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
1=== modified file 'configure.ac'
2--- configure.ac 2012-11-14 20:20:13 +0000
3+++ configure.ac 2012-11-16 18:58:44 +0000
4@@ -25,6 +25,7 @@
5 # Dependencies
6 ###########################
7
8+GIO_REQUIRED_VERSION=2.33
9 GLIB_REQUIRED_VERSION=2.33
10 GTK_REQUIRED_VERSION=3.0
11 INDICATOR_REQUIRED_VERSION=0.3.19
12@@ -135,16 +136,15 @@
13 AC_MSG_ERROR([tests were requested but gtest is not installed.])
14 fi
15 if test "x$enable_tests" = "xyes"; then
16- PKG_CHECK_MODULES([TEST_SERVICE],[indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION
17- dbustest-1 >= $DBUSTEST_REQUIRED_VERSION
18- dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION],
19- [enable_tests="yes"],
20- [enable_tests="no"])
21+ PKG_CHECK_MODULES([TEST_SERVICE],[glib-2.0 >= $GLIB_REQUIRED_VERSION
22+ gio-2.0 >= $GIO_REQUIRED_VERSION],
23+ [enable_tests="yes"],
24+ [enable_tests="no"])
25 fi
26 fi
27 AM_CONDITIONAL([BUILD_TESTS],[test "x$enable_tests" = "xyes"])
28 AC_SUBST([TEST_SERVICE_CFLAGS])
29-AC_SUBST([TEST_SERVICE_LDFLAGS])
30+AC_SUBST([TEST_SERVICE_LIBS])
31
32 ##############################
33 # Custom Junk
34@@ -211,6 +211,7 @@
35 data/icons/scalable/status/Makefile
36 data/extra-sessions/Makefile
37 tests/Makefile
38+tests/indicator-session.service
39 po/Makefile.in
40 ])
41
42
43=== modified file 'debian/changelog'
44--- debian/changelog 2012-11-16 03:42:55 +0000
45+++ debian/changelog 2012-11-16 18:58:44 +0000
46@@ -4,14 +4,10 @@
47 - Add DPKG_GENSYMBOLS_CHECK_LEVEL=4.
48 - Use the dh sequencer with autoreconf.
49 - Override dh_autoreconf to run autogen.sh.
50- - Temporarily disable running tests due to an issue with getting the
51- gsettings schema for testing.
52 * debian/control:
53 - Add dh-autoreconf to Build-Depends.
54 - Add gnome-common to Build-Depends.
55- - Add libdbustest1-dev, dbus-test-runner to Build-Depends.
56- - Explicitly list libgtest-dev in Build-Depends, even though it does get
57- pulled in via libxorg-gtest-dev.
58+ - Add libgtest-dev, libdbustest1-dev, dbus-test-runner to Build-Depends.
59 - Adjust style to be consistent and use trailing commas in lists.
60 - Update Vcs-Bzr and Vcs-Browser fields and add notice for uploaders.
61 * Automatic snapshot from revision 373 (bootstrap):
62
63=== modified file 'debian/control'
64--- debian/control 2012-11-15 17:13:28 +0000
65+++ debian/control 2012-11-16 18:58:44 +0000
66@@ -7,7 +7,6 @@
67 dh-translations,
68 intltool,
69 gnome-common,
70- libxorg-gtest-dev,
71 libgtest-dev,
72 libdbustest1-dev,
73 dbus-test-runner,
74
75=== modified file 'debian/rules'
76--- debian/rules 2012-11-15 17:08:26 +0000
77+++ debian/rules 2012-11-16 18:58:44 +0000
78@@ -5,9 +5,6 @@
79 %:
80 dh $@ --with translations,autoreconf
81
82-override_dh_auto_test:
83- # TESTS TEMPORARILY DISABLED: need fixing for gsettings schema.
84-
85 override_dh_autoreconf:
86 NOCONFIGURE=1 dh_autoreconf ./autogen.sh
87
88
89=== modified file 'tests/Makefile.am'
90--- tests/Makefile.am 2012-08-31 16:59:27 +0000
91+++ tests/Makefile.am 2012-11-16 18:58:44 +0000
92@@ -1,31 +1,45 @@
93 TESTS =
94 CLEANFILES =
95+BUILT_SOURCES =
96+check_PROGRAMS =
97+
98+###
99+###
100+###
101
102 # stock UMB tests on user-visible strings
103 include $(srcdir)/Makefile.am.strings
104
105-AM_CPPFLAGS = \
106- $(GTEST_CPPFLAGS) \
107- $(XORG_GTEST_CPPFLAGS) \
108- $(INDICATOR_CFLAGS) \
109- -I${top_srcdir}/src \
110- -Wall -Werror
111+check_LIBRARIES = libgtest.a
112+nodist_libgtest_a_SOURCES = \
113+ $(GTEST_SOURCE)/src/gtest-all.cc \
114+ $(GTEST_SOURCE)/src/gtest_main.cc
115+
116+AM_CPPFLAGS = $(GTEST_CPPFLAGS) -I${top_srcdir}/src -Wall -Werror
117 AM_CXXFLAGS = $(GTEST_CXXFLAGS)
118
119-TESTS = test-service
120-check_PROGRAMS = test-service
121-test_service_SOURCES = \
122- test-service.cc \
123- gtest-dbus-helper.h
124-test_service_LDADD = $(TEST_SERVICE_LIBS) libgtest.a $(XORG_GTEST_MAIN_LIBS) $(X11_LIBS)
125+###
126+###
127+###
128+
129+BUILT_SOURCES += gschemas.compiled
130+CLEANFILES += gschemas.compiled
131+gschemas.compiled: Makefile
132+ $(AM_V_at) cp -f $(top_builddir)/data/*gschema.xml .
133+ $(AM_V_GEN) $(GLIB_COMPILE_SCHEMAS) --targetdir=. .
134+
135+
136+TESTS += test-service
137+check_PROGRAMS += test-service
138+test_service_SOURCES = test-service.cc
139+test_service_LDADD = \
140+ $(TEST_SERVICE_LIBS) \
141+ libgtest.a
142 test_service_CPPFLAGS = \
143+ -DSCHEMA_DIR="\"$(top_builddir)/tests/\"" \
144+ -DINDICATOR_SERVICE_DIR="\"$(abs_builddir)\"" \
145+ -DINDICATOR_SERVICE_PATH="\"$(top_builddir)/src/indicator-session-service\"" \
146 $(TEST_SERVICE_CFLAGS) \
147- $(AM_CPPFLAGS) \
148- -DINDICATOR_SERVICE_PATH="\"$(top_builddir)/src/indicator-session-service\""
149+ $(AM_CPPFLAGS)
150
151-check_LIBRARIES = libgtest.a
152-nodist_libgtest_a_SOURCES = \
153- $(XORG_GTEST_SOURCE)/src/xorg-gtest-all.cpp \
154- $(GTEST_SOURCE)/src/gtest-all.cc \
155- $(XORG_GTEST_SOURCE)/src/xorg-gtest_main.cpp
156
157
158=== removed file 'tests/gtest-dbus-helper.h'
159--- tests/gtest-dbus-helper.h 2012-08-23 18:00:30 +0000
160+++ tests/gtest-dbus-helper.h 1970-01-01 00:00:00 +0000
161@@ -1,418 +0,0 @@
162-/*
163-Copyright 2012 Canonical Ltd.
164-
165-Authors:
166- Charles Kerr <charles.kerr@canonical.com>
167-
168-This program is free software: you can redistribute it and/or modify it
169-under the terms of the GNU General Public License version 3, as published
170-by the Free Software Foundation.
171-
172-This program is distributed in the hope that it will be useful, but
173-WITHOUT ANY WARRANTY; without even the implied warranties of
174-MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
175-PURPOSE. See the GNU General Public License for more details.
176-
177-You should have received a copy of the GNU General Public License along
178-with this program. If not, see <http://www.gnu.org/licenses/>.
179-*/
180-
181-#ifndef INDICATOR_SERVICE_TEST_H
182-#define INDICATOR_SERVICE_TEST_H
183-
184-#include <algorithm>
185-#include <functional>
186-#include <string>
187-#include <vector>
188-
189-#include <gio/gio.h>
190-#include <gtest/gtest.h>
191-#include <libdbustest/dbus-test.h>
192-#include <libdbusmenu-glib/client.h>
193-
194-/***
195-****
196-***/
197-
198-/**
199- * Convenience class for looking at a DbusmenuClient's items for testing
200- *
201- * Examples:
202- *
203- * // confirm that there are N menuitems of type T
204- * TEST_EQ (helper.count_type(T), N);
205- *
206- * // confirm that there are N visible menuitems
207- * TEST_EQ (helper.count_property_bool(DBUSMENU_MENUITEM_PROP_VISIBLE,true), N);
208- *
209- * // get a sorted list of all the menuitems of type T
210- * std::vector<DbusmenuMenuitem*> items = helper.find_type(T);
211- */
212-class DbusmenuClientHelper
213-{
214- public:
215-
216- DbusmenuClientHelper (DbusmenuClient * client_): client(client_) {
217- g_object_ref (G_OBJECT(client));
218- }
219- ~DbusmenuClientHelper() {
220- g_object_unref(G_OBJECT(client));
221- client = NULL;
222- }
223-
224- private:
225-
226- static void foreach_accumulate_func (DbusmenuMenuitem * mi, gpointer gset) {
227- static_cast<std::vector<DbusmenuMenuitem*>*>(gset)->push_back (mi);
228- }
229-
230- public:
231-
232- std::vector<DbusmenuMenuitem*>
233- get_all_menuitems () const
234- {
235- std::vector<DbusmenuMenuitem*> items;
236-
237- DbusmenuMenuitem * root = dbusmenu_client_get_root (client);
238- if (root != NULL)
239- dbusmenu_menuitem_foreach (root, foreach_accumulate_func, &items);
240-
241- return items;
242- }
243-
244- private:
245-
246- template<typename value_type> class PropertyPredicate:
247- public std::unary_function<DbusmenuMenuitem*,bool> {
248- protected:
249- const std::string _key;
250- const value_type _value;
251- virtual value_type get_value(DbusmenuMenuitem * mi) const = 0;
252- public:
253- PropertyPredicate (const char * propertyName, value_type propertyValue):
254- _key(propertyName), _value(propertyValue) { }
255- bool operator()(const DbusmenuMenuitem* cmi) const {
256- // FIXME: remove const_cast after the dbusmenu_menuitem_propperty_get*() functions are constified
257- DbusmenuMenuitem * mi = const_cast<DbusmenuMenuitem*>(cmi);
258- return dbusmenu_menuitem_property_exist (mi, _key.c_str()) && (_value == get_value(mi));
259- }
260- };
261-
262- class StringPropertyPredicate: public PropertyPredicate<std::string> {
263- protected:
264- virtual std::string get_value (DbusmenuMenuitem * mi) const {
265- return dbusmenu_menuitem_property_get(mi, _key.c_str());
266- }
267- public:
268- StringPropertyPredicate (const char * propName, const char * propValue):
269- PropertyPredicate (propName, propValue) {}
270- };
271-
272- class IntPropertyPredicate: public PropertyPredicate<int> {
273- protected:
274- virtual int get_value (DbusmenuMenuitem * mi) const {
275- return dbusmenu_menuitem_property_get_int(mi, _key.c_str());
276- }
277- public:
278- IntPropertyPredicate (const char * propName, int propValue):
279- PropertyPredicate (propName, propValue) {}
280- };
281-
282- class BoolPropertyPredicate: public PropertyPredicate<bool> {
283- protected:
284- virtual bool get_value (DbusmenuMenuitem * mi) const {
285- return dbusmenu_menuitem_property_get_bool(mi, _key.c_str());
286- }
287- public:
288- BoolPropertyPredicate (const char * propName, bool propValue):
289- PropertyPredicate (propName, propValue) {}
290- };
291-
292- public:
293-
294- typedef std::vector<DbusmenuMenuitem*> menuitems_t;
295-
296- void
297- match_property (menuitems_t& items, const char * key, const char * value) const
298- {
299- const StringPropertyPredicate pred (key, value);
300- items.erase (std::remove_if (items.begin(), items.end(), std::not1(pred)), items.end());
301- }
302-
303- void
304- match_property_int (menuitems_t& items, const char * key, int value) const
305- {
306- const IntPropertyPredicate pred (key, value);
307- items.erase (std::remove_if (items.begin(), items.end(), std::not1(pred)), items.end());
308- }
309-
310- void
311- match_property_bool (menuitems_t& items, const char * key, bool value) const
312- {
313- const BoolPropertyPredicate pred (key, value);
314- items.erase (std::remove_if (items.begin(), items.end(), std::not1(pred)), items.end());
315- }
316-
317- menuitems_t find_property (const char * prop_name, const char * prop_value) const
318- {
319- menuitems_t items;
320- g_return_val_if_fail (prop_name!=NULL, items);
321- g_return_val_if_fail (prop_value!=NULL, items);
322-
323- items = get_all_menuitems ();
324- match_property (items, prop_name, prop_value);
325- return items;
326- }
327-
328- menuitems_t find_property_int (const char * prop_name, int prop_value) const
329- {
330- std::vector<DbusmenuMenuitem*> items;
331- g_return_val_if_fail (prop_name!=NULL, items);
332-
333- items = get_all_menuitems ();
334- match_property_int (items, prop_name, prop_value);
335- return items;
336- }
337-
338- menuitems_t find_property_bool (const char * prop_name, bool prop_value) const
339- {
340- std::vector<DbusmenuMenuitem*> items;
341- g_return_val_if_fail (prop_name!=NULL, items);
342-
343- items = get_all_menuitems ();
344- match_property_bool (items, prop_name, prop_value);
345- return items;
346- }
347-
348- menuitems_t find_type (const char * type) const
349- {
350- return find_property (DBUSMENU_MENUITEM_PROP_TYPE, type);
351- }
352-
353- int count_property (const char * propName, const char * propValue) const
354- {
355- return find_property (propName, propValue).size();
356- }
357-
358- int count_type (const char * type) const
359- {
360- return count_property (DBUSMENU_MENUITEM_PROP_TYPE, type);
361- }
362-
363- int count_property_int (const char * propName, int propValue) const
364- {
365- return find_property_int (propName, propValue).size();
366- }
367-
368- int count_property_bool (const char * propName, bool propValue) const
369- {
370- return find_property_bool (propName, propValue).size();
371- }
372-
373- private:
374-
375- DbusmenuClient * client;
376-};
377-
378-/**
379- * Fixture class for using Google Test on an indicator-service's
380- * com.canonical.dbusmenu interface.
381- *
382- * The SetUp() function starts the service up, waits for it to
383- * be visible on the bus, then creates a DbusmenuClient and waits
384- * for its layout-changed signal. This way the test function
385- * is reached after the menu is available and populated.
386- *
387- * TearDown() cleans up the DBus scaffolding and stops the service.
388- */
389-class IndicatorServiceTest : public ::testing::Test
390-{
391- public:
392-
393- IndicatorServiceTest(const char * service_name_,
394- const char * menu_object_path_,
395- const char * executable_):
396- menu_client(0),
397- menu_helper(0),
398- test_service(0),
399- indicator_service_proxy(0),
400- handler_id(0),
401- executable(executable_),
402- service_name(service_name_),
403- menu_object_path(menu_object_path_)
404- {
405- // glib one-time init stuff
406- g_type_init();
407- g_assert (g_thread_supported());
408- mainloop = g_main_loop_new (NULL, FALSE);
409- }
410-
411- private:
412-
413- static void
414- on_layout_updated_static (DbusmenuClient * client, IndicatorServiceTest * self)
415- {
416- g_debug ("LAYOUT UPDATED");
417- self->on_layout_updated (client);
418- }
419- void
420- on_layout_updated (DbusmenuClient * client)
421- {
422- ASSERT_EQ (client, menu_client);
423- ASSERT_NE (handler_id, 0);
424- ASSERT_TRUE (g_signal_handler_is_connected (client, handler_id));
425-
426- // stop listening for this event
427- g_signal_handler_disconnect (client, handler_id);
428- handler_id = 0;
429-
430- ready();
431- }
432-
433- private:
434-
435- static gboolean
436- on_timeout_static (gpointer self)
437- {
438- static_cast<IndicatorServiceTest*>(self)->on_timeout();
439- return false;
440- }
441- void
442- on_timeout()
443- {
444- ASSERT_NE (handler_id, 0ul);
445- g_source_remove (handler_id);
446- handler_id = 0;
447- ready();
448- }
449-
450- protected:
451-
452- virtual void
453- SetUp()
454- {
455- ASSERT_EQ (NULL, test_service);
456- ASSERT_EQ (NULL, menu_helper);
457- ASSERT_EQ (NULL, indicator_service_proxy);
458-
459- test_service = dbus_test_service_new (NULL);
460-
461- // Start the executable and wait until it shows up on the bus.
462- // Unset the NO_WATCHERS env var to ensure that the service
463- // will shut down when there are no watchers... otherwise
464- // this task will never finish
465- g_unsetenv("INDICATOR_ALLOW_NO_WATCHERS");
466- DbusTestProcess * indicator_service_task = dbus_test_process_new (executable.c_str());
467- dbus_test_service_add_task (test_service, DBUS_TEST_TASK(indicator_service_task));
468- g_object_unref (G_OBJECT(indicator_service_task));
469-
470- // create a menu task that waits for our service before it runs
471- DbusTestTask * wait_task = dbus_test_task_new ();
472- dbus_test_task_set_wait_for (wait_task, service_name.c_str());
473- dbus_test_service_add_task (test_service, wait_task);
474- g_object_unref (G_OBJECT(wait_task));
475-
476- g_debug ("starting tasks");
477- dbus_test_service_start_tasks(test_service);
478-
479- // at this point the indicator service is running, let's Watch it
480- // to ensure it stays alive for the duration of the test
481- GError * error = NULL;
482- GDBusConnection * bus_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
483- indicator_service_proxy = g_dbus_proxy_new_sync (bus_connection,
484- G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
485- NULL,
486- service_name.c_str(),
487- "/org/ayatana/indicator/service",
488- "org.ayatana.indicator.service",
489- NULL,
490- &error);
491- GVariant * result = g_dbus_proxy_call_sync (indicator_service_proxy, "Watch",
492- NULL, G_DBUS_CALL_FLAGS_NO_AUTO_START,
493- -1, NULL, &error);
494- guint a, b;
495- g_variant_get (result, "(uu)", &a, &b);
496- g_debug ("Sending 'Watch' to proxy %p yielded %u %u", indicator_service_proxy, a, b);
497- g_variant_unref (result);
498- EXPECT_EQ(NULL, error);
499- if (error != NULL) {
500- g_message ("%s Unable to Watch indicator-service : %s", G_STRFUNC, error->message);
501- g_clear_error (&error);
502- }
503- g_object_unref (G_OBJECT(bus_connection));
504-
505- menu_client = dbusmenu_client_new (service_name.c_str(), menu_object_path.c_str());
506- menu_helper = new DbusmenuClientHelper (menu_client);
507-
508- // wait for a "layout-updated" signal before we let SetUp finish
509- wait_for_layout_update();
510- }
511-
512- virtual void
513- TearDown()
514- {
515- ASSERT_EQ (handler_id, 0);
516-
517- // tear down the mainloop
518- ASSERT_TRUE (mainloop != NULL);
519- g_main_loop_unref (mainloop);
520- mainloop = NULL;
521-
522- // tear down the menu client
523- if (menu_helper != NULL) {
524- delete menu_helper;
525- menu_helper = NULL;
526- }
527- if (menu_client != NULL) {
528- g_object_unref(G_OBJECT(menu_client));
529- menu_client = NULL;
530- }
531-
532- // tear down the indicator proxy
533- EXPECT_TRUE (G_IS_DBUS_PROXY(indicator_service_proxy));
534- g_object_unref (G_OBJECT(indicator_service_proxy));
535- indicator_service_proxy = NULL;
536- }
537-
538- void wait_for_layout_update()
539- {
540- ASSERT_EQ (handler_id, 0ul);
541- handler_id = g_signal_connect (menu_client,
542- DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED,
543- G_CALLBACK(on_layout_updated_static),
544- this);
545- g_debug ("waiting for layout update...");
546- g_main_loop_run (mainloop);
547- }
548-
549- void wait_seconds (int seconds)
550- {
551- ASSERT_EQ (handler_id, 0ul);
552- handler_id = g_timeout_add_seconds (seconds, on_timeout_static, this);
553- g_debug ("waiting %d seconds...", seconds);
554- g_main_loop_run (mainloop);
555- }
556-
557- protected:
558-
559- DbusmenuClient * menu_client;
560- DbusmenuClientHelper * menu_helper;
561-
562- private:
563-
564- void ready()
565- {
566- g_debug("done waiting");
567- g_main_loop_quit (mainloop);
568- }
569-
570- GMainLoop * mainloop;
571- DbusTestService * test_service;
572- GDBusProxy * indicator_service_proxy;
573- gulong handler_id;
574- const std::string executable;
575- const std::string service_name;
576- const std::string menu_object_path;
577-};
578-
579-#endif // #ifndef INDICATOR_SERVICE_TEST_H
580
581=== added file 'tests/indicator-session.service.in'
582--- tests/indicator-session.service.in 1970-01-01 00:00:00 +0000
583+++ tests/indicator-session.service.in 2012-11-16 18:58:44 +0000
584@@ -0,0 +1,3 @@
585+[D-BUS Service]
586+Name=com.canonical.indicator.session
587+Exec=@abs_top_builddir@/src/indicator-session-service
588
589=== added file 'tests/org.gnome.desktop.lockdown.gschema.xml'
590--- tests/org.gnome.desktop.lockdown.gschema.xml 1970-01-01 00:00:00 +0000
591+++ tests/org.gnome.desktop.lockdown.gschema.xml 2012-11-16 18:58:44 +0000
592@@ -0,0 +1,45 @@
593+<?xml version="1.0" encoding="UTF-8"?>
594+<schemalist gettext-domain="gsettings-desktop-schemas">
595+ <schema path="/org/gnome/desktop/lockdown/" id="org.gnome.desktop.lockdown">
596+ <key type="b" name="disable-command-line">
597+ <default>false</default>
598+ <summary>Disable command line</summary>
599+ <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>
600+ </key>
601+ <key type="b" name="disable-save-to-disk">
602+ <default>false</default>
603+ <summary>Disable saving files to disk</summary>
604+ <description>Prevent the user from saving files to disk. For example, this would disable access to all applications' "Save as" dialogs.</description>
605+ </key>
606+ <key type="b" name="disable-printing">
607+ <default>false</default>
608+ <summary>Disable printing</summary>
609+ <description>Prevent the user from printing. For example, this would disable access to all applications' "Print" dialogs.</description>
610+ </key>
611+ <key type="b" name="disable-print-setup">
612+ <default>false</default>
613+ <summary>Disable print setup</summary>
614+ <description>Prevent the user from modifying print settings. For example, this would disable access to all applications' "Print Setup" dialogs.</description>
615+ </key>
616+ <key type="b" name="disable-user-switching">
617+ <default>false</default>
618+ <summary>Disable user switching</summary>
619+ <description>Prevent the user from switching to another account while his session is active.</description>
620+ </key>
621+ <key type="b" name="disable-lock-screen">
622+ <default>false</default>
623+ <summary>Disable lock screen</summary>
624+ <description>Prevent the user to lock his screen.</description>
625+ </key>
626+ <key type="b" name="disable-application-handlers">
627+ <default>false</default>
628+ <summary>Disable URL and MIME type handlers</summary>
629+ <description>Prevent running any URL or MIME type handler applications.</description>
630+ </key>
631+ <key type="b" name="disable-log-out">
632+ <default>false</default>
633+ <summary>Disable log out</summary>
634+ <description>Prevent the user from logging out.</description>
635+ </key>
636+ </schema>
637+</schemalist>
638\ No newline at end of file
639
640=== added file 'tests/org.gnome.settings-daemon.plugins.media-keys.gschema.xml'
641--- tests/org.gnome.settings-daemon.plugins.media-keys.gschema.xml 1970-01-01 00:00:00 +0000
642+++ tests/org.gnome.settings-daemon.plugins.media-keys.gschema.xml 2012-11-16 18:58:44 +0000
643@@ -0,0 +1,203 @@
644+<?xml version="1.0" encoding="UTF-8"?>
645+<schemalist>
646+ <schema path="/org/gnome/settings-daemon/plugins/media-keys/" id="org.gnome.settings-daemon.plugins.media-keys" gettext-domain="gnome-settings-daemon">
647+ <key type="b" name="active">
648+ <default>true</default>
649+ <summary>Activation of this plugin</summary>
650+ <description>Whether this plugin would be activated by gnome-settings-daemon or not</description>
651+ </key>
652+ <key type="as" name="custom-keybindings">
653+ <default>[]</default>
654+ <summary>Custom keybindings</summary>
655+ <description>List of custom keybindings</description>
656+ </key>
657+ <key type="s" name="calculator">
658+ <default>'XF86Calculator'</default>
659+ <summary>Launch calculator</summary>
660+ <description>Binding to launch the calculator.</description>
661+ </key>
662+ <key type="s" name="email">
663+ <default>'XF86Mail'</default>
664+ <summary>Launch email client</summary>
665+ <description>Binding to launch the email client.</description>
666+ </key>
667+ <key type="s" name="eject">
668+ <default>'XF86Eject'</default>
669+ <summary>Eject</summary>
670+ <description>Binding to eject an optical disc.</description>
671+ </key>
672+ <key type="s" name="help">
673+ <default>''</default>
674+ <summary>Launch help browser</summary>
675+ <description>Binding to launch the help browser.</description>
676+ </key>
677+ <key type="s" name="home">
678+ <default>'XF86Explorer'</default>
679+ <summary>Home folder</summary>
680+ <description>Binding to open the Home folder.</description>
681+ </key>
682+ <key type="s" name="media">
683+ <default>'XF86AudioMedia'</default>
684+ <summary>Launch media player</summary>
685+ <description>Binding to launch the media player.</description>
686+ </key>
687+ <key type="s" name="next">
688+ <default>'XF86AudioNext'</default>
689+ <summary>Next track</summary>
690+ <description>Binding to skip to next track.</description>
691+ </key>
692+ <key type="s" name="pause">
693+ <default>'XF86AudioPause'</default>
694+ <summary>Pause playback</summary>
695+ <description>Binding to pause playback.</description>
696+ </key>
697+ <key type="s" name="play">
698+ <default>'XF86AudioPlay'</default>
699+ <summary>Play (or play/pause)</summary>
700+ <description>Binding to start playback (or toggle play/pause).</description>
701+ </key>
702+ <key type="s" name="logout">
703+ <default>'&lt;Control&gt;&lt;Alt&gt;Delete'</default>
704+ <summary>Log out</summary>
705+ <description>Binding to log out.</description>
706+ </key>
707+ <key type="s" name="previous">
708+ <default>'XF86AudioPrev'</default>
709+ <summary>Previous track</summary>
710+ <description>Binding to skip to previous track.</description>
711+ </key>
712+ <key type="i" name="priority">
713+ <default>98</default>
714+ <summary>Priority to use for this plugin</summary>
715+ <description>Priority to use for this plugin in gnome-settings-daemon startup queue</description>
716+ </key>
717+ <key type="s" name="screensaver">
718+ <default>'&lt;Control&gt;&lt;Alt&gt;l'</default>
719+ <summary>Lock screen</summary>
720+ <description>Binding to lock the screen.</description>
721+ </key>
722+ <key type="s" name="search">
723+ <default>'XF86Search'</default>
724+ <summary>Search</summary>
725+ <description>Binding to launch the search tool.</description>
726+ </key>
727+ <key type="s" name="stop">
728+ <default>'XF86AudioStop'</default>
729+ <summary>Stop playback</summary>
730+ <description>Binding to stop playback.</description>
731+ </key>
732+ <key type="s" name="volume-down">
733+ <default>'XF86AudioLowerVolume'</default>
734+ <summary>Volume down</summary>
735+ <description>Binding to lower the system volume.</description>
736+ </key>
737+ <key type="s" name="volume-mute">
738+ <default>'XF86AudioMute'</default>
739+ <summary>Volume mute</summary>
740+ <description>Binding to mute the system volume.</description>
741+ </key>
742+ <key type="s" name="volume-up">
743+ <default>'XF86AudioRaiseVolume'</default>
744+ <summary>Volume up</summary>
745+ <description>Binding to raise the system volume.</description>
746+ </key>
747+ <key type="s" name="screenshot">
748+ <default>'Print'</default>
749+ <summary>Take a screenshot</summary>
750+ <description>Binding to take a screenshot.</description>
751+ </key>
752+ <key type="s" name="window-screenshot">
753+ <default>'&lt;Alt&gt;Print'</default>
754+ <summary>Take a screenshot of a window</summary>
755+ <description>Binding to take a screenshot of a window.</description>
756+ </key>
757+ <key type="s" name="area-screenshot">
758+ <default>'&lt;Shift&gt;Print'</default>
759+ <summary>Take a screenshot of an area</summary>
760+ <description>Binding to take a screenshot of an area.</description>
761+ </key>
762+ <key type="s" name="screenshot-clip">
763+ <default>'&lt;Ctrl&gt;Print'</default>
764+ <summary>Copy a screenshot to clipboard</summary>
765+ <description>Binding to copy a screenshot to clipboard.</description>
766+ </key>
767+ <key type="s" name="window-screenshot-clip">
768+ <default>'&lt;Ctrl&gt;&lt;Alt&gt;Print'</default>
769+ <summary>Copy a screenshot of a window to clipboard</summary>
770+ <description>Binding to copy a screenshot of a window to clipboard.</description>
771+ </key>
772+ <key type="s" name="area-screenshot-clip">
773+ <default>'&lt;Ctrl&gt;&lt;Shift&gt;Print'</default>
774+ <summary>Copy a screenshot of an area to clipboard</summary>
775+ <description>Binding to copy a screenshot of an area to clipboard.</description>
776+ </key>
777+ <key type="s" name="terminal">
778+ <default>'&lt;Primary&gt;&lt;Alt&gt;t'</default>
779+ <summary>Launch terminal</summary>
780+ <description>Binding to launch the terminal.</description>
781+ </key>
782+ <key type="s" name="www">
783+ <default>'XF86WWW'</default>
784+ <summary>Launch web browser</summary>
785+ <description>Binding to launch the web browser.</description>
786+ </key>
787+ <key type="s" name="magnifier">
788+ <default>''</default>
789+ <summary>Toggle magnifier</summary>
790+ <description>Binding to show the screen magnifier</description>
791+ </key>
792+ <key type="s" name="screenreader">
793+ <default>''</default>
794+ <summary>Toggle screen reader</summary>
795+ <description>Binding to start the screen reader</description>
796+ </key>
797+ <key type="s" name="on-screen-keyboard">
798+ <default>''</default>
799+ <summary>Toggle on-screen keyboard</summary>
800+ <description>Binding to show the on-screen keyboard</description>
801+ </key>
802+ <key type="s" name="increase-text-size">
803+ <default>''</default>
804+ <summary>Increase text size</summary>
805+ <description>Binding to increase the text size</description>
806+ </key>
807+ <key type="s" name="decrease-text-size">
808+ <default>''</default>
809+ <summary>Decrease text size</summary>
810+ <description>Binding to decrease the text size</description>
811+ </key>
812+ <key type="s" name="toggle-contrast">
813+ <default>''</default>
814+ <summary>Toggle contrast</summary>
815+ <description>Binding to toggle the interface contrast</description>
816+ </key>
817+ <key type="s" name="magnifier-zoom-in">
818+ <default>''</default>
819+ <summary>Magnifier zoom in</summary>
820+ <description>Binding for the magnifier to zoom in</description>
821+ </key>
822+ <key type="s" name="magnifier-zoom-out">
823+ <default>''</default>
824+ <summary>Magnifier zoom out</summary>
825+ <description>Binding for the magnifier to zoom out</description>
826+ </key>
827+ </schema>
828+
829+ <schema id="org.gnome.settings-daemon.plugins.media-keys.custom-keybinding" gettext-domain="gnome-settings-daemon">
830+ <key type="s" name="name">
831+ <default>''</default>
832+ <summary>Name</summary>
833+ <description>Name of the custom binding</description>
834+ </key>
835+ <key type="s" name="binding">
836+ <default>''</default>
837+ <summary>Binding</summary>
838+ <description>Binding for the custom binding</description>
839+ </key>
840+ <key type="s" name="command">
841+ <default>''</default>
842+ <summary>Command</summary>
843+ <description>Command to run when the binding is invoked</description>
844+ </key>
845+ </schema>
846+</schemalist>
847\ No newline at end of file
848
849=== modified file 'tests/test-service.cc'
850--- tests/test-service.cc 2012-08-23 18:00:30 +0000
851+++ tests/test-service.cc 2012-11-16 18:58:44 +0000
852@@ -17,39 +17,130 @@
853 with this program. If not, see <http://www.gnu.org/licenses/>.
854 */
855
856-#include "gtest-dbus-helper.h"
857+#include <glib-object.h>
858+#include <gio/gio.h>
859+#include <glib.h>
860+
861+#include <gtest/gtest.h>
862+
863 #include "shared-names.h"
864
865 /***
866 ****
867 ***/
868
869-/**
870- * Fixture class for testing indicator-session-service with Google Test.
871- */
872-class SessionServiceTest: public IndicatorServiceTest
873+#define INDICATOR_SERVICE_OBJECT_PATH "/org/ayatana/indicator/service"
874+#define INDICATOR_SERVICE_INTERFACE_NAME "org.ayatana.indicator.service"
875+
876+class ClientTest : public ::testing::Test
877 {
878- public:
879- virtual ~SessionServiceTest() {}
880- SessionServiceTest(): IndicatorServiceTest(INDICATOR_SESSION_DBUS_NAME,
881- INDICATOR_SESSION_DBUS_OBJECT,
882- INDICATOR_SERVICE_PATH) { }
883- public:
884- virtual void SetUp() {
885- wait_seconds(1);
886- IndicatorServiceTest::SetUp();
887+ protected:
888+
889+ GTestDBus * test_dbus;
890+ GDBusConnection * session_bus;
891+ GMainLoop * main_loop;
892+
893+ virtual void SetUp()
894+ {
895+ test_dbus = NULL;
896+ session_bus = NULL;
897+ main_loop = NULL;
898+
899+ static bool first_run = true;
900+ if (first_run)
901+ {
902+ g_type_init();
903+ g_setenv ("INDICATOR_SERVICE_SHUTDOWN_TIMEOUT", "1000", TRUE);
904+ g_unsetenv ("INDICATOR_ALLOW_NO_WATCHERS");
905+ g_unsetenv ("INDICATOR_SERVICE_REPLACE_MODE");
906+ g_setenv ("GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, TRUE);
907+ g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
908+ first_run = false;
909+ }
910+
911+ main_loop = g_main_loop_new (NULL, FALSE);
912+ // pull up a test dbus that's pointed at our test .service file
913+ test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
914+ g_debug (G_STRLOC" service dir path is \"%s\"", INDICATOR_SERVICE_DIR);
915+ g_test_dbus_add_service_dir (test_dbus, INDICATOR_SERVICE_DIR);
916+
917+ // allow the service to exist w/o a sync indicator
918+ g_setenv ("INDICATOR_ALLOW_NO_WATCHERS", "1", TRUE);
919+
920+ g_test_dbus_up (test_dbus);
921+ g_debug (G_STRLOC" this test bus' address is \"%s\"", g_test_dbus_get_bus_address(test_dbus));
922+ session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
923+ g_debug (G_STRLOC" the dbus connection %p unique name is \"%s\"", session_bus, g_dbus_connection_get_unique_name(session_bus));
924+ g_debug (G_STRLOC" the dbus connection %p refcount is %d", session_bus, G_OBJECT(session_bus)->ref_count);
925 }
926- virtual void TearDown() {
927- IndicatorServiceTest::TearDown();
928+
929+ // undo SetUp
930+ virtual void TearDown()
931+ {
932+ g_clear_object (&session_bus);
933+ g_debug (G_STRLOC" tearing down the bus");
934+ g_test_dbus_down (test_dbus);
935+ g_clear_object (&test_dbus);
936+ g_clear_pointer (&main_loop, g_main_loop_unref);
937 }
938 };
939
940+/***
941+****
942+***/
943
944 /**
945- * Basic sanity test to see if we can account for all our menuitems.
946+ * This is a basic test to see if we can launch indicator-session-service
947+ * and call its "GetUserRealName" method. The test succeeds if we can launch
948+ * the service, call the method, and get response that equals g_get_real_name().
949+ *
950+ * (You may be wondering why GetUserRealName() exists at all, instead of clients
951+ * using g_get_real_name(). It's because the former updates itslef when the user
952+ * edits his real name, while the latter returns its cached copy of the old name.)
953 */
954-TEST_F(SessionServiceTest, HelloWorld)
955+TEST_F (ClientTest, TestCanStartService)
956 {
957- ASSERT_TRUE(true);
958+ GError * error;
959+ GVariant * result;
960+ const gchar * name;
961+
962+ // call GetUserRealName(), which as a side effect should activate
963+ // indicator-session-service via the .service file in the tests/ directory
964+ error = NULL;
965+ result = g_dbus_connection_call_sync (session_bus,
966+ INDICATOR_SESSION_DBUS_NAME,
967+ INDICATOR_SESSION_SERVICE_DBUS_OBJECT,
968+ INDICATOR_SESSION_SERVICE_DBUS_IFACE,
969+ "GetUserRealName",
970+ NULL,
971+ G_VARIANT_TYPE("(s)"),
972+ G_DBUS_CALL_FLAGS_NONE,
973+ -1,
974+ NULL,
975+ &error);
976+
977+ EXPECT_TRUE (error == NULL);
978+ ASSERT_TRUE (result != NULL);
979+
980+ if (error != NULL)
981+ {
982+ g_warning ("GetUserRealName failed: %s", error->message);
983+ g_clear_error (&error);
984+ }
985+
986+ name = NULL;
987+ g_variant_get (result, "(&s)", &name);
988+ ASSERT_STREQ (g_get_real_name(), name);
989+ g_clear_pointer (&result, g_variant_unref);
990+
991+ // call IndicatorService's Shutdown() method for a clean exit
992+ result = g_dbus_connection_call_sync (session_bus,
993+ INDICATOR_SESSION_DBUS_NAME,
994+ "/org/ayatana/indicator/service",
995+ "org.ayatana.indicator.service",
996+ "Shutdown", NULL,
997+ NULL,
998+ G_DBUS_CALL_FLAGS_NONE,
999+ -1, NULL, NULL);
1000+ g_clear_pointer (&result, g_variant_unref);
1001 }
1002-

Subscribers

People subscribed via source and target branches