aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac13
-rw-r--r--debian/changelog6
-rw-r--r--debian/control1
-rw-r--r--debian/rules3
-rw-r--r--tests/Makefile.am52
-rw-r--r--tests/gtest-dbus-helper.h418
-rw-r--r--tests/indicator-session.service.in3
-rw-r--r--tests/org.gnome.desktop.lockdown.gschema.xml45
-rw-r--r--tests/org.gnome.settings-daemon.plugins.media-keys.gschema.xml203
-rw-r--r--tests/test-service.cc131
10 files changed, 403 insertions, 472 deletions
diff --git a/configure.ac b/configure.ac
index d485254..aadb24e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,6 +25,7 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
# Dependencies
###########################
+GIO_REQUIRED_VERSION=2.33
GLIB_REQUIRED_VERSION=2.33
GTK_REQUIRED_VERSION=3.0
INDICATOR_REQUIRED_VERSION=0.3.19
@@ -135,16 +136,15 @@ if test "x$enable_tests" != "xno"; then
AC_MSG_ERROR([tests were requested but gtest is not installed.])
fi
if test "x$enable_tests" = "xyes"; then
- PKG_CHECK_MODULES([TEST_SERVICE],[indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION
- dbustest-1 >= $DBUSTEST_REQUIRED_VERSION
- dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION],
- [enable_tests="yes"],
- [enable_tests="no"])
+ PKG_CHECK_MODULES([TEST_SERVICE],[glib-2.0 >= $GLIB_REQUIRED_VERSION
+ gio-2.0 >= $GIO_REQUIRED_VERSION],
+ [enable_tests="yes"],
+ [enable_tests="no"])
fi
fi
AM_CONDITIONAL([BUILD_TESTS],[test "x$enable_tests" = "xyes"])
AC_SUBST([TEST_SERVICE_CFLAGS])
-AC_SUBST([TEST_SERVICE_LDFLAGS])
+AC_SUBST([TEST_SERVICE_LIBS])
##############################
# Custom Junk
@@ -211,6 +211,7 @@ data/icons/scalable/actions/Makefile
data/icons/scalable/status/Makefile
data/extra-sessions/Makefile
tests/Makefile
+tests/indicator-session.service
po/Makefile.in
])
diff --git a/debian/changelog b/debian/changelog
index 418d825..5fca7cd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,14 +4,10 @@ indicator-session (12.10.5-0ubuntu1) UNRELEASED; urgency=low
- Add DPKG_GENSYMBOLS_CHECK_LEVEL=4.
- Use the dh sequencer with autoreconf.
- Override dh_autoreconf to run autogen.sh.
- - Temporarily disable running tests due to an issue with getting the
- gsettings schema for testing.
* debian/control:
- Add dh-autoreconf to Build-Depends.
- Add gnome-common to Build-Depends.
- - Add libdbustest1-dev, dbus-test-runner to Build-Depends.
- - Explicitly list libgtest-dev in Build-Depends, even though it does get
- pulled in via libxorg-gtest-dev.
+ - Add libgtest-dev, libdbustest1-dev, dbus-test-runner to Build-Depends.
- Adjust style to be consistent and use trailing commas in lists.
- Update Vcs-Bzr and Vcs-Browser fields and add notice for uploaders.
* Automatic snapshot from revision 373 (bootstrap):
diff --git a/debian/control b/debian/control
index de9dc22..2c6a551 100644
--- a/debian/control
+++ b/debian/control
@@ -7,7 +7,6 @@ Build-Depends: debhelper (>= 9),
dh-translations,
intltool,
gnome-common,
- libxorg-gtest-dev,
libgtest-dev,
libdbustest1-dev,
dbus-test-runner,
diff --git a/debian/rules b/debian/rules
index cafefe7..54cfd06 100644
--- a/debian/rules
+++ b/debian/rules
@@ -5,9 +5,6 @@ export DPKG_GENSYMBOLS_CHECK_LEVEL=4
%:
dh $@ --with translations,autoreconf
-override_dh_auto_test:
- # TESTS TEMPORARILY DISABLED: need fixing for gsettings schema.
-
override_dh_autoreconf:
NOCONFIGURE=1 dh_autoreconf ./autogen.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9371c2e..088b283 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,31 +1,45 @@
TESTS =
CLEANFILES =
+BUILT_SOURCES =
+check_PROGRAMS =
+
+###
+###
+###
# stock UMB tests on user-visible strings
include $(srcdir)/Makefile.am.strings
-AM_CPPFLAGS = \
- $(GTEST_CPPFLAGS) \
- $(XORG_GTEST_CPPFLAGS) \
- $(INDICATOR_CFLAGS) \
- -I${top_srcdir}/src \
- -Wall -Werror
+check_LIBRARIES = libgtest.a
+nodist_libgtest_a_SOURCES = \
+ $(GTEST_SOURCE)/src/gtest-all.cc \
+ $(GTEST_SOURCE)/src/gtest_main.cc
+
+AM_CPPFLAGS = $(GTEST_CPPFLAGS) -I${top_srcdir}/src -Wall -Werror
AM_CXXFLAGS = $(GTEST_CXXFLAGS)
-TESTS = test-service
-check_PROGRAMS = test-service
-test_service_SOURCES = \
- test-service.cc \
- gtest-dbus-helper.h
-test_service_LDADD = $(TEST_SERVICE_LIBS) libgtest.a $(XORG_GTEST_MAIN_LIBS) $(X11_LIBS)
+###
+###
+###
+
+BUILT_SOURCES += gschemas.compiled
+CLEANFILES += gschemas.compiled
+gschemas.compiled: Makefile
+ $(AM_V_at) cp -f $(top_builddir)/data/*gschema.xml .
+ $(AM_V_GEN) $(GLIB_COMPILE_SCHEMAS) --targetdir=. .
+
+
+TESTS += test-service
+check_PROGRAMS += test-service
+test_service_SOURCES = test-service.cc
+test_service_LDADD = \
+ $(TEST_SERVICE_LIBS) \
+ libgtest.a
test_service_CPPFLAGS = \
+ -DSCHEMA_DIR="\"$(top_builddir)/tests/\"" \
+ -DINDICATOR_SERVICE_DIR="\"$(abs_builddir)\"" \
+ -DINDICATOR_SERVICE_PATH="\"$(top_builddir)/src/indicator-session-service\"" \
$(TEST_SERVICE_CFLAGS) \
- $(AM_CPPFLAGS) \
- -DINDICATOR_SERVICE_PATH="\"$(top_builddir)/src/indicator-session-service\""
+ $(AM_CPPFLAGS)
-check_LIBRARIES = libgtest.a
-nodist_libgtest_a_SOURCES = \
- $(XORG_GTEST_SOURCE)/src/xorg-gtest-all.cpp \
- $(GTEST_SOURCE)/src/gtest-all.cc \
- $(XORG_GTEST_SOURCE)/src/xorg-gtest_main.cpp
diff --git a/tests/gtest-dbus-helper.h b/tests/gtest-dbus-helper.h
deleted file mode 100644
index c893606..0000000
--- a/tests/gtest-dbus-helper.h
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
-Copyright 2012 Canonical Ltd.
-
-Authors:
- Charles Kerr <charles.kerr@canonical.com>
-
-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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef INDICATOR_SERVICE_TEST_H
-#define INDICATOR_SERVICE_TEST_H
-
-#include <algorithm>
-#include <functional>
-#include <string>
-#include <vector>
-
-#include <gio/gio.h>
-#include <gtest/gtest.h>
-#include <libdbustest/dbus-test.h>
-#include <libdbusmenu-glib/client.h>
-
-/***
-****
-***/
-
-/**
- * Convenience class for looking at a DbusmenuClient's items for testing
- *
- * Examples:
- *
- * // confirm that there are N menuitems of type T
- * TEST_EQ (helper.count_type(T), N);
- *
- * // confirm that there are N visible menuitems
- * TEST_EQ (helper.count_property_bool(DBUSMENU_MENUITEM_PROP_VISIBLE,true), N);
- *
- * // get a sorted list of all the menuitems of type T
- * std::vector<DbusmenuMenuitem*> items = helper.find_type(T);
- */
-class DbusmenuClientHelper
-{
- public:
-
- DbusmenuClientHelper (DbusmenuClient * client_): client(client_) {
- g_object_ref (G_OBJECT(client));
- }
- ~DbusmenuClientHelper() {
- g_object_unref(G_OBJECT(client));
- client = NULL;
- }
-
- private:
-
- static void foreach_accumulate_func (DbusmenuMenuitem * mi, gpointer gset) {
- static_cast<std::vector<DbusmenuMenuitem*>*>(gset)->push_back (mi);
- }
-
- public:
-
- std::vector<DbusmenuMenuitem*>
- get_all_menuitems () const
- {
- std::vector<DbusmenuMenuitem*> items;
-
- DbusmenuMenuitem * root = dbusmenu_client_get_root (client);
- if (root != NULL)
- dbusmenu_menuitem_foreach (root, foreach_accumulate_func, &items);
-
- return items;
- }
-
- private:
-
- template<typename value_type> class PropertyPredicate:
- public std::unary_function<DbusmenuMenuitem*,bool> {
- protected:
- const std::string _key;
- const value_type _value;
- virtual value_type get_value(DbusmenuMenuitem * mi) const = 0;
- public:
- PropertyPredicate (const char * propertyName, value_type propertyValue):
- _key(propertyName), _value(propertyValue) { }
- bool operator()(const DbusmenuMenuitem* cmi) const {
- // FIXME: remove const_cast after the dbusmenu_menuitem_propperty_get*() functions are constified
- DbusmenuMenuitem * mi = const_cast<DbusmenuMenuitem*>(cmi);
- return dbusmenu_menuitem_property_exist (mi, _key.c_str()) && (_value == get_value(mi));
- }
- };
-
- class StringPropertyPredicate: public PropertyPredicate<std::string> {
- protected:
- virtual std::string get_value (DbusmenuMenuitem * mi) const {
- return dbusmenu_menuitem_property_get(mi, _key.c_str());
- }
- public:
- StringPropertyPredicate (const char * propName, const char * propValue):
- PropertyPredicate (propName, propValue) {}
- };
-
- class IntPropertyPredicate: public PropertyPredicate<int> {
- protected:
- virtual int get_value (DbusmenuMenuitem * mi) const {
- return dbusmenu_menuitem_property_get_int(mi, _key.c_str());
- }
- public:
- IntPropertyPredicate (const char * propName, int propValue):
- PropertyPredicate (propName, propValue) {}
- };
-
- class BoolPropertyPredicate: public PropertyPredicate<bool> {
- protected:
- virtual bool get_value (DbusmenuMenuitem * mi) const {
- return dbusmenu_menuitem_property_get_bool(mi, _key.c_str());
- }
- public:
- BoolPropertyPredicate (const char * propName, bool propValue):
- PropertyPredicate (propName, propValue) {}
- };
-
- public:
-
- typedef std::vector<DbusmenuMenuitem*> menuitems_t;
-
- void
- match_property (menuitems_t& items, const char * key, const char * value) const
- {
- const StringPropertyPredicate pred (key, value);
- items.erase (std::remove_if (items.begin(), items.end(), std::not1(pred)), items.end());
- }
-
- void
- match_property_int (menuitems_t& items, const char * key, int value) const
- {
- const IntPropertyPredicate pred (key, value);
- items.erase (std::remove_if (items.begin(), items.end(), std::not1(pred)), items.end());
- }
-
- void
- match_property_bool (menuitems_t& items, const char * key, bool value) const
- {
- const BoolPropertyPredicate pred (key, value);
- items.erase (std::remove_if (items.begin(), items.end(), std::not1(pred)), items.end());
- }
-
- menuitems_t find_property (const char * prop_name, const char * prop_value) const
- {
- menuitems_t items;
- g_return_val_if_fail (prop_name!=NULL, items);
- g_return_val_if_fail (prop_value!=NULL, items);
-
- items = get_all_menuitems ();
- match_property (items, prop_name, prop_value);
- return items;
- }
-
- menuitems_t find_property_int (const char * prop_name, int prop_value) const
- {
- std::vector<DbusmenuMenuitem*> items;
- g_return_val_if_fail (prop_name!=NULL, items);
-
- items = get_all_menuitems ();
- match_property_int (items, prop_name, prop_value);
- return items;
- }
-
- menuitems_t find_property_bool (const char * prop_name, bool prop_value) const
- {
- std::vector<DbusmenuMenuitem*> items;
- g_return_val_if_fail (prop_name!=NULL, items);
-
- items = get_all_menuitems ();
- match_property_bool (items, prop_name, prop_value);
- return items;
- }
-
- menuitems_t find_type (const char * type) const
- {
- return find_property (DBUSMENU_MENUITEM_PROP_TYPE, type);
- }
-
- int count_property (const char * propName, const char * propValue) const
- {
- return find_property (propName, propValue).size();
- }
-
- int count_type (const char * type) const
- {
- return count_property (DBUSMENU_MENUITEM_PROP_TYPE, type);
- }
-
- int count_property_int (const char * propName, int propValue) const
- {
- return find_property_int (propName, propValue).size();
- }
-
- int count_property_bool (const char * propName, bool propValue) const
- {
- return find_property_bool (propName, propValue).size();
- }
-
- private:
-
- DbusmenuClient * client;
-};
-
-/**
- * Fixture class for using Google Test on an indicator-service's
- * com.canonical.dbusmenu interface.
- *
- * The SetUp() function starts the service up, waits for it to
- * be visible on the bus, then creates a DbusmenuClient and waits
- * for its layout-changed signal. This way the test function
- * is reached after the menu is available and populated.
- *
- * TearDown() cleans up the DBus scaffolding and stops the service.
- */
-class IndicatorServiceTest : public ::testing::Test
-{
- public:
-
- IndicatorServiceTest(const char * service_name_,
- const char * menu_object_path_,
- const char * executable_):
- menu_client(0),
- menu_helper(0),
- test_service(0),
- indicator_service_proxy(0),
- handler_id(0),
- executable(executable_),
- service_name(service_name_),
- menu_object_path(menu_object_path_)
- {
- // glib one-time init stuff
- g_type_init();
- g_assert (g_thread_supported());
- mainloop = g_main_loop_new (NULL, FALSE);
- }
-
- private:
-
- static void
- on_layout_updated_static (DbusmenuClient * client, IndicatorServiceTest * self)
- {
- g_debug ("LAYOUT UPDATED");
- self->on_layout_updated (client);
- }
- void
- on_layout_updated (DbusmenuClient * client)
- {
- ASSERT_EQ (client, menu_client);
- ASSERT_NE (handler_id, 0);
- ASSERT_TRUE (g_signal_handler_is_connected (client, handler_id));
-
- // stop listening for this event
- g_signal_handler_disconnect (client, handler_id);
- handler_id = 0;
-
- ready();
- }
-
- private:
-
- static gboolean
- on_timeout_static (gpointer self)
- {
- static_cast<IndicatorServiceTest*>(self)->on_timeout();
- return false;
- }
- void
- on_timeout()
- {
- ASSERT_NE (handler_id, 0ul);
- g_source_remove (handler_id);
- handler_id = 0;
- ready();
- }
-
- protected:
-
- virtual void
- SetUp()
- {
- ASSERT_EQ (NULL, test_service);
- ASSERT_EQ (NULL, menu_helper);
- ASSERT_EQ (NULL, indicator_service_proxy);
-
- test_service = dbus_test_service_new (NULL);
-
- // Start the executable and wait until it shows up on the bus.
- // Unset the NO_WATCHERS env var to ensure that the service
- // will shut down when there are no watchers... otherwise
- // this task will never finish
- g_unsetenv("INDICATOR_ALLOW_NO_WATCHERS");
- DbusTestProcess * indicator_service_task = dbus_test_process_new (executable.c_str());
- dbus_test_service_add_task (test_service, DBUS_TEST_TASK(indicator_service_task));
- g_object_unref (G_OBJECT(indicator_service_task));
-
- // create a menu task that waits for our service before it runs
- DbusTestTask * wait_task = dbus_test_task_new ();
- dbus_test_task_set_wait_for (wait_task, service_name.c_str());
- dbus_test_service_add_task (test_service, wait_task);
- g_object_unref (G_OBJECT(wait_task));
-
- g_debug ("starting tasks");
- dbus_test_service_start_tasks(test_service);
-
- // at this point the indicator service is running, let's Watch it
- // to ensure it stays alive for the duration of the test
- GError * error = NULL;
- GDBusConnection * bus_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
- indicator_service_proxy = g_dbus_proxy_new_sync (bus_connection,
- G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
- NULL,
- service_name.c_str(),
- "/org/ayatana/indicator/service",
- "org.ayatana.indicator.service",
- NULL,
- &error);
- GVariant * result = g_dbus_proxy_call_sync (indicator_service_proxy, "Watch",
- NULL, G_DBUS_CALL_FLAGS_NO_AUTO_START,
- -1, NULL, &error);
- guint a, b;
- g_variant_get (result, "(uu)", &a, &b);
- g_debug ("Sending 'Watch' to proxy %p yielded %u %u", indicator_service_proxy, a, b);
- g_variant_unref (result);
- EXPECT_EQ(NULL, error);
- if (error != NULL) {
- g_message ("%s Unable to Watch indicator-service : %s", G_STRFUNC, error->message);
- g_clear_error (&error);
- }
- g_object_unref (G_OBJECT(bus_connection));
-
- menu_client = dbusmenu_client_new (service_name.c_str(), menu_object_path.c_str());
- menu_helper = new DbusmenuClientHelper (menu_client);
-
- // wait for a "layout-updated" signal before we let SetUp finish
- wait_for_layout_update();
- }
-
- virtual void
- TearDown()
- {
- ASSERT_EQ (handler_id, 0);
-
- // tear down the mainloop
- ASSERT_TRUE (mainloop != NULL);
- g_main_loop_unref (mainloop);
- mainloop = NULL;
-
- // tear down the menu client
- if (menu_helper != NULL) {
- delete menu_helper;
- menu_helper = NULL;
- }
- if (menu_client != NULL) {
- g_object_unref(G_OBJECT(menu_client));
- menu_client = NULL;
- }
-
- // tear down the indicator proxy
- EXPECT_TRUE (G_IS_DBUS_PROXY(indicator_service_proxy));
- g_object_unref (G_OBJECT(indicator_service_proxy));
- indicator_service_proxy = NULL;
- }
-
- void wait_for_layout_update()
- {
- ASSERT_EQ (handler_id, 0ul);
- handler_id = g_signal_connect (menu_client,
- DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED,
- G_CALLBACK(on_layout_updated_static),
- this);
- g_debug ("waiting for layout update...");
- g_main_loop_run (mainloop);
- }
-
- void wait_seconds (int seconds)
- {
- ASSERT_EQ (handler_id, 0ul);
- handler_id = g_timeout_add_seconds (seconds, on_timeout_static, this);
- g_debug ("waiting %d seconds...", seconds);
- g_main_loop_run (mainloop);
- }
-
- protected:
-
- DbusmenuClient * menu_client;
- DbusmenuClientHelper * menu_helper;
-
- private:
-
- void ready()
- {
- g_debug("done waiting");
- g_main_loop_quit (mainloop);
- }
-
- GMainLoop * mainloop;
- DbusTestService * test_service;
- GDBusProxy * indicator_service_proxy;
- gulong handler_id;
- const std::string executable;
- const std::string service_name;
- const std::string menu_object_path;
-};
-
-#endif // #ifndef INDICATOR_SERVICE_TEST_H
diff --git a/tests/indicator-session.service.in b/tests/indicator-session.service.in
new file mode 100644
index 0000000..80aab0d
--- /dev/null
+++ b/tests/indicator-session.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=com.canonical.indicator.session
+Exec=@abs_top_builddir@/src/indicator-session-service
diff --git a/tests/org.gnome.desktop.lockdown.gschema.xml b/tests/org.gnome.desktop.lockdown.gschema.xml
new file mode 100644
index 0000000..6ccee17
--- /dev/null
+++ b/tests/org.gnome.desktop.lockdown.gschema.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist gettext-domain="gsettings-desktop-schemas">
+ <schema path="/org/gnome/desktop/lockdown/" id="org.gnome.desktop.lockdown">
+ <key type="b" name="disable-command-line">
+ <default>false</default>
+ <summary>Disable command line</summary>
+ <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>
+ </key>
+ <key type="b" name="disable-save-to-disk">
+ <default>false</default>
+ <summary>Disable saving files to disk</summary>
+ <description>Prevent the user from saving files to disk. For example, this would disable access to all applications' "Save as" dialogs.</description>
+ </key>
+ <key type="b" name="disable-printing">
+ <default>false</default>
+ <summary>Disable printing</summary>
+ <description>Prevent the user from printing. For example, this would disable access to all applications' "Print" dialogs.</description>
+ </key>
+ <key type="b" name="disable-print-setup">
+ <default>false</default>
+ <summary>Disable print setup</summary>
+ <description>Prevent the user from modifying print settings. For example, this would disable access to all applications' "Print Setup" dialogs.</description>
+ </key>
+ <key type="b" name="disable-user-switching">
+ <default>false</default>
+ <summary>Disable user switching</summary>
+ <description>Prevent the user from switching to another account while his session is active.</description>
+ </key>
+ <key type="b" name="disable-lock-screen">
+ <default>false</default>
+ <summary>Disable lock screen</summary>
+ <description>Prevent the user to lock his screen.</description>
+ </key>
+ <key type="b" name="disable-application-handlers">
+ <default>false</default>
+ <summary>Disable URL and MIME type handlers</summary>
+ <description>Prevent running any URL or MIME type handler applications.</description>
+ </key>
+ <key type="b" name="disable-log-out">
+ <default>false</default>
+ <summary>Disable log out</summary>
+ <description>Prevent the user from logging out.</description>
+ </key>
+ </schema>
+</schemalist> \ No newline at end of file
diff --git a/tests/org.gnome.settings-daemon.plugins.media-keys.gschema.xml b/tests/org.gnome.settings-daemon.plugins.media-keys.gschema.xml
new file mode 100644
index 0000000..3f8dd50
--- /dev/null
+++ b/tests/org.gnome.settings-daemon.plugins.media-keys.gschema.xml
@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist>
+ <schema path="/org/gnome/settings-daemon/plugins/media-keys/" id="org.gnome.settings-daemon.plugins.media-keys" gettext-domain="gnome-settings-daemon">
+ <key type="b" name="active">
+ <default>true</default>
+ <summary>Activation of this plugin</summary>
+ <description>Whether this plugin would be activated by gnome-settings-daemon or not</description>
+ </key>
+ <key type="as" name="custom-keybindings">
+ <default>[]</default>
+ <summary>Custom keybindings</summary>
+ <description>List of custom keybindings</description>
+ </key>
+ <key type="s" name="calculator">
+ <default>'XF86Calculator'</default>
+ <summary>Launch calculator</summary>
+ <description>Binding to launch the calculator.</description>
+ </key>
+ <key type="s" name="email">
+ <default>'XF86Mail'</default>
+ <summary>Launch email client</summary>
+ <description>Binding to launch the email client.</description>
+ </key>
+ <key type="s" name="eject">
+ <default>'XF86Eject'</default>
+ <summary>Eject</summary>
+ <description>Binding to eject an optical disc.</description>
+ </key>
+ <key type="s" name="help">
+ <default>''</default>
+ <summary>Launch help browser</summary>
+ <description>Binding to launch the help browser.</description>
+ </key>
+ <key type="s" name="home">
+ <default>'XF86Explorer'</default>
+ <summary>Home folder</summary>
+ <description>Binding to open the Home folder.</description>
+ </key>
+ <key type="s" name="media">
+ <default>'XF86AudioMedia'</default>
+ <summary>Launch media player</summary>
+ <description>Binding to launch the media player.</description>
+ </key>
+ <key type="s" name="next">
+ <default>'XF86AudioNext'</default>
+ <summary>Next track</summary>
+ <description>Binding to skip to next track.</description>
+ </key>
+ <key type="s" name="pause">
+ <default>'XF86AudioPause'</default>
+ <summary>Pause playback</summary>
+ <description>Binding to pause playback.</description>
+ </key>
+ <key type="s" name="play">
+ <default>'XF86AudioPlay'</default>
+ <summary>Play (or play/pause)</summary>
+ <description>Binding to start playback (or toggle play/pause).</description>
+ </key>
+ <key type="s" name="logout">
+ <default>'&lt;Control&gt;&lt;Alt&gt;Delete'</default>
+ <summary>Log out</summary>
+ <description>Binding to log out.</description>
+ </key>
+ <key type="s" name="previous">
+ <default>'XF86AudioPrev'</default>
+ <summary>Previous track</summary>
+ <description>Binding to skip to previous track.</description>
+ </key>
+ <key type="i" name="priority">
+ <default>98</default>
+ <summary>Priority to use for this plugin</summary>
+ <description>Priority to use for this plugin in gnome-settings-daemon startup queue</description>
+ </key>
+ <key type="s" name="screensaver">
+ <default>'&lt;Control&gt;&lt;Alt&gt;l'</default>
+ <summary>Lock screen</summary>
+ <description>Binding to lock the screen.</description>
+ </key>
+ <key type="s" name="search">
+ <default>'XF86Search'</default>
+ <summary>Search</summary>
+ <description>Binding to launch the search tool.</description>
+ </key>
+ <key type="s" name="stop">
+ <default>'XF86AudioStop'</default>
+ <summary>Stop playback</summary>
+ <description>Binding to stop playback.</description>
+ </key>
+ <key type="s" name="volume-down">
+ <default>'XF86AudioLowerVolume'</default>
+ <summary>Volume down</summary>
+ <description>Binding to lower the system volume.</description>
+ </key>
+ <key type="s" name="volume-mute">
+ <default>'XF86AudioMute'</default>
+ <summary>Volume mute</summary>
+ <description>Binding to mute the system volume.</description>
+ </key>
+ <key type="s" name="volume-up">
+ <default>'XF86AudioRaiseVolume'</default>
+ <summary>Volume up</summary>
+ <description>Binding to raise the system volume.</description>
+ </key>
+ <key type="s" name="screenshot">
+ <default>'Print'</default>
+ <summary>Take a screenshot</summary>
+ <description>Binding to take a screenshot.</description>
+ </key>
+ <key type="s" name="window-screenshot">
+ <default>'&lt;Alt&gt;Print'</default>
+ <summary>Take a screenshot of a window</summary>
+ <description>Binding to take a screenshot of a window.</description>
+ </key>
+ <key type="s" name="area-screenshot">
+ <default>'&lt;Shift&gt;Print'</default>
+ <summary>Take a screenshot of an area</summary>
+ <description>Binding to take a screenshot of an area.</description>
+ </key>
+ <key type="s" name="screenshot-clip">
+ <default>'&lt;Ctrl&gt;Print'</default>
+ <summary>Copy a screenshot to clipboard</summary>
+ <description>Binding to copy a screenshot to clipboard.</description>
+ </key>
+ <key type="s" name="window-screenshot-clip">
+ <default>'&lt;Ctrl&gt;&lt;Alt&gt;Print'</default>
+ <summary>Copy a screenshot of a window to clipboard</summary>
+ <description>Binding to copy a screenshot of a window to clipboard.</description>
+ </key>
+ <key type="s" name="area-screenshot-clip">
+ <default>'&lt;Ctrl&gt;&lt;Shift&gt;Print'</default>
+ <summary>Copy a screenshot of an area to clipboard</summary>
+ <description>Binding to copy a screenshot of an area to clipboard.</description>
+ </key>
+ <key type="s" name="terminal">
+ <default>'&lt;Primary&gt;&lt;Alt&gt;t'</default>
+ <summary>Launch terminal</summary>
+ <description>Binding to launch the terminal.</description>
+ </key>
+ <key type="s" name="www">
+ <default>'XF86WWW'</default>
+ <summary>Launch web browser</summary>
+ <description>Binding to launch the web browser.</description>
+ </key>
+ <key type="s" name="magnifier">
+ <default>''</default>
+ <summary>Toggle magnifier</summary>
+ <description>Binding to show the screen magnifier</description>
+ </key>
+ <key type="s" name="screenreader">
+ <default>''</default>
+ <summary>Toggle screen reader</summary>
+ <description>Binding to start the screen reader</description>
+ </key>
+ <key type="s" name="on-screen-keyboard">
+ <default>''</default>
+ <summary>Toggle on-screen keyboard</summary>
+ <description>Binding to show the on-screen keyboard</description>
+ </key>
+ <key type="s" name="increase-text-size">
+ <default>''</default>
+ <summary>Increase text size</summary>
+ <description>Binding to increase the text size</description>
+ </key>
+ <key type="s" name="decrease-text-size">
+ <default>''</default>
+ <summary>Decrease text size</summary>
+ <description>Binding to decrease the text size</description>
+ </key>
+ <key type="s" name="toggle-contrast">
+ <default>''</default>
+ <summary>Toggle contrast</summary>
+ <description>Binding to toggle the interface contrast</description>
+ </key>
+ <key type="s" name="magnifier-zoom-in">
+ <default>''</default>
+ <summary>Magnifier zoom in</summary>
+ <description>Binding for the magnifier to zoom in</description>
+ </key>
+ <key type="s" name="magnifier-zoom-out">
+ <default>''</default>
+ <summary>Magnifier zoom out</summary>
+ <description>Binding for the magnifier to zoom out</description>
+ </key>
+ </schema>
+
+ <schema id="org.gnome.settings-daemon.plugins.media-keys.custom-keybinding" gettext-domain="gnome-settings-daemon">
+ <key type="s" name="name">
+ <default>''</default>
+ <summary>Name</summary>
+ <description>Name of the custom binding</description>
+ </key>
+ <key type="s" name="binding">
+ <default>''</default>
+ <summary>Binding</summary>
+ <description>Binding for the custom binding</description>
+ </key>
+ <key type="s" name="command">
+ <default>''</default>
+ <summary>Command</summary>
+ <description>Command to run when the binding is invoked</description>
+ </key>
+ </schema>
+</schemalist> \ No newline at end of file
diff --git a/tests/test-service.cc b/tests/test-service.cc
index 37ba4a9..4d540d6 100644
--- a/tests/test-service.cc
+++ b/tests/test-service.cc
@@ -17,39 +17,130 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gtest-dbus-helper.h"
+#include <glib-object.h>
+#include <gio/gio.h>
+#include <glib.h>
+
+#include <gtest/gtest.h>
+
#include "shared-names.h"
/***
****
***/
-/**
- * Fixture class for testing indicator-session-service with Google Test.
- */
-class SessionServiceTest: public IndicatorServiceTest
+#define INDICATOR_SERVICE_OBJECT_PATH "/org/ayatana/indicator/service"
+#define INDICATOR_SERVICE_INTERFACE_NAME "org.ayatana.indicator.service"
+
+class ClientTest : public ::testing::Test
{
- public:
- virtual ~SessionServiceTest() {}
- SessionServiceTest(): IndicatorServiceTest(INDICATOR_SESSION_DBUS_NAME,
- INDICATOR_SESSION_DBUS_OBJECT,
- INDICATOR_SERVICE_PATH) { }
- public:
- virtual void SetUp() {
- wait_seconds(1);
- IndicatorServiceTest::SetUp();
+ protected:
+
+ GTestDBus * test_dbus;
+ GDBusConnection * session_bus;
+ GMainLoop * main_loop;
+
+ virtual void SetUp()
+ {
+ test_dbus = NULL;
+ session_bus = NULL;
+ main_loop = NULL;
+
+ static bool first_run = true;
+ if (first_run)
+ {
+ g_type_init();
+ g_setenv ("INDICATOR_SERVICE_SHUTDOWN_TIMEOUT", "1000", TRUE);
+ g_unsetenv ("INDICATOR_ALLOW_NO_WATCHERS");
+ g_unsetenv ("INDICATOR_SERVICE_REPLACE_MODE");
+ g_setenv ("GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, TRUE);
+ g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
+ first_run = false;
+ }
+
+ main_loop = g_main_loop_new (NULL, FALSE);
+ // pull up a test dbus that's pointed at our test .service file
+ test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
+ g_debug (G_STRLOC" service dir path is \"%s\"", INDICATOR_SERVICE_DIR);
+ g_test_dbus_add_service_dir (test_dbus, INDICATOR_SERVICE_DIR);
+
+ // allow the service to exist w/o a sync indicator
+ g_setenv ("INDICATOR_ALLOW_NO_WATCHERS", "1", TRUE);
+
+ g_test_dbus_up (test_dbus);
+ g_debug (G_STRLOC" this test bus' address is \"%s\"", g_test_dbus_get_bus_address(test_dbus));
+ session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+ g_debug (G_STRLOC" the dbus connection %p unique name is \"%s\"", session_bus, g_dbus_connection_get_unique_name(session_bus));
+ g_debug (G_STRLOC" the dbus connection %p refcount is %d", session_bus, G_OBJECT(session_bus)->ref_count);
}
- virtual void TearDown() {
- IndicatorServiceTest::TearDown();
+
+ // undo SetUp
+ virtual void TearDown()
+ {
+ g_clear_object (&session_bus);
+ g_debug (G_STRLOC" tearing down the bus");
+ g_test_dbus_down (test_dbus);
+ g_clear_object (&test_dbus);
+ g_clear_pointer (&main_loop, g_main_loop_unref);
}
};
+/***
+****
+***/
/**
- * Basic sanity test to see if we can account for all our menuitems.
+ * This is a basic test to see if we can launch indicator-session-service
+ * and call its "GetUserRealName" method. The test succeeds if we can launch
+ * the service, call the method, and get response that equals g_get_real_name().
+ *
+ * (You may be wondering why GetUserRealName() exists at all, instead of clients
+ * using g_get_real_name(). It's because the former updates itslef when the user
+ * edits his real name, while the latter returns its cached copy of the old name.)
*/
-TEST_F(SessionServiceTest, HelloWorld)
+TEST_F (ClientTest, TestCanStartService)
{
- ASSERT_TRUE(true);
-}
+ GError * error;
+ GVariant * result;
+ const gchar * name;
+
+ // call GetUserRealName(), which as a side effect should activate
+ // indicator-session-service via the .service file in the tests/ directory
+ error = NULL;
+ result = g_dbus_connection_call_sync (session_bus,
+ INDICATOR_SESSION_DBUS_NAME,
+ INDICATOR_SESSION_SERVICE_DBUS_OBJECT,
+ INDICATOR_SESSION_SERVICE_DBUS_IFACE,
+ "GetUserRealName",
+ NULL,
+ G_VARIANT_TYPE("(s)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ EXPECT_TRUE (error == NULL);
+ ASSERT_TRUE (result != NULL);
+
+ if (error != NULL)
+ {
+ g_warning ("GetUserRealName failed: %s", error->message);
+ g_clear_error (&error);
+ }
+
+ name = NULL;
+ g_variant_get (result, "(&s)", &name);
+ ASSERT_STREQ (g_get_real_name(), name);
+ g_clear_pointer (&result, g_variant_unref);
+
+ // call IndicatorService's Shutdown() method for a clean exit
+ result = g_dbus_connection_call_sync (session_bus,
+ INDICATOR_SESSION_DBUS_NAME,
+ "/org/ayatana/indicator/service",
+ "org.ayatana.indicator.service",
+ "Shutdown", NULL,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, NULL);
+ g_clear_pointer (&result, g_variant_unref);
+}