From ae39f7001e5603010afc02de29787ade6d48ef14 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 22 Mar 2013 16:34:34 -0500 Subject: port indicator-session to GMenu/cmake. Code coverage increased from 0% to 95.4%. --- tests/backend-mock-guest.c | 129 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 tests/backend-mock-guest.c (limited to 'tests/backend-mock-guest.c') diff --git a/tests/backend-mock-guest.c b/tests/backend-mock-guest.c new file mode 100644 index 0000000..0428783 --- /dev/null +++ b/tests/backend-mock-guest.c @@ -0,0 +1,129 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * Authors: + * Charles Kerr + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include + +#include "backend-mock-guest.h" + +struct _IndicatorSessionGuestMockPriv +{ + gboolean guest_is_active; + gboolean guest_is_logged_in; + gboolean guest_is_allowed; +}; + +typedef IndicatorSessionGuestMockPriv priv_t; + +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); +} + +static gboolean +my_is_allowed (IndicatorSessionGuest * self) +{ + return INDICATOR_SESSION_GUEST_MOCK(self)->priv->guest_is_allowed; +} + +static gboolean +my_is_logged_in (IndicatorSessionGuest * self) +{ + g_return_val_if_fail (INDICATOR_IS_SESSION_GUEST_MOCK(self), FALSE); + + return INDICATOR_SESSION_GUEST_MOCK(self)->priv->guest_is_logged_in; +} + +static gboolean +my_is_active (IndicatorSessionGuest * self) +{ + return INDICATOR_SESSION_GUEST_MOCK(self)->priv->guest_is_active; +} + +static void +my_switch_to_guest (IndicatorSessionGuest * self) +{ + g_message ("%s %s FIXME", G_STRLOC, G_STRFUNC); +} + +/*** +**** GObject Boilerplate +***/ + +static void +/* cppcheck-suppress unusedFunction */ +indicator_session_guest_mock_class_init (IndicatorSessionGuestMockClass * klass) +{ + GObjectClass * object_class; + IndicatorSessionGuestClass * guest_class; + + object_class = G_OBJECT_CLASS (klass); + object_class->dispose = my_dispose; + object_class->finalize = my_finalize; + + guest_class = INDICATOR_SESSION_GUEST_CLASS (klass); + guest_class->is_allowed = my_is_allowed; + guest_class->is_logged_in = my_is_logged_in; + guest_class->is_active = my_is_active; + guest_class->switch_to_guest = my_switch_to_guest; + + g_type_class_add_private (klass, sizeof (IndicatorSessionGuestMockPriv)); +} + +static void +/* cppcheck-suppress unusedFunction */ +indicator_session_guest_mock_init (IndicatorSessionGuestMock * self) +{ + priv_t * p; + + p = G_TYPE_INSTANCE_GET_PRIVATE (self, + INDICATOR_TYPE_SESSION_GUEST_MOCK, + IndicatorSessionGuestMockPriv); + self->priv = p; + + p->guest_is_allowed = TRUE; + p->guest_is_active = FALSE; + p->guest_is_logged_in = FALSE; +} + +/*** +**** Public +***/ + +IndicatorSessionGuest * +indicator_session_guest_mock_new (void) +{ + gpointer o = g_object_new (INDICATOR_TYPE_SESSION_GUEST_MOCK, NULL); + + return INDICATOR_SESSION_GUEST (o); +} -- cgit v1.2.3 From 0c5a240c6fb66d4b2dd620c81d48a065bedeb7f7 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 19 Jun 2013 18:22:32 -0500 Subject: silence unused variable warning --- tests/backend-mock-guest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/backend-mock-guest.c') diff --git a/tests/backend-mock-guest.c b/tests/backend-mock-guest.c index 0428783..b04c805 100644 --- a/tests/backend-mock-guest.c +++ b/tests/backend-mock-guest.c @@ -71,7 +71,7 @@ my_is_active (IndicatorSessionGuest * self) } static void -my_switch_to_guest (IndicatorSessionGuest * self) +my_switch_to_guest (IndicatorSessionGuest * self G_GNUC_UNUSED) { g_message ("%s %s FIXME", G_STRLOC, G_STRFUNC); } -- cgit v1.2.3 From 3222a77d7159826d89743685d35710597f269e00 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 28 Jun 2013 21:15:15 -0500 Subject: fix test breakage introduced with the recent commit that hides the reboot menuitem when running in unity shell --- tests/backend-mock-guest.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'tests/backend-mock-guest.c') 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) @@ -76,6 +64,22 @@ my_switch_to_guest (IndicatorSessionGuest * self G_GNUC_UNUSED) g_message ("%s %s FIXME", G_STRLOC, G_STRFUNC); } +/*** +**** 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 ***/ -- cgit v1.2.3