aboutsummaryrefslogtreecommitdiff
path: root/tests/backend-dbus/test-users.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/backend-dbus/test-users.cc')
-rw-r--r--tests/backend-dbus/test-users.cc54
1 files changed, 40 insertions, 14 deletions
diff --git a/tests/backend-dbus/test-users.cc b/tests/backend-dbus/test-users.cc
index bd0547d..fa52df3 100644
--- a/tests/backend-dbus/test-users.cc
+++ b/tests/backend-dbus/test-users.cc
@@ -153,23 +153,25 @@ TEST_F (Users, HelloWorld)
ASSERT_TRUE (true);
}
-
/**
* Confirm that 'users' can get the cached users from our Mock Accounts
*/
TEST_F (Users, InitialUsers)
{
- const guint logged_in_uid = ck_session->user()->uid();
GStrv keys = indicator_session_users_get_keys (users);
+ const MockUser * active_user = login1_seat->active_user ();
ASSERT_EQ (12, g_strv_length (keys));
for (int i=0; keys && keys[i]; ++i)
{
- MockUser * mu = accounts->find_by_path (keys[i]);
- const bool is_logged_in = mu->uid() == logged_in_uid;
- const bool is_current_user = mu->uid() == logged_in_uid;
- compare_user (keys[i], mu, is_logged_in, is_current_user);
+ IndicatorSessionUser * isu = indicator_session_users_get_user (users, keys[i]);
+ MockUser * mu = accounts->find_by_uid (isu->uid);
+ const bool is_logged_in = login1_seat->find_session_for_user (isu->uid) != 0;
+ const bool is_active = active_user && (active_user->uid() == isu->uid);
+ compare_user (isu, mu, is_logged_in, is_active);
+
+ indicator_session_user_free (isu);
}
g_strfreev (keys);
@@ -187,7 +189,9 @@ TEST_F (Users, UserAdded)
ASSERT_EQ (0, event_keys.size());
wait_for_signals (users, INDICATOR_SESSION_USERS_SIGNAL_USER_ADDED, 1);
ASSERT_EQ (1, event_keys.size());
- ASSERT_STREQ (mu->path(), event_keys[0].c_str());
+ IndicatorSessionUser * isu = indicator_session_users_get_user (users, event_keys[0].c_str());
+ ASSERT_EQ (mu->uid(), isu->uid);
+ indicator_session_user_free (isu);
compare_user (event_keys[0], mu, false, false);
}
@@ -197,24 +201,45 @@ TEST_F (Users, UserAdded)
*/
TEST_F (Users, UserRemoved)
{
- MockUser * mu;
+ MockUser * mu = accounts->find_by_username ("pdavison");
- mu = accounts->find_by_username ("pdavison");
+ /* confirm that users knows about pdavison */
+ bool found = false;
+ GStrv keys = indicator_session_users_get_keys (users);
+ ASSERT_EQ (12, g_strv_length (keys));
+ for (int i=0; !found && keys && keys[i]; i++)
+ {
+ IndicatorSessionUser * isu = indicator_session_users_get_user (users, keys[i]);
+ found = isu->uid == mu->uid();
+ indicator_session_user_free (isu);
+ }
+ g_strfreev (keys);
+ ASSERT_TRUE (found);
+
+ /* on the bus, remove pdavison. */
accounts->remove_user (mu);
+
+ /* now, users should emit a 'user removed' signal... */
ASSERT_EQ (0, event_keys.size());
wait_for_signals (users, INDICATOR_SESSION_USERS_SIGNAL_USER_REMOVED, 1);
ASSERT_EQ (1, event_keys.size());
- ASSERT_STREQ (mu->path(), event_keys[0].c_str());
- GStrv keys = indicator_session_users_get_keys (users);
+ /* confirm that users doesn't know about pdavison */
+ keys = indicator_session_users_get_keys (users);
ASSERT_EQ (11, g_strv_length (keys));
+ for (int i=0; keys && keys[i]; i++)
+ {
+ IndicatorSessionUser * isu = indicator_session_users_get_user (users, keys[i]);
+ ASSERT_NE (event_keys[0], keys[i]);
+ ASSERT_NE (mu->uid(), isu->uid);
+ indicator_session_user_free (isu);
+ }
g_strfreev (keys);
- ASSERT_TRUE (indicator_session_users_get_user (users, mu->path()) == NULL);
-
delete mu;
}
+#if 0
/**
* Confirm that 'users' notices when a user's real name changes
*/
@@ -368,10 +393,11 @@ TEST_F (Users, LiveSession)
MockConsoleKitSession * session = ck_seat->add_session_by_user (live_user);
wait_msec (100);
ck_seat->activate_session (session);
- wait_for_signal (users, "notify::"INDICATOR_SESSION_USERS_PROP_IS_LIVE_SESSION);
+ wait_for_signal (users, "notify::" INDICATOR_SESSION_USERS_PROP_IS_LIVE_SESSION);
// confirm the backend thinks it's a live session
ASSERT_TRUE (indicator_session_users_is_live_session (users));
g_object_get (users, INDICATOR_SESSION_USERS_PROP_IS_LIVE_SESSION, &b, NULL);
ASSERT_TRUE (b);
}
+#endif