diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/com.canonical.indicator.session.gschema.xml | 7 | ||||
-rw-r--r-- | tests/gtest-dbus-fixture.h | 55 | ||||
-rw-r--r-- | tests/test-service.cc | 17 |
3 files changed, 49 insertions, 30 deletions
diff --git a/tests/com.canonical.indicator.session.gschema.xml b/tests/com.canonical.indicator.session.gschema.xml index 76b2be3..60e680b 100644 --- a/tests/com.canonical.indicator.session.gschema.xml +++ b/tests/com.canonical.indicator.session.gschema.xml @@ -26,7 +26,12 @@ <summary>Determine the visibility of the User's real name on the panel</summary> <description>Allow for the Removal of the users name from the panel</description> </key> + <key type="b" name="user-show-menu"> + <default>true</default> + <summary>Show the list of users</summary> + <description>Allow for the user menu to be hidden by the user.</description> + </key> </schema> -</schemalist>
\ No newline at end of file +</schemalist> diff --git a/tests/gtest-dbus-fixture.h b/tests/gtest-dbus-fixture.h index e6cd9c7..dedb727 100644 --- a/tests/gtest-dbus-fixture.h +++ b/tests/gtest-dbus-fixture.h @@ -54,13 +54,6 @@ class GTestDBusFixture : public ::testing::Test g_main_loop_quit (self->loop); } - static gboolean - wait_for_signal__timeout (gpointer name) - { - g_error ("%s: timed out waiting for signal '%s'", G_STRLOC, (char*)name); - return G_SOURCE_REMOVE; - } - protected: virtual void SetUp () @@ -103,29 +96,45 @@ class GTestDBusFixture : public ::testing::Test g_clear_pointer (&loop, g_main_loop_unref); } - /* convenience func to loop while waiting for a GObject's signal */ - void wait_for_signal (gpointer o, const gchar * signal) + private: + + static gboolean + wait_for_signal__timeout(gpointer name) { - const int timeout_seconds = 5; // arbitrary + g_error("%s: timed out waiting for signal '%s'", G_STRLOC, (char*)name); + return G_SOURCE_REMOVE; + } + static gboolean + wait_msec__timeout(gpointer loop) + { + g_main_loop_quit(static_cast<GMainLoop*>(loop)); + return G_SOURCE_CONTINUE; + } + + protected: + + /* convenience func to loop while waiting for a GObject's signal */ + void wait_for_signal(gpointer o, const gchar * signal, const int timeout_seconds=5) + { // wait for the signal or for timeout, whichever comes first - guint handler_id = g_signal_connect_swapped (o, signal, - G_CALLBACK(g_main_loop_quit), - loop); - gulong timeout_id = g_timeout_add_seconds (timeout_seconds, - wait_for_signal__timeout, - loop); - g_main_loop_run (loop); - g_source_remove (timeout_id); - g_signal_handler_disconnect (o, handler_id); + const auto handler_id = g_signal_connect_swapped(o, signal, + G_CALLBACK(g_main_loop_quit), + loop); + const auto timeout_id = g_timeout_add_seconds(timeout_seconds, + wait_for_signal__timeout, + loop); + g_main_loop_run(loop); + g_source_remove(timeout_id); + g_signal_handler_disconnect(o, handler_id); } /* convenience func to loop for N msec */ - void wait_msec (int msec) + void wait_msec(int msec=50) { - guint id = g_timeout_add (msec, (GSourceFunc)g_main_loop_quit, loop); - g_main_loop_run (loop); - g_source_remove (id); + const auto id = g_timeout_add(msec, wait_msec__timeout, loop); + g_main_loop_run(loop); + g_source_remove(id); } GMainLoop * loop; diff --git a/tests/test-service.cc b/tests/test-service.cc index f14fe61..ab84459 100644 --- a/tests/test-service.cc +++ b/tests/test-service.cc @@ -616,7 +616,7 @@ TEST_F (ServiceTest, OnlineAccountError) check_last_command_is ("online-accounts"); // check that the header's icon and a11y adjusted to the error state - check_header ("", "system-devices-panel-alert", "System (Attention Required)"); + check_header ("", "system-devices-panel", "System"); // cleanup g_settings_reset (mock_settings, error_key); @@ -756,12 +756,7 @@ TEST_F (ServiceTest, User) g_settings_set_boolean (indicator_settings, show_name_key, true); wait_for_signal (action_group, "action-state-changed"); check_header ("Third Doctor", "system-devices-panel", "System, Third Doctor"); - g_settings_set_boolean (mock_settings, error_key, true); - wait_for_signal (action_group, "action-state-changed"); - check_header ("Third Doctor", "system-devices-panel-alert", "System, Third Doctor (Attention Required)"); - g_settings_reset (mock_settings, error_key); g_settings_reset (indicator_settings, show_name_key); - wait_for_menu_resync (); // try setting the max user count to 2... // since troughton has the fewest logins, he should get culled @@ -812,6 +807,16 @@ TEST_F (ServiceTest, User) check_label ("Third Doctor", switch_menu, 8); g_clear_object (&switch_menu); + /* Hide the user list */ + g_settings_set_boolean (indicator_settings, "user-show-menu", FALSE); + wait_for_menu_resync (); + // now there should be 2 menuitems: greeter + guest + ASSERT_TRUE (find_menu_item_for_action ("indicator.switch-to-screensaver", &switch_menu, &pos)); + ASSERT_EQ (0, pos); + ASSERT_EQ (2, g_menu_model_get_n_items (switch_menu)); + g_clear_object (&switch_menu); + g_settings_set_boolean (indicator_settings, "user-show-menu", TRUE); + // now switch to one of the doctors g_action_group_activate_action (G_ACTION_GROUP(action_group), "switch-to-user", |