diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2013-07-12 07:42:07 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2013-07-12 07:42:07 -0500 |
commit | a19955f3f81b1a5eb8fc928bc5dcf8a24bb6833f (patch) | |
tree | 54b1593439a2ef0e69d30a3b8cb891d865db9d31 | |
parent | c9352cd0a8363e4508d19e66ccf373b2abb2b7d3 (diff) | |
download | ayatana-indicator-session-a19955f3f81b1a5eb8fc928bc5dcf8a24bb6833f.tar.gz ayatana-indicator-session-a19955f3f81b1a5eb8fc928bc5dcf8a24bb6833f.tar.bz2 ayatana-indicator-session-a19955f3f81b1a5eb8fc928bc5dcf8a24bb6833f.zip |
add the online-accounts action and unit tests for it
-rw-r--r-- | src/actions.c | 8 | ||||
-rw-r--r-- | src/actions.h | 2 | ||||
-rw-r--r-- | src/backend-dbus/actions.c | 10 | ||||
-rw-r--r-- | src/service.c | 29 | ||||
-rw-r--r-- | tests/backend-mock-actions.c | 7 | ||||
-rw-r--r-- | tests/test-service.cc | 9 |
6 files changed, 55 insertions, 10 deletions
diff --git a/src/actions.c b/src/actions.c index ca086b7..563f626 100644 --- a/src/actions.c +++ b/src/actions.c @@ -250,6 +250,14 @@ indicator_session_actions_has_online_account_error (IndicatorSessionActions * se ***/ void +indicator_session_actions_online_accounts (IndicatorSessionActions * self) +{ + g_return_if_fail (INDICATOR_IS_SESSION_ACTIONS (self)); + + INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->online_accounts (self); +} + +void indicator_session_actions_settings (IndicatorSessionActions * self) { g_return_if_fail (INDICATOR_IS_SESSION_ACTIONS (self)); diff --git a/src/actions.h b/src/actions.h index 0f8aa1d..e31685e 100644 --- a/src/actions.h +++ b/src/actions.h @@ -78,6 +78,7 @@ struct _IndicatorSessionActionsClass void (*help) (IndicatorSessionActions * self); void (*about) (IndicatorSessionActions * self); void (*settings) (IndicatorSessionActions * self); + void (*online_accounts) (IndicatorSessionActions * self); void (*switch_to_greeter) (IndicatorSessionActions * self); void (*switch_to_screensaver) (IndicatorSessionActions * self); @@ -121,6 +122,7 @@ void indicator_session_actions_power_off (IndicatorSession void indicator_session_actions_help (IndicatorSessionActions * self); void indicator_session_actions_about (IndicatorSessionActions * self); void indicator_session_actions_settings (IndicatorSessionActions * self); +void indicator_session_actions_online_accounts (IndicatorSessionActions * self); void indicator_session_actions_switch_to_screensaver (IndicatorSessionActions * self); void indicator_session_actions_switch_to_greeter (IndicatorSessionActions * self); diff --git a/src/backend-dbus/actions.c b/src/backend-dbus/actions.c index ed1e708..9030ca7 100644 --- a/src/backend-dbus/actions.c +++ b/src/backend-dbus/actions.c @@ -311,6 +311,9 @@ on_webcredentials_proxy_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res, gp g_signal_connect_swapped (webcredentials, "notify::error-status", G_CALLBACK(indicator_session_actions_notify_has_online_account_error), gself); + + if (webcredentials_get_error_status (webcredentials)) + indicator_session_actions_notify_has_online_account_error (gself); } log_and_clear_error (&err, G_STRLOC, G_STRFUNC); @@ -715,6 +718,12 @@ my_settings (IndicatorSessionActions * self G_GNUC_UNUSED) } static void +my_online_accounts (IndicatorSessionActions * self G_GNUC_UNUSED) +{ + run_outside_app ("gnome-control-center credentials"); +} + +static void my_about (IndicatorSessionActions * self G_GNUC_UNUSED) { run_outside_app ("gnome-control-center info"); @@ -855,6 +864,7 @@ indicator_session_actions_dbus_class_init (IndicatorSessionActionsDbusClass * kl actions_class->reboot = my_reboot; actions_class->power_off = my_power_off; actions_class->settings = my_settings; + actions_class->online_accounts = my_online_accounts; actions_class->help = my_help; actions_class->about = my_about; actions_class->switch_to_screensaver = my_switch_to_screensaver; diff --git a/src/service.c b/src/service.c index 3de37e3..74acd89 100644 --- a/src/service.c +++ b/src/service.c @@ -623,6 +623,14 @@ on_about_activated (GSimpleAction * a G_GNUC_UNUSED, } static void +on_online_accounts_activated (GSimpleAction * a G_GNUC_UNUSED, + GVariant * param G_GNUC_UNUSED, + gpointer gself) +{ + indicator_session_actions_online_accounts (get_backend_actions(gself)); +} + +static void on_help_activated (GSimpleAction * a G_GNUC_UNUSED, GVariant * param G_GNUC_UNUSED, gpointer gself) @@ -720,16 +728,17 @@ init_gactions (IndicatorSessionService * self) priv_t * p = self->priv; GActionEntry entries[] = { - { "about", on_about_activated }, - { "help", on_help_activated }, - { "settings", on_settings_activated }, - { "logout", on_logout_activated }, - { "suspend", on_suspend_activated }, - { "hibernate", on_hibernate_activated }, - { "reboot", on_reboot_activated }, - { "power-off", on_power_off_activated }, - { "switch-to-screensaver", on_screensaver_activated }, - { "switch-to-greeter", on_greeter_activated } + { "about", on_about_activated }, + { "help", on_help_activated }, + { "hibernate", on_hibernate_activated }, + { "logout", on_logout_activated }, + { "online-accounts", on_online_accounts_activated }, + { "reboot", on_reboot_activated }, + { "settings", on_settings_activated }, + { "switch-to-screensaver", on_screensaver_activated }, + { "switch-to-greeter", on_greeter_activated }, + { "suspend", on_suspend_activated }, + { "power-off", on_power_off_activated } }; p->actions = g_simple_action_group_new (); diff --git a/tests/backend-mock-actions.c b/tests/backend-mock-actions.c index af4afd9..25a606f 100644 --- a/tests/backend-mock-actions.c +++ b/tests/backend-mock-actions.c @@ -141,6 +141,12 @@ my_settings (IndicatorSessionActions * self G_GNUC_UNUSED) g_settings_set_string (mock_settings, "last-command", "settings"); } +static void +my_online_accounts (IndicatorSessionActions * self G_GNUC_UNUSED) +{ + g_settings_set_string (mock_settings, "last-command", "online-accounts"); +} + static gboolean my_can_prompt (IndicatorSessionActions * self G_GNUC_UNUSED) { @@ -195,6 +201,7 @@ indicator_session_actions_mock_class_init (IndicatorSessionActionsMockClass * kl actions_class->reboot = my_reboot; actions_class->power_off = my_power_off; actions_class->settings = my_settings; + actions_class->online_accounts = my_online_accounts; actions_class->help = my_help; actions_class->about = my_about; actions_class->switch_to_screensaver = my_switch_to_screensaver; diff --git a/tests/test-service.cc b/tests/test-service.cc index 86f49e6..2027ec0 100644 --- a/tests/test-service.cc +++ b/tests/test-service.cc @@ -589,6 +589,15 @@ TEST_F (ServiceTest, OnlineAccountError) ASSERT_TRUE (find_menu_item_for_action ("indicator.online-accounts", &model, &pos)); g_clear_object (&model); + // check that the service has a corresponding action + ASSERT_TRUE (g_action_group_has_action (G_ACTION_GROUP(action_group), "online-accounts")); + ASSERT_TRUE (g_action_group_get_action_enabled (G_ACTION_GROUP(action_group), "online-accounts")); + + // confirm that activating the action is handled by the service + g_action_group_activate_action (G_ACTION_GROUP(action_group), "online-accounts", NULL); + wait_for_signal (mock_settings, "changed::last-command"); + 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)"); |