Merge lp:~charlesk/indicator-session/lp-1074065 into lp:indicator-session/13.04

Proposed by Charles Kerr
Status: Merged
Approved by: Allan LeSage
Approved revision: 377
Merged at revision: 376
Proposed branch: lp:~charlesk/indicator-session/lp-1074065
Merge into: lp:indicator-session/13.04
Diff against target: 1002 lines (+403/-472)
10 files modified
configure.ac (+7/-6)
debian/changelog (+1/-5)
debian/control (+0/-1)
debian/rules (+0/-3)
tests/Makefile.am (+33/-19)
tests/gtest-dbus-helper.h (+0/-418)
tests/indicator-session.service.in (+3/-0)
tests/org.gnome.desktop.lockdown.gschema.xml (+45/-0)
tests/org.gnome.settings-daemon.plugins.media-keys.gschema.xml (+203/-0)
tests/test-service.cc (+111/-20)
To merge this branch: bzr merge lp:~charlesk/indicator-session/lp-1074065
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Indicator Applet Developers Pending
Review via email: mp+133172@code.launchpad.net

Commit message

Reimplement test-service s.t. we actually test activating the service via dbus. Drop unneeded Xorg baggage.

Description of the change

Reimplement test-service s.t. we actually test activating the service via dbus. Drop unneeded Xorg baggage.

This patch is based on the GTestDBus tests in indicator-sync. It adds into the tests/ directory a test version of the .service file, and tells GTestDBus about it via a call to g_test_dbus_add_service_dir(), so that we can launch the service before it's been installed on the system.

It also removes gtest-dbus-helper.h, which is superseded here by using GTestDBus directly.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

I'm not sure why this is failing. When I run the same code on a stock install in VirtualBox, service activation succeeds. Maybe there's some package needed for dbus activation that's not getting installed here?

Adding g_message() calls to confirm that the g_dbus_connection_call*() funcs are where the error messages are coming from...

Revision history for this message
Charles Kerr (charlesk) wrote :

Looks like Jenkins won't kick off a CI build for a WIP. Switching to "Needs Review" to get its attention. Pardon the email noise :)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Allan LeSage (allanlesage) wrote :

> FAILED: Continuous integration, rev:375
> http://jenkins.qa.ubuntu.com/job/indicator-session-ci/29/
> Executed test runs:
> FAILURE: http://jenkins.qa.ubuntu.com/job/indicator-session-
> ci/./build=pbuilder,distribution=quantal,flavor=amd64/29/console
> FAILURE: http://jenkins.qa.ubuntu.com/job/indicator-session-
> ci/./build=pbuilder,distribution=quantal,flavor=i386/29/console

This last failed result was a mis-configuration error on my part.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
377. By Charles Kerr

re-enable the tests/ directory

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'configure.ac'
--- configure.ac 2012-11-14 20:20:13 +0000
+++ configure.ac 2012-11-16 18:58:44 +0000
@@ -25,6 +25,7 @@
25# Dependencies 25# Dependencies
26###########################26###########################
2727
28GIO_REQUIRED_VERSION=2.33
28GLIB_REQUIRED_VERSION=2.3329GLIB_REQUIRED_VERSION=2.33
29GTK_REQUIRED_VERSION=3.030GTK_REQUIRED_VERSION=3.0
30INDICATOR_REQUIRED_VERSION=0.3.1931INDICATOR_REQUIRED_VERSION=0.3.19
@@ -135,16 +136,15 @@
135 AC_MSG_ERROR([tests were requested but gtest is not installed.])136 AC_MSG_ERROR([tests were requested but gtest is not installed.])
136 fi137 fi
137 if test "x$enable_tests" = "xyes"; then138 if test "x$enable_tests" = "xyes"; then
138 PKG_CHECK_MODULES([TEST_SERVICE],[indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION139 PKG_CHECK_MODULES([TEST_SERVICE],[glib-2.0 >= $GLIB_REQUIRED_VERSION
139 dbustest-1 >= $DBUSTEST_REQUIRED_VERSION140 gio-2.0 >= $GIO_REQUIRED_VERSION],
140 dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION],141 [enable_tests="yes"],
141 [enable_tests="yes"],142 [enable_tests="no"])
142 [enable_tests="no"])
143 fi143 fi
144fi144fi
145AM_CONDITIONAL([BUILD_TESTS],[test "x$enable_tests" = "xyes"])145AM_CONDITIONAL([BUILD_TESTS],[test "x$enable_tests" = "xyes"])
146AC_SUBST([TEST_SERVICE_CFLAGS])146AC_SUBST([TEST_SERVICE_CFLAGS])
147AC_SUBST([TEST_SERVICE_LDFLAGS])147AC_SUBST([TEST_SERVICE_LIBS])
148148
149##############################149##############################
150# Custom Junk150# Custom Junk
@@ -211,6 +211,7 @@
211data/icons/scalable/status/Makefile211data/icons/scalable/status/Makefile
212data/extra-sessions/Makefile212data/extra-sessions/Makefile
213tests/Makefile213tests/Makefile
214tests/indicator-session.service
214po/Makefile.in215po/Makefile.in
215])216])
216217
217218
=== modified file 'debian/changelog'
--- debian/changelog 2012-11-16 03:42:55 +0000
+++ debian/changelog 2012-11-16 18:58:44 +0000
@@ -4,14 +4,10 @@
4 - Add DPKG_GENSYMBOLS_CHECK_LEVEL=4.4 - Add DPKG_GENSYMBOLS_CHECK_LEVEL=4.
5 - Use the dh sequencer with autoreconf.5 - Use the dh sequencer with autoreconf.
6 - Override dh_autoreconf to run autogen.sh.6 - Override dh_autoreconf to run autogen.sh.
7 - Temporarily disable running tests due to an issue with getting the
8 gsettings schema for testing.
9 * debian/control:7 * debian/control:
10 - Add dh-autoreconf to Build-Depends.8 - Add dh-autoreconf to Build-Depends.
11 - Add gnome-common to Build-Depends.9 - Add gnome-common to Build-Depends.
12 - Add libdbustest1-dev, dbus-test-runner to Build-Depends.10 - Add libgtest-dev, libdbustest1-dev, dbus-test-runner to Build-Depends.
13 - Explicitly list libgtest-dev in Build-Depends, even though it does get
14 pulled in via libxorg-gtest-dev.
15 - Adjust style to be consistent and use trailing commas in lists. 11 - Adjust style to be consistent and use trailing commas in lists.
16 - Update Vcs-Bzr and Vcs-Browser fields and add notice for uploaders.12 - Update Vcs-Bzr and Vcs-Browser fields and add notice for uploaders.
17 * Automatic snapshot from revision 373 (bootstrap):13 * Automatic snapshot from revision 373 (bootstrap):
1814
=== modified file 'debian/control'
--- debian/control 2012-11-15 17:13:28 +0000
+++ debian/control 2012-11-16 18:58:44 +0000
@@ -7,7 +7,6 @@
7 dh-translations,7 dh-translations,
8 intltool,8 intltool,
9 gnome-common,9 gnome-common,
10 libxorg-gtest-dev,
11 libgtest-dev,10 libgtest-dev,
12 libdbustest1-dev,11 libdbustest1-dev,
13 dbus-test-runner,12 dbus-test-runner,
1413
=== modified file 'debian/rules'
--- debian/rules 2012-11-15 17:08:26 +0000
+++ debian/rules 2012-11-16 18:58:44 +0000
@@ -5,9 +5,6 @@
5%:5%:
6 dh $@ --with translations,autoreconf6 dh $@ --with translations,autoreconf
77
8override_dh_auto_test:
9 # TESTS TEMPORARILY DISABLED: need fixing for gsettings schema.
10
11override_dh_autoreconf:8override_dh_autoreconf:
12 NOCONFIGURE=1 dh_autoreconf ./autogen.sh9 NOCONFIGURE=1 dh_autoreconf ./autogen.sh
1310
1411
=== modified file 'tests/Makefile.am'
--- tests/Makefile.am 2012-08-31 16:59:27 +0000
+++ tests/Makefile.am 2012-11-16 18:58:44 +0000
@@ -1,31 +1,45 @@
1TESTS =1TESTS =
2CLEANFILES =2CLEANFILES =
3BUILT_SOURCES =
4check_PROGRAMS =
5
6###
7###
8###
39
4# stock UMB tests on user-visible strings10# stock UMB tests on user-visible strings
5include $(srcdir)/Makefile.am.strings11include $(srcdir)/Makefile.am.strings
612
7AM_CPPFLAGS = \13check_LIBRARIES = libgtest.a
8 $(GTEST_CPPFLAGS) \14nodist_libgtest_a_SOURCES = \
9 $(XORG_GTEST_CPPFLAGS) \15 $(GTEST_SOURCE)/src/gtest-all.cc \
10 $(INDICATOR_CFLAGS) \16 $(GTEST_SOURCE)/src/gtest_main.cc
11 -I${top_srcdir}/src \17
12 -Wall -Werror18AM_CPPFLAGS = $(GTEST_CPPFLAGS) -I${top_srcdir}/src -Wall -Werror
13AM_CXXFLAGS = $(GTEST_CXXFLAGS)19AM_CXXFLAGS = $(GTEST_CXXFLAGS)
1420
15TESTS = test-service21###
16check_PROGRAMS = test-service22###
17test_service_SOURCES = \23###
18 test-service.cc \24
19 gtest-dbus-helper.h25BUILT_SOURCES += gschemas.compiled
20test_service_LDADD = $(TEST_SERVICE_LIBS) libgtest.a $(XORG_GTEST_MAIN_LIBS) $(X11_LIBS)26CLEANFILES += gschemas.compiled
27gschemas.compiled: Makefile
28 $(AM_V_at) cp -f $(top_builddir)/data/*gschema.xml .
29 $(AM_V_GEN) $(GLIB_COMPILE_SCHEMAS) --targetdir=. .
30
31
32TESTS += test-service
33check_PROGRAMS += test-service
34test_service_SOURCES = test-service.cc
35test_service_LDADD = \
36 $(TEST_SERVICE_LIBS) \
37 libgtest.a
21test_service_CPPFLAGS = \38test_service_CPPFLAGS = \
39 -DSCHEMA_DIR="\"$(top_builddir)/tests/\"" \
40 -DINDICATOR_SERVICE_DIR="\"$(abs_builddir)\"" \
41 -DINDICATOR_SERVICE_PATH="\"$(top_builddir)/src/indicator-session-service\"" \
22 $(TEST_SERVICE_CFLAGS) \42 $(TEST_SERVICE_CFLAGS) \
23 $(AM_CPPFLAGS) \43 $(AM_CPPFLAGS)
24 -DINDICATOR_SERVICE_PATH="\"$(top_builddir)/src/indicator-session-service\""
2544
26check_LIBRARIES = libgtest.a
27nodist_libgtest_a_SOURCES = \
28 $(XORG_GTEST_SOURCE)/src/xorg-gtest-all.cpp \
29 $(GTEST_SOURCE)/src/gtest-all.cc \
30 $(XORG_GTEST_SOURCE)/src/xorg-gtest_main.cpp
3145
3246
=== removed file 'tests/gtest-dbus-helper.h'
--- tests/gtest-dbus-helper.h 2012-08-23 18:00:30 +0000
+++ tests/gtest-dbus-helper.h 1970-01-01 00:00:00 +0000
@@ -1,418 +0,0 @@
1/*
2Copyright 2012 Canonical Ltd.
3
4Authors:
5 Charles Kerr <charles.kerr@canonical.com>
6
7This program is free software: you can redistribute it and/or modify it
8under the terms of the GNU General Public License version 3, as published
9by the Free Software Foundation.
10
11This program is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranties of
13MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14PURPOSE. See the GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License along
17with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef INDICATOR_SERVICE_TEST_H
21#define INDICATOR_SERVICE_TEST_H
22
23#include <algorithm>
24#include <functional>
25#include <string>
26#include <vector>
27
28#include <gio/gio.h>
29#include <gtest/gtest.h>
30#include <libdbustest/dbus-test.h>
31#include <libdbusmenu-glib/client.h>
32
33/***
34****
35***/
36
37/**
38 * Convenience class for looking at a DbusmenuClient's items for testing
39 *
40 * Examples:
41 *
42 * // confirm that there are N menuitems of type T
43 * TEST_EQ (helper.count_type(T), N);
44 *
45 * // confirm that there are N visible menuitems
46 * TEST_EQ (helper.count_property_bool(DBUSMENU_MENUITEM_PROP_VISIBLE,true), N);
47 *
48 * // get a sorted list of all the menuitems of type T
49 * std::vector<DbusmenuMenuitem*> items = helper.find_type(T);
50 */
51class DbusmenuClientHelper
52{
53 public:
54
55 DbusmenuClientHelper (DbusmenuClient * client_): client(client_) {
56 g_object_ref (G_OBJECT(client));
57 }
58 ~DbusmenuClientHelper() {
59 g_object_unref(G_OBJECT(client));
60 client = NULL;
61 }
62
63 private:
64
65 static void foreach_accumulate_func (DbusmenuMenuitem * mi, gpointer gset) {
66 static_cast<std::vector<DbusmenuMenuitem*>*>(gset)->push_back (mi);
67 }
68
69 public:
70
71 std::vector<DbusmenuMenuitem*>
72 get_all_menuitems () const
73 {
74 std::vector<DbusmenuMenuitem*> items;
75
76 DbusmenuMenuitem * root = dbusmenu_client_get_root (client);
77 if (root != NULL)
78 dbusmenu_menuitem_foreach (root, foreach_accumulate_func, &items);
79
80 return items;
81 }
82
83 private:
84
85 template<typename value_type> class PropertyPredicate:
86 public std::unary_function<DbusmenuMenuitem*,bool> {
87 protected:
88 const std::string _key;
89 const value_type _value;
90 virtual value_type get_value(DbusmenuMenuitem * mi) const = 0;
91 public:
92 PropertyPredicate (const char * propertyName, value_type propertyValue):
93 _key(propertyName), _value(propertyValue) { }
94 bool operator()(const DbusmenuMenuitem* cmi) const {
95 // FIXME: remove const_cast after the dbusmenu_menuitem_propperty_get*() functions are constified
96 DbusmenuMenuitem * mi = const_cast<DbusmenuMenuitem*>(cmi);
97 return dbusmenu_menuitem_property_exist (mi, _key.c_str()) && (_value == get_value(mi));
98 }
99 };
100
101 class StringPropertyPredicate: public PropertyPredicate<std::string> {
102 protected:
103 virtual std::string get_value (DbusmenuMenuitem * mi) const {
104 return dbusmenu_menuitem_property_get(mi, _key.c_str());
105 }
106 public:
107 StringPropertyPredicate (const char * propName, const char * propValue):
108 PropertyPredicate (propName, propValue) {}
109 };
110
111 class IntPropertyPredicate: public PropertyPredicate<int> {
112 protected:
113 virtual int get_value (DbusmenuMenuitem * mi) const {
114 return dbusmenu_menuitem_property_get_int(mi, _key.c_str());
115 }
116 public:
117 IntPropertyPredicate (const char * propName, int propValue):
118 PropertyPredicate (propName, propValue) {}
119 };
120
121 class BoolPropertyPredicate: public PropertyPredicate<bool> {
122 protected:
123 virtual bool get_value (DbusmenuMenuitem * mi) const {
124 return dbusmenu_menuitem_property_get_bool(mi, _key.c_str());
125 }
126 public:
127 BoolPropertyPredicate (const char * propName, bool propValue):
128 PropertyPredicate (propName, propValue) {}
129 };
130
131 public:
132
133 typedef std::vector<DbusmenuMenuitem*> menuitems_t;
134
135 void
136 match_property (menuitems_t& items, const char * key, const char * value) const
137 {
138 const StringPropertyPredicate pred (key, value);
139 items.erase (std::remove_if (items.begin(), items.end(), std::not1(pred)), items.end());
140 }
141
142 void
143 match_property_int (menuitems_t& items, const char * key, int value) const
144 {
145 const IntPropertyPredicate pred (key, value);
146 items.erase (std::remove_if (items.begin(), items.end(), std::not1(pred)), items.end());
147 }
148
149 void
150 match_property_bool (menuitems_t& items, const char * key, bool value) const
151 {
152 const BoolPropertyPredicate pred (key, value);
153 items.erase (std::remove_if (items.begin(), items.end(), std::not1(pred)), items.end());
154 }
155
156 menuitems_t find_property (const char * prop_name, const char * prop_value) const
157 {
158 menuitems_t items;
159 g_return_val_if_fail (prop_name!=NULL, items);
160 g_return_val_if_fail (prop_value!=NULL, items);
161
162 items = get_all_menuitems ();
163 match_property (items, prop_name, prop_value);
164 return items;
165 }
166
167 menuitems_t find_property_int (const char * prop_name, int prop_value) const
168 {
169 std::vector<DbusmenuMenuitem*> items;
170 g_return_val_if_fail (prop_name!=NULL, items);
171
172 items = get_all_menuitems ();
173 match_property_int (items, prop_name, prop_value);
174 return items;
175 }
176
177 menuitems_t find_property_bool (const char * prop_name, bool prop_value) const
178 {
179 std::vector<DbusmenuMenuitem*> items;
180 g_return_val_if_fail (prop_name!=NULL, items);
181
182 items = get_all_menuitems ();
183 match_property_bool (items, prop_name, prop_value);
184 return items;
185 }
186
187 menuitems_t find_type (const char * type) const
188 {
189 return find_property (DBUSMENU_MENUITEM_PROP_TYPE, type);
190 }
191
192 int count_property (const char * propName, const char * propValue) const
193 {
194 return find_property (propName, propValue).size();
195 }
196
197 int count_type (const char * type) const
198 {
199 return count_property (DBUSMENU_MENUITEM_PROP_TYPE, type);
200 }
201
202 int count_property_int (const char * propName, int propValue) const
203 {
204 return find_property_int (propName, propValue).size();
205 }
206
207 int count_property_bool (const char * propName, bool propValue) const
208 {
209 return find_property_bool (propName, propValue).size();
210 }
211
212 private:
213
214 DbusmenuClient * client;
215};
216
217/**
218 * Fixture class for using Google Test on an indicator-service's
219 * com.canonical.dbusmenu interface.
220 *
221 * The SetUp() function starts the service up, waits for it to
222 * be visible on the bus, then creates a DbusmenuClient and waits
223 * for its layout-changed signal. This way the test function
224 * is reached after the menu is available and populated.
225 *
226 * TearDown() cleans up the DBus scaffolding and stops the service.
227 */
228class IndicatorServiceTest : public ::testing::Test
229{
230 public:
231
232 IndicatorServiceTest(const char * service_name_,
233 const char * menu_object_path_,
234 const char * executable_):
235 menu_client(0),
236 menu_helper(0),
237 test_service(0),
238 indicator_service_proxy(0),
239 handler_id(0),
240 executable(executable_),
241 service_name(service_name_),
242 menu_object_path(menu_object_path_)
243 {
244 // glib one-time init stuff
245 g_type_init();
246 g_assert (g_thread_supported());
247 mainloop = g_main_loop_new (NULL, FALSE);
248 }
249
250 private:
251
252 static void
253 on_layout_updated_static (DbusmenuClient * client, IndicatorServiceTest * self)
254 {
255 g_debug ("LAYOUT UPDATED");
256 self->on_layout_updated (client);
257 }
258 void
259 on_layout_updated (DbusmenuClient * client)
260 {
261 ASSERT_EQ (client, menu_client);
262 ASSERT_NE (handler_id, 0);
263 ASSERT_TRUE (g_signal_handler_is_connected (client, handler_id));
264
265 // stop listening for this event
266 g_signal_handler_disconnect (client, handler_id);
267 handler_id = 0;
268
269 ready();
270 }
271
272 private:
273
274 static gboolean
275 on_timeout_static (gpointer self)
276 {
277 static_cast<IndicatorServiceTest*>(self)->on_timeout();
278 return false;
279 }
280 void
281 on_timeout()
282 {
283 ASSERT_NE (handler_id, 0ul);
284 g_source_remove (handler_id);
285 handler_id = 0;
286 ready();
287 }
288
289 protected:
290
291 virtual void
292 SetUp()
293 {
294 ASSERT_EQ (NULL, test_service);
295 ASSERT_EQ (NULL, menu_helper);
296 ASSERT_EQ (NULL, indicator_service_proxy);
297
298 test_service = dbus_test_service_new (NULL);
299
300 // Start the executable and wait until it shows up on the bus.
301 // Unset the NO_WATCHERS env var to ensure that the service
302 // will shut down when there are no watchers... otherwise
303 // this task will never finish
304 g_unsetenv("INDICATOR_ALLOW_NO_WATCHERS");
305 DbusTestProcess * indicator_service_task = dbus_test_process_new (executable.c_str());
306 dbus_test_service_add_task (test_service, DBUS_TEST_TASK(indicator_service_task));
307 g_object_unref (G_OBJECT(indicator_service_task));
308
309 // create a menu task that waits for our service before it runs
310 DbusTestTask * wait_task = dbus_test_task_new ();
311 dbus_test_task_set_wait_for (wait_task, service_name.c_str());
312 dbus_test_service_add_task (test_service, wait_task);
313 g_object_unref (G_OBJECT(wait_task));
314
315 g_debug ("starting tasks");
316 dbus_test_service_start_tasks(test_service);
317
318 // at this point the indicator service is running, let's Watch it
319 // to ensure it stays alive for the duration of the test
320 GError * error = NULL;
321 GDBusConnection * bus_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
322 indicator_service_proxy = g_dbus_proxy_new_sync (bus_connection,
323 G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
324 NULL,
325 service_name.c_str(),
326 "/org/ayatana/indicator/service",
327 "org.ayatana.indicator.service",
328 NULL,
329 &error);
330 GVariant * result = g_dbus_proxy_call_sync (indicator_service_proxy, "Watch",
331 NULL, G_DBUS_CALL_FLAGS_NO_AUTO_START,
332 -1, NULL, &error);
333 guint a, b;
334 g_variant_get (result, "(uu)", &a, &b);
335 g_debug ("Sending 'Watch' to proxy %p yielded %u %u", indicator_service_proxy, a, b);
336 g_variant_unref (result);
337 EXPECT_EQ(NULL, error);
338 if (error != NULL) {
339 g_message ("%s Unable to Watch indicator-service : %s", G_STRFUNC, error->message);
340 g_clear_error (&error);
341 }
342 g_object_unref (G_OBJECT(bus_connection));
343
344 menu_client = dbusmenu_client_new (service_name.c_str(), menu_object_path.c_str());
345 menu_helper = new DbusmenuClientHelper (menu_client);
346
347 // wait for a "layout-updated" signal before we let SetUp finish
348 wait_for_layout_update();
349 }
350
351 virtual void
352 TearDown()
353 {
354 ASSERT_EQ (handler_id, 0);
355
356 // tear down the mainloop
357 ASSERT_TRUE (mainloop != NULL);
358 g_main_loop_unref (mainloop);
359 mainloop = NULL;
360
361 // tear down the menu client
362 if (menu_helper != NULL) {
363 delete menu_helper;
364 menu_helper = NULL;
365 }
366 if (menu_client != NULL) {
367 g_object_unref(G_OBJECT(menu_client));
368 menu_client = NULL;
369 }
370
371 // tear down the indicator proxy
372 EXPECT_TRUE (G_IS_DBUS_PROXY(indicator_service_proxy));
373 g_object_unref (G_OBJECT(indicator_service_proxy));
374 indicator_service_proxy = NULL;
375 }
376
377 void wait_for_layout_update()
378 {
379 ASSERT_EQ (handler_id, 0ul);
380 handler_id = g_signal_connect (menu_client,
381 DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED,
382 G_CALLBACK(on_layout_updated_static),
383 this);
384 g_debug ("waiting for layout update...");
385 g_main_loop_run (mainloop);
386 }
387
388 void wait_seconds (int seconds)
389 {
390 ASSERT_EQ (handler_id, 0ul);
391 handler_id = g_timeout_add_seconds (seconds, on_timeout_static, this);
392 g_debug ("waiting %d seconds...", seconds);
393 g_main_loop_run (mainloop);
394 }
395
396 protected:
397
398 DbusmenuClient * menu_client;
399 DbusmenuClientHelper * menu_helper;
400
401 private:
402
403 void ready()
404 {
405 g_debug("done waiting");
406 g_main_loop_quit (mainloop);
407 }
408
409 GMainLoop * mainloop;
410 DbusTestService * test_service;
411 GDBusProxy * indicator_service_proxy;
412 gulong handler_id;
413 const std::string executable;
414 const std::string service_name;
415 const std::string menu_object_path;
416};
417
418#endif // #ifndef INDICATOR_SERVICE_TEST_H
4190
=== added file 'tests/indicator-session.service.in'
--- tests/indicator-session.service.in 1970-01-01 00:00:00 +0000
+++ tests/indicator-session.service.in 2012-11-16 18:58:44 +0000
@@ -0,0 +1,3 @@
1[D-BUS Service]
2Name=com.canonical.indicator.session
3Exec=@abs_top_builddir@/src/indicator-session-service
04
=== added file 'tests/org.gnome.desktop.lockdown.gschema.xml'
--- tests/org.gnome.desktop.lockdown.gschema.xml 1970-01-01 00:00:00 +0000
+++ tests/org.gnome.desktop.lockdown.gschema.xml 2012-11-16 18:58:44 +0000
@@ -0,0 +1,45 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<schemalist gettext-domain="gsettings-desktop-schemas">
3 <schema path="/org/gnome/desktop/lockdown/" id="org.gnome.desktop.lockdown">
4 <key type="b" name="disable-command-line">
5 <default>false</default>
6 <summary>Disable command line</summary>
7 <description>Prevent the user from accessing the terminal or specifying a command line to be executed. For example, this would disable access to the panel's "Run Application" dialog.</description>
8 </key>
9 <key type="b" name="disable-save-to-disk">
10 <default>false</default>
11 <summary>Disable saving files to disk</summary>
12 <description>Prevent the user from saving files to disk. For example, this would disable access to all applications' "Save as" dialogs.</description>
13 </key>
14 <key type="b" name="disable-printing">
15 <default>false</default>
16 <summary>Disable printing</summary>
17 <description>Prevent the user from printing. For example, this would disable access to all applications' "Print" dialogs.</description>
18 </key>
19 <key type="b" name="disable-print-setup">
20 <default>false</default>
21 <summary>Disable print setup</summary>
22 <description>Prevent the user from modifying print settings. For example, this would disable access to all applications' "Print Setup" dialogs.</description>
23 </key>
24 <key type="b" name="disable-user-switching">
25 <default>false</default>
26 <summary>Disable user switching</summary>
27 <description>Prevent the user from switching to another account while his session is active.</description>
28 </key>
29 <key type="b" name="disable-lock-screen">
30 <default>false</default>
31 <summary>Disable lock screen</summary>
32 <description>Prevent the user to lock his screen.</description>
33 </key>
34 <key type="b" name="disable-application-handlers">
35 <default>false</default>
36 <summary>Disable URL and MIME type handlers</summary>
37 <description>Prevent running any URL or MIME type handler applications.</description>
38 </key>
39 <key type="b" name="disable-log-out">
40 <default>false</default>
41 <summary>Disable log out</summary>
42 <description>Prevent the user from logging out.</description>
43 </key>
44 </schema>
45</schemalist>
0\ No newline at end of file46\ No newline at end of file
147
=== added file 'tests/org.gnome.settings-daemon.plugins.media-keys.gschema.xml'
--- tests/org.gnome.settings-daemon.plugins.media-keys.gschema.xml 1970-01-01 00:00:00 +0000
+++ tests/org.gnome.settings-daemon.plugins.media-keys.gschema.xml 2012-11-16 18:58:44 +0000
@@ -0,0 +1,203 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<schemalist>
3 <schema path="/org/gnome/settings-daemon/plugins/media-keys/" id="org.gnome.settings-daemon.plugins.media-keys" gettext-domain="gnome-settings-daemon">
4 <key type="b" name="active">
5 <default>true</default>
6 <summary>Activation of this plugin</summary>
7 <description>Whether this plugin would be activated by gnome-settings-daemon or not</description>
8 </key>
9 <key type="as" name="custom-keybindings">
10 <default>[]</default>
11 <summary>Custom keybindings</summary>
12 <description>List of custom keybindings</description>
13 </key>
14 <key type="s" name="calculator">
15 <default>'XF86Calculator'</default>
16 <summary>Launch calculator</summary>
17 <description>Binding to launch the calculator.</description>
18 </key>
19 <key type="s" name="email">
20 <default>'XF86Mail'</default>
21 <summary>Launch email client</summary>
22 <description>Binding to launch the email client.</description>
23 </key>
24 <key type="s" name="eject">
25 <default>'XF86Eject'</default>
26 <summary>Eject</summary>
27 <description>Binding to eject an optical disc.</description>
28 </key>
29 <key type="s" name="help">
30 <default>''</default>
31 <summary>Launch help browser</summary>
32 <description>Binding to launch the help browser.</description>
33 </key>
34 <key type="s" name="home">
35 <default>'XF86Explorer'</default>
36 <summary>Home folder</summary>
37 <description>Binding to open the Home folder.</description>
38 </key>
39 <key type="s" name="media">
40 <default>'XF86AudioMedia'</default>
41 <summary>Launch media player</summary>
42 <description>Binding to launch the media player.</description>
43 </key>
44 <key type="s" name="next">
45 <default>'XF86AudioNext'</default>
46 <summary>Next track</summary>
47 <description>Binding to skip to next track.</description>
48 </key>
49 <key type="s" name="pause">
50 <default>'XF86AudioPause'</default>
51 <summary>Pause playback</summary>
52 <description>Binding to pause playback.</description>
53 </key>
54 <key type="s" name="play">
55 <default>'XF86AudioPlay'</default>
56 <summary>Play (or play/pause)</summary>
57 <description>Binding to start playback (or toggle play/pause).</description>
58 </key>
59 <key type="s" name="logout">
60 <default>'&lt;Control&gt;&lt;Alt&gt;Delete'</default>
61 <summary>Log out</summary>
62 <description>Binding to log out.</description>
63 </key>
64 <key type="s" name="previous">
65 <default>'XF86AudioPrev'</default>
66 <summary>Previous track</summary>
67 <description>Binding to skip to previous track.</description>
68 </key>
69 <key type="i" name="priority">
70 <default>98</default>
71 <summary>Priority to use for this plugin</summary>
72 <description>Priority to use for this plugin in gnome-settings-daemon startup queue</description>
73 </key>
74 <key type="s" name="screensaver">
75 <default>'&lt;Control&gt;&lt;Alt&gt;l'</default>
76 <summary>Lock screen</summary>
77 <description>Binding to lock the screen.</description>
78 </key>
79 <key type="s" name="search">
80 <default>'XF86Search'</default>
81 <summary>Search</summary>
82 <description>Binding to launch the search tool.</description>
83 </key>
84 <key type="s" name="stop">
85 <default>'XF86AudioStop'</default>
86 <summary>Stop playback</summary>
87 <description>Binding to stop playback.</description>
88 </key>
89 <key type="s" name="volume-down">
90 <default>'XF86AudioLowerVolume'</default>
91 <summary>Volume down</summary>
92 <description>Binding to lower the system volume.</description>
93 </key>
94 <key type="s" name="volume-mute">
95 <default>'XF86AudioMute'</default>
96 <summary>Volume mute</summary>
97 <description>Binding to mute the system volume.</description>
98 </key>
99 <key type="s" name="volume-up">
100 <default>'XF86AudioRaiseVolume'</default>
101 <summary>Volume up</summary>
102 <description>Binding to raise the system volume.</description>
103 </key>
104 <key type="s" name="screenshot">
105 <default>'Print'</default>
106 <summary>Take a screenshot</summary>
107 <description>Binding to take a screenshot.</description>
108 </key>
109 <key type="s" name="window-screenshot">
110 <default>'&lt;Alt&gt;Print'</default>
111 <summary>Take a screenshot of a window</summary>
112 <description>Binding to take a screenshot of a window.</description>
113 </key>
114 <key type="s" name="area-screenshot">
115 <default>'&lt;Shift&gt;Print'</default>
116 <summary>Take a screenshot of an area</summary>
117 <description>Binding to take a screenshot of an area.</description>
118 </key>
119 <key type="s" name="screenshot-clip">
120 <default>'&lt;Ctrl&gt;Print'</default>
121 <summary>Copy a screenshot to clipboard</summary>
122 <description>Binding to copy a screenshot to clipboard.</description>
123 </key>
124 <key type="s" name="window-screenshot-clip">
125 <default>'&lt;Ctrl&gt;&lt;Alt&gt;Print'</default>
126 <summary>Copy a screenshot of a window to clipboard</summary>
127 <description>Binding to copy a screenshot of a window to clipboard.</description>
128 </key>
129 <key type="s" name="area-screenshot-clip">
130 <default>'&lt;Ctrl&gt;&lt;Shift&gt;Print'</default>
131 <summary>Copy a screenshot of an area to clipboard</summary>
132 <description>Binding to copy a screenshot of an area to clipboard.</description>
133 </key>
134 <key type="s" name="terminal">
135 <default>'&lt;Primary&gt;&lt;Alt&gt;t'</default>
136 <summary>Launch terminal</summary>
137 <description>Binding to launch the terminal.</description>
138 </key>
139 <key type="s" name="www">
140 <default>'XF86WWW'</default>
141 <summary>Launch web browser</summary>
142 <description>Binding to launch the web browser.</description>
143 </key>
144 <key type="s" name="magnifier">
145 <default>''</default>
146 <summary>Toggle magnifier</summary>
147 <description>Binding to show the screen magnifier</description>
148 </key>
149 <key type="s" name="screenreader">
150 <default>''</default>
151 <summary>Toggle screen reader</summary>
152 <description>Binding to start the screen reader</description>
153 </key>
154 <key type="s" name="on-screen-keyboard">
155 <default>''</default>
156 <summary>Toggle on-screen keyboard</summary>
157 <description>Binding to show the on-screen keyboard</description>
158 </key>
159 <key type="s" name="increase-text-size">
160 <default>''</default>
161 <summary>Increase text size</summary>
162 <description>Binding to increase the text size</description>
163 </key>
164 <key type="s" name="decrease-text-size">
165 <default>''</default>
166 <summary>Decrease text size</summary>
167 <description>Binding to decrease the text size</description>
168 </key>
169 <key type="s" name="toggle-contrast">
170 <default>''</default>
171 <summary>Toggle contrast</summary>
172 <description>Binding to toggle the interface contrast</description>
173 </key>
174 <key type="s" name="magnifier-zoom-in">
175 <default>''</default>
176 <summary>Magnifier zoom in</summary>
177 <description>Binding for the magnifier to zoom in</description>
178 </key>
179 <key type="s" name="magnifier-zoom-out">
180 <default>''</default>
181 <summary>Magnifier zoom out</summary>
182 <description>Binding for the magnifier to zoom out</description>
183 </key>
184 </schema>
185
186 <schema id="org.gnome.settings-daemon.plugins.media-keys.custom-keybinding" gettext-domain="gnome-settings-daemon">
187 <key type="s" name="name">
188 <default>''</default>
189 <summary>Name</summary>
190 <description>Name of the custom binding</description>
191 </key>
192 <key type="s" name="binding">
193 <default>''</default>
194 <summary>Binding</summary>
195 <description>Binding for the custom binding</description>
196 </key>
197 <key type="s" name="command">
198 <default>''</default>
199 <summary>Command</summary>
200 <description>Command to run when the binding is invoked</description>
201 </key>
202 </schema>
203</schemalist>
0\ No newline at end of file204\ No newline at end of file
1205
=== modified file 'tests/test-service.cc'
--- tests/test-service.cc 2012-08-23 18:00:30 +0000
+++ tests/test-service.cc 2012-11-16 18:58:44 +0000
@@ -17,39 +17,130 @@
17with this program. If not, see <http://www.gnu.org/licenses/>.17with this program. If not, see <http://www.gnu.org/licenses/>.
18*/18*/
1919
20#include "gtest-dbus-helper.h"20#include <glib-object.h>
21#include <gio/gio.h>
22#include <glib.h>
23
24#include <gtest/gtest.h>
25
21#include "shared-names.h"26#include "shared-names.h"
2227
23/***28/***
24****29****
25***/30***/
2631
27/**32#define INDICATOR_SERVICE_OBJECT_PATH "/org/ayatana/indicator/service"
28 * Fixture class for testing indicator-session-service with Google Test.33#define INDICATOR_SERVICE_INTERFACE_NAME "org.ayatana.indicator.service"
29 */34
30class SessionServiceTest: public IndicatorServiceTest35class ClientTest : public ::testing::Test
31{36{
32 public:37 protected:
33 virtual ~SessionServiceTest() {}38
34 SessionServiceTest(): IndicatorServiceTest(INDICATOR_SESSION_DBUS_NAME,39 GTestDBus * test_dbus;
35 INDICATOR_SESSION_DBUS_OBJECT,40 GDBusConnection * session_bus;
36 INDICATOR_SERVICE_PATH) { }41 GMainLoop * main_loop;
37 public:42
38 virtual void SetUp() {43 virtual void SetUp()
39 wait_seconds(1);44 {
40 IndicatorServiceTest::SetUp();45 test_dbus = NULL;
46 session_bus = NULL;
47 main_loop = NULL;
48
49 static bool first_run = true;
50 if (first_run)
51 {
52 g_type_init();
53 g_setenv ("INDICATOR_SERVICE_SHUTDOWN_TIMEOUT", "1000", TRUE);
54 g_unsetenv ("INDICATOR_ALLOW_NO_WATCHERS");
55 g_unsetenv ("INDICATOR_SERVICE_REPLACE_MODE");
56 g_setenv ("GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, TRUE);
57 g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
58 first_run = false;
59 }
60
61 main_loop = g_main_loop_new (NULL, FALSE);
62 // pull up a test dbus that's pointed at our test .service file
63 test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
64 g_debug (G_STRLOC" service dir path is \"%s\"", INDICATOR_SERVICE_DIR);
65 g_test_dbus_add_service_dir (test_dbus, INDICATOR_SERVICE_DIR);
66
67 // allow the service to exist w/o a sync indicator
68 g_setenv ("INDICATOR_ALLOW_NO_WATCHERS", "1", TRUE);
69
70 g_test_dbus_up (test_dbus);
71 g_debug (G_STRLOC" this test bus' address is \"%s\"", g_test_dbus_get_bus_address(test_dbus));
72 session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
73 g_debug (G_STRLOC" the dbus connection %p unique name is \"%s\"", session_bus, g_dbus_connection_get_unique_name(session_bus));
74 g_debug (G_STRLOC" the dbus connection %p refcount is %d", session_bus, G_OBJECT(session_bus)->ref_count);
41 }75 }
42 virtual void TearDown() {76
43 IndicatorServiceTest::TearDown();77 // undo SetUp
78 virtual void TearDown()
79 {
80 g_clear_object (&session_bus);
81 g_debug (G_STRLOC" tearing down the bus");
82 g_test_dbus_down (test_dbus);
83 g_clear_object (&test_dbus);
84 g_clear_pointer (&main_loop, g_main_loop_unref);
44 }85 }
45};86};
4687
88/***
89****
90***/
4791
48/**92/**
49 * Basic sanity test to see if we can account for all our menuitems.93 * This is a basic test to see if we can launch indicator-session-service
94 * and call its "GetUserRealName" method. The test succeeds if we can launch
95 * the service, call the method, and get response that equals g_get_real_name().
96 *
97 * (You may be wondering why GetUserRealName() exists at all, instead of clients
98 * using g_get_real_name(). It's because the former updates itslef when the user
99 * edits his real name, while the latter returns its cached copy of the old name.)
50 */100 */
51TEST_F(SessionServiceTest, HelloWorld)101TEST_F (ClientTest, TestCanStartService)
52{102{
53 ASSERT_TRUE(true);103 GError * error;
104 GVariant * result;
105 const gchar * name;
106
107 // call GetUserRealName(), which as a side effect should activate
108 // indicator-session-service via the .service file in the tests/ directory
109 error = NULL;
110 result = g_dbus_connection_call_sync (session_bus,
111 INDICATOR_SESSION_DBUS_NAME,
112 INDICATOR_SESSION_SERVICE_DBUS_OBJECT,
113 INDICATOR_SESSION_SERVICE_DBUS_IFACE,
114 "GetUserRealName",
115 NULL,
116 G_VARIANT_TYPE("(s)"),
117 G_DBUS_CALL_FLAGS_NONE,
118 -1,
119 NULL,
120 &error);
121
122 EXPECT_TRUE (error == NULL);
123 ASSERT_TRUE (result != NULL);
124
125 if (error != NULL)
126 {
127 g_warning ("GetUserRealName failed: %s", error->message);
128 g_clear_error (&error);
129 }
130
131 name = NULL;
132 g_variant_get (result, "(&s)", &name);
133 ASSERT_STREQ (g_get_real_name(), name);
134 g_clear_pointer (&result, g_variant_unref);
135
136 // call IndicatorService's Shutdown() method for a clean exit
137 result = g_dbus_connection_call_sync (session_bus,
138 INDICATOR_SESSION_DBUS_NAME,
139 "/org/ayatana/indicator/service",
140 "org.ayatana.indicator.service",
141 "Shutdown", NULL,
142 NULL,
143 G_DBUS_CALL_FLAGS_NONE,
144 -1, NULL, NULL);
145 g_clear_pointer (&result, g_variant_unref);
54}146}
55

Subscribers

People subscribed via source and target branches