Make sure self-switch works on fixed-dir backend. 82/320682/1
authorMichal Bloch <m.bloch@samsung.com>
Wed, 5 Mar 2025 18:25:40 +0000 (19:25 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Wed, 5 Mar 2025 19:17:56 +0000 (20:17 +0100)
Change-Id: I93e1f6eeaa9460526da625e0747b6586342ba96b

src/service/src/fs_helpers.cpp
tests/api_tests/test_api_switchuser.cpp

index fb6938200ade95dce9a06c86f5afaa1003273bdb..57894cd483205068e012b2fdb8d47c8187870ecd 100644 (file)
@@ -262,6 +262,9 @@ static const DirBackend& GetBackendOfSubsession(const fs::path& path)
 
 bool switch_user_subsession(const int session_uid, const std::string_view prev_subsession, const std::string_view next_subsession)
 {
+       if (prev_subsession == next_subsession)
+               return true;
+
        /* We switch into next first, and only then switch away from prev. This is so
         * that we are never in an intermediate "no session" state which is important
         * for robustness (consider the case where Away succeeds and Into fails). */
index bf8e45de228a42f76baf0f81971fb2661a5a4546..4cd42f5329bbdcf9d58f634f6d111432952130fc 100644 (file)
@@ -7,7 +7,7 @@
 
 // Test
 
-const int action_items = 29;
+const int action_items = 31;
 
 TEST(subsession_switch_user_test, APISwitchUserTest) {
 
@@ -105,6 +105,13 @@ TEST(subsession_switch_user_test, APISwitchUserTest) {
                                                        .cb_expected = SUBSESSION_ERROR_INVALID_PARAMETER,
                                                        .cb_desc = "Check if getting current user [" + std::string(TestUserStr::user_5) + " ]  is done", },
 
+                       // Fixed size -> self
+                       api_call_res_t{ .call_result = std::move(subsession_switch_user_l<subsession_5001>( TestUserStr::user_5)),
+                                                       .expected = SUBSESSION_ERROR_NONE,
+                                                       .desc = "Check if switch to [ " + std::string(TestUserStr::user_5) + " ] is successful",
+                                                       .cb_expected = SUBSESSION_ERROR_NONE,
+                                                       .cb_desc = "Check if switch to [" + std::string(TestUserStr::user_5) + " ] callback is successful", },
+
                        // Fixed size -> regular dir
                        api_call_res_t{ .call_result = std::move(subsession_switch_user_l<subsession_5001>( TestUserStr::user_1)),
                                                        .expected = SUBSESSION_ERROR_NONE,
@@ -118,6 +125,14 @@ TEST(subsession_switch_user_test, APISwitchUserTest) {
                                                        .cb_expected = SUBSESSION_ERROR_INVALID_PARAMETER,
                                                        .cb_desc = "Check if getting current user [" + std::string(TestUserStr::user_1) + " ]  is done", },
 
+                       // Regular dir -> self
+                       api_call_res_t{ .call_result = std::move(subsession_switch_user_l<subsession_5001>( TestUserStr::user_1)),
+                                                       .expected = SUBSESSION_ERROR_NONE,
+                                                       .desc = "Check if switch to [ " + std::string(TestUserStr::user_1) + " ] is successful",
+                                                       .cb_expected = SUBSESSION_ERROR_NONE,
+                                                       .cb_desc = "Check if switch to [" + std::string(TestUserStr::user_1) + " ] callback is successful", },
+
+
                        // Regular dir -> default
                        api_call_res_t{ .call_result = std::move(subsession_switch_user_l<subsession_5001>( TestUserStr::user_0)),
                                                        .expected = SUBSESSION_ERROR_NONE,