aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2013-06-28 21:15:15 -0500
committerCharles Kerr <charles.kerr@canonical.com>2013-06-28 21:15:15 -0500
commit3222a77d7159826d89743685d35710597f269e00 (patch)
tree6a40a3aa0d436891aad2e6d7d2769389edb0f1dc /tests
parentf85ba52944c1924271ce4734a31dacb4a8e51e71 (diff)
downloadayatana-indicator-session-3222a77d7159826d89743685d35710597f269e00.tar.gz
ayatana-indicator-session-3222a77d7159826d89743685d35710597f269e00.tar.bz2
ayatana-indicator-session-3222a77d7159826d89743685d35710597f269e00.zip
fix test breakage introduced with the recent commit that hides the reboot menuitem when running in unity shell
Diffstat (limited to 'tests')
-rw-r--r--tests/backend-mock-guest.c34
-rw-r--r--tests/backend-mock-users.c42
-rw-r--r--tests/test-service.cc25
3 files changed, 64 insertions, 37 deletions
diff --git a/tests/backend-mock-guest.c b/tests/backend-mock-guest.c
index b04c805..8bc188f 100644
--- a/tests/backend-mock-guest.c
+++ b/tests/backend-mock-guest.c
@@ -34,21 +34,9 @@ G_DEFINE_TYPE (IndicatorSessionGuestMock,
indicator_session_guest_mock,
INDICATOR_TYPE_SESSION_GUEST)
-/***
-**** Virtual Functions
-***/
-
-static void
-my_dispose (GObject * o)
-{
- G_OBJECT_CLASS (indicator_session_guest_mock_parent_class)->dispose (o);
-}
-
-static void
-my_finalize (GObject * o)
-{
- G_OBJECT_CLASS (indicator_session_guest_mock_parent_class)->finalize (o);
-}
+/**
+*** IndicatorSessionGuest virtual functions
+**/
static gboolean
my_is_allowed (IndicatorSessionGuest * self)
@@ -77,6 +65,22 @@ my_switch_to_guest (IndicatorSessionGuest * self G_GNUC_UNUSED)
}
/***
+**** GObject virtual Functions
+***/
+
+static void
+my_dispose (GObject * o)
+{
+ G_OBJECT_CLASS (indicator_session_guest_mock_parent_class)->dispose (o);
+}
+
+static void
+my_finalize (GObject * o)
+{
+ G_OBJECT_CLASS (indicator_session_guest_mock_parent_class)->finalize (o);
+}
+
+/***
**** GObject Boilerplate
***/
diff --git a/tests/backend-mock-users.c b/tests/backend-mock-users.c
index bae40b6..f2291cd 100644
--- a/tests/backend-mock-users.c
+++ b/tests/backend-mock-users.c
@@ -32,25 +32,9 @@ G_DEFINE_TYPE (IndicatorSessionUsersMock,
INDICATOR_TYPE_SESSION_USERS)
/***
-****
+**** IndicatorSessionUsers virtual functions
***/
-static void
-my_dispose (GObject * o)
-{
- G_OBJECT_CLASS (indicator_session_users_mock_parent_class)->dispose (o);
-}
-
-static void
-my_finalize (GObject * o)
-{
- priv_t * p = INDICATOR_SESSION_USERS_MOCK (o)->priv;
-
- g_hash_table_destroy (p->users);
-
- G_OBJECT_CLASS (indicator_session_users_mock_parent_class)->finalize (o);
-}
-
static gboolean
my_is_live_session (IndicatorSessionUsers * users G_GNUC_UNUSED)
{
@@ -96,6 +80,30 @@ my_get_user (IndicatorSessionUsers * self, guint uid)
return ret;
}
+/***
+**** GObject virtual functions
+***/
+
+static void
+my_dispose (GObject * o)
+{
+ G_OBJECT_CLASS (indicator_session_users_mock_parent_class)->dispose (o);
+}
+
+static void
+my_finalize (GObject * o)
+{
+ priv_t * p = INDICATOR_SESSION_USERS_MOCK (o)->priv;
+
+ g_hash_table_destroy (p->users);
+
+ G_OBJECT_CLASS (indicator_session_users_mock_parent_class)->finalize (o);
+}
+
+/***
+**** GObject boilerplate
+***/
+
static void
/* cppcheck-suppress unusedFunction */
indicator_session_users_mock_class_init (IndicatorSessionUsersMockClass * klass)
diff --git a/tests/test-service.cc b/tests/test-service.cc
index 996332d..86f49e6 100644
--- a/tests/test-service.cc
+++ b/tests/test-service.cc
@@ -285,6 +285,18 @@ class ServiceTest: public GTestDBusFixture
return success;
}
+ bool action_menuitem_exists (const char * action_name)
+ {
+ bool found;
+ GMenuModel * model = 0;
+ int pos = -1;
+
+ if ((found = find_menu_item_for_action (action_name, &model, &pos)))
+ g_object_unref (G_OBJECT(model));
+
+ return found;
+ }
+
bool action_menuitem_label_is_ellipsized (const char * action_name)
{
int pos = -1;
@@ -477,7 +489,8 @@ TEST_F (ServiceTest, ConfirmationDisabledByBackend)
// confirm that the ellipsis are correct
ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.switch-to-greeter"));
ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.logout"));
- ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.reboot"));
+ if (action_menuitem_exists ("indicator.reboot"))
+ ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.reboot"));
ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.power-off"));
// now toggle the can-prompt flag
@@ -490,7 +503,8 @@ TEST_F (ServiceTest, ConfirmationDisabledByBackend)
// confirm that the ellipsis are correct
ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.switch-to-greeter"));
ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.logout"));
- ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.reboot"));
+ if (action_menuitem_exists ("indicator.reboot"))
+ ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.reboot"));
ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.power-off"));
// cleanup
@@ -509,7 +523,8 @@ TEST_F (ServiceTest, ConfirmationDisabledByUser)
// confirm that the ellipsis are correct
ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.switch-to-greeter"));
ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.logout"));
- ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.reboot"));
+ if (action_menuitem_exists ("indicator.reboot"))
+ ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.reboot"));
ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.power-off"));
// now toggle the can-prompt flag
@@ -522,7 +537,8 @@ TEST_F (ServiceTest, ConfirmationDisabledByUser)
// confirm that the ellipsis are correct
ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.switch-to-greeter"));
ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.logout"));
- ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.reboot"));
+ if (action_menuitem_exists ("indicator.reboot"))
+ ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.reboot"));
ASSERT_EQ (confirm, action_menuitem_label_is_ellipsized ("indicator.power-off"));
// cleanup
@@ -542,7 +558,6 @@ TEST_F (ServiceTest, DefaultMenuItems)
ASSERT_TRUE (find_menu_item_for_action ("indicator.logout", NULL, NULL));
ASSERT_TRUE (find_menu_item_for_action ("indicator.suspend", NULL, NULL));
ASSERT_TRUE (find_menu_item_for_action ("indicator.hibernate", NULL, NULL));
- ASSERT_TRUE (find_menu_item_for_action ("indicator.reboot", NULL, NULL));
ASSERT_TRUE (find_menu_item_for_action ("indicator.power-off", NULL, NULL));
}