From 452605811f41f580edae53e80c3a6881b0bd5996 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 22 Jan 2013 14:30:05 -0600 Subject: add glib requirement to debian/control. bump glib requirement in configure.ac --- debian/control | 1 + 1 file changed, 1 insertion(+) (limited to 'debian/control') diff --git a/debian/control b/debian/control index 546b5c9..31292c5 100644 --- a/debian/control +++ b/debian/control @@ -7,6 +7,7 @@ Uploaders: Evgeni Golov Build-Depends: debhelper (>= 9), dh-autoreconf, dh-translations, + libglib2.0-dev (>= 2.35.4), libgtk-3-dev (>= 3.5.12), libdbus-glib-1-dev, intltool, -- cgit v1.2.3 From 5c47f6dbe75e413d2acbcef3e9750e937fb18431 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Mon, 25 Feb 2013 19:34:56 -0500 Subject: Test libmessaging-menu Use dbusmock to test whether libmessaging-menu calls the right functions on registration and deregistration. --- configure.ac | 18 +++++++++----- debian/control | 1 + test/Makefile.am | 10 ++++++++ test/test-client.py | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 6 deletions(-) create mode 100755 test/test-client.py (limited to 'debian/control') diff --git a/configure.ac b/configure.ac index bcd7b20..08ac680 100644 --- a/configure.ac +++ b/configure.ac @@ -75,7 +75,7 @@ AC_SUBST(COVERAGE_CXXFLAGS) AC_SUBST(COVERAGE_LDFLAGS) ########################### -# Google Test framework +# Tests ########################### AC_ARG_ENABLE([tests], @@ -85,10 +85,16 @@ AC_ARG_ENABLE([tests], if test "x$enable_tests" != "xno"; then m4_include([m4/gtest.m4]) CHECK_GTEST - if test "x$enable_tests" = "xauto"; then - enable_tests=${have_gtest} - elif test "x$enable_tests" = "xyes" && test "x$have_gtest" != "xyes"; then - AC_MSG_ERROR([tests were requested but gtest is not installed.]) + AM_PATH_PYTHON(3.0,, [:]) + AC_PYTHON_MODULE(dbusmock) + if test "x$have_gtest" = "xyes" -a "x$HAVE_PYMOD_DBUSMOCK" = "xyes"; then + enable_tests="yes" + else + if test "x$enable_tests" = "xyes"; then + AC_MSG_ERROR([tests were requested but gtest or dbusmock are not installed.]) + else + enable_tests="no" + fi fi fi AM_CONDITIONAL([BUILD_TESTS],[test "x$enable_tests" = "xyes"]) @@ -193,7 +199,7 @@ Messaging Indicator Configuration: Prefix: $prefix Indicator Dir: $INDICATORDIR - gtest: $enable_tests + tests: $enable_tests gcov: $use_gcov introspecion: $enable_introspection documentation: $enable_gtk_doc diff --git a/debian/control b/debian/control index 31292c5..efc21cd 100644 --- a/debian/control +++ b/debian/control @@ -19,6 +19,7 @@ Build-Depends: debhelper (>= 9), libgirepository1.0-dev (>= 0.9.12), gtk-doc-tools, libgtest-dev, + python3-dbusmock, Standards-Version: 3.9.3 Homepage: https://launchpad.net/indicator-messages # If you aren't a member of ~indicator-applet-developers but need to upload diff --git a/test/Makefile.am b/test/Makefile.am index 4671446..87ae2c3 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -65,3 +65,13 @@ libindicator_messages_service_la_LIBADD = \ libindicator_messages_service_la_LDFLAGS = \ $(COVERAGE_LDFLAGS) + +###################################### +# Test client with dbusmock +###################################### + +TESTS_ENVIRONMENT = \ + export LD_LIBRARY_PATH=$(top_builddir)/libmessaging-menu/.libs; \ + export GI_TYPELIB_PATH=$(top_builddir)/libmessaging-menu; + +TESTS += test-client.py diff --git a/test/test-client.py b/test/test-client.py new file mode 100755 index 0000000..e012d6e --- /dev/null +++ b/test/test-client.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 + +import unittest +import dbus +import dbusmock +import subprocess +from gi.repository import GLib, Gio, MessagingMenu + +class MessagingMenuTest(dbusmock.DBusTestCase): + @classmethod + def setUpClass(klass): + klass.start_session_bus() + klass.bus = klass.get_dbus(False) + + def setUp(self): + name = 'com.canonical.indicator.messages' + obj_path = '/com/canonical/indicator/messages/service' + iface = 'com.canonical.indicator.messages.service' + + self.messaging_service = self.spawn_server(name, obj_path, iface, stdout=subprocess.PIPE) + self.mock = dbus.Interface(self.bus.get_object(name, obj_path), dbusmock.MOCK_IFACE) + self.mock.AddMethod('', 'RegisterApplication', 'so', '', '') + self.mock.AddMethod('', 'UnregisterApplication', 's', '', '') + self.mock.AddMethod('', 'ApplicationStoppedRunning', 's', '', '') + self.mock.AddMethod('', 'SetStatus', 'ss', '', '') + + self.loop = GLib.MainLoop() + + def tearDown(self): + self.messaging_service.terminate() + self.messaging_service.wait() + + def spin_loop(self, ms=10): + GLib.timeout_add(ms, lambda: self.loop.quit()) + self.loop.run() + + def assertMethodCalled(self, name, *expected_args): + calls = self.mock.GetMethodCalls(name) + self.assertEqual(len(calls), 1, 'method %s was not called' % name) + args = calls[0][1] + self.assertEqual(len(args), len(expected_args)) + for i in range(len(args)): + if expected_args[i]: + self.assertEqual(args[i], expected_args[i]) + + def test_registration(self): + mmapp = MessagingMenu.App.new('empathy.desktop') + mmapp.register() + self.spin_loop() + self.assertMethodCalled('RegisterApplication', 'empathy.desktop', None) + + mmapp.unregister() + self.spin_loop() + self.assertMethodCalled('UnregisterApplication', 'empathy.desktop') + + # ApplicationStoppedRunning is called when the last ref on mmapp is dropped + del mmapp + self.spin_loop() + self.assertMethodCalled('ApplicationStoppedRunning', 'empathy.desktop') + + def test_status(self): + mmapp = MessagingMenu.App.new('empathy.desktop') + mmapp.register() + mmapp.set_status(MessagingMenu.Status.AWAY) + self.spin_loop() + self.assertMethodCalled('SetStatus', 'empathy.desktop', 'away') + +unittest.main(testRunner=unittest.TextTestRunner()) -- cgit v1.2.3 From d98feb7174b8b66059bce11abe5d2c0fb5c418cb Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Tue, 26 Feb 2013 15:17:56 -0500 Subject: debian/control: add autoconf-archive as an explicit build dep Needed for AC_PYTHON_MODULE --- debian/control | 1 + 1 file changed, 1 insertion(+) (limited to 'debian/control') diff --git a/debian/control b/debian/control index efc21cd..c0a8290 100644 --- a/debian/control +++ b/debian/control @@ -20,6 +20,7 @@ Build-Depends: debhelper (>= 9), gtk-doc-tools, libgtest-dev, python3-dbusmock, + autoconf-archive, Standards-Version: 3.9.3 Homepage: https://launchpad.net/indicator-messages # If you aren't a member of ~indicator-applet-developers but need to upload -- cgit v1.2.3 From 7af3c34b4fc7642585a77f97e5605463b7e1c99c Mon Sep 17 00:00:00 2001 From: Jeremy Bicha Date: Fri, 7 Jun 2013 08:19:11 -0400 Subject: Have libmessaging-menu-dev depend on gir1.2-messagingmenu-1.0 --- debian/control | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'debian/control') diff --git a/debian/control b/debian/control index 31292c5..e44b405 100644 --- a/debian/control +++ b/debian/control @@ -68,6 +68,7 @@ Architecture: any Section: libdevel Depends: ${shlibs:Depends}, ${misc:Depends}, + gir1.2-messagingmenu-1.0 (=${binary:Version}), libmessaging-menu0 (=${binary:Version}), libglib2.0-dev, Description: Messaging Menu - library development files @@ -75,7 +76,7 @@ Description: Messaging Menu - library development files the messaging menu. Package: gir1.2-messagingmenu-1.0 -Section: libs +Section: introspection Architecture: any Depends: ${misc:Depends}, ${gir:Depends}, -- cgit v1.2.3 From 014158fd7f63b25840bbcecc92e9ec3f42a7002c Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 7 Jun 2013 17:35:39 -0400 Subject: Remove autoconf-archive dependency (copied ax_python_module into m4/) --- debian/control | 1 - m4/ax_python_module.m4 | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 m4/ax_python_module.m4 (limited to 'debian/control') diff --git a/debian/control b/debian/control index c0a8290..efc21cd 100644 --- a/debian/control +++ b/debian/control @@ -20,7 +20,6 @@ Build-Depends: debhelper (>= 9), gtk-doc-tools, libgtest-dev, python3-dbusmock, - autoconf-archive, Standards-Version: 3.9.3 Homepage: https://launchpad.net/indicator-messages # If you aren't a member of ~indicator-applet-developers but need to upload diff --git a/m4/ax_python_module.m4 b/m4/ax_python_module.m4 new file mode 100644 index 0000000..bd70a06 --- /dev/null +++ b/m4/ax_python_module.m4 @@ -0,0 +1,49 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_python_module.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PYTHON_MODULE(modname[, fatal]) +# +# DESCRIPTION +# +# Checks for Python module. +# +# If fatal is non-empty then absence of a module will trigger an error. +# +# LICENSE +# +# Copyright (c) 2008 Andrew Collier +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 5 + +AU_ALIAS([AC_PYTHON_MODULE], [AX_PYTHON_MODULE]) +AC_DEFUN([AX_PYTHON_MODULE],[ + if test -z $PYTHON; + then + PYTHON="python" + fi + PYTHON_NAME=`basename $PYTHON` + AC_MSG_CHECKING($PYTHON_NAME module: $1) + $PYTHON -c "import $1" 2>/dev/null + if test $? -eq 0; + then + AC_MSG_RESULT(yes) + eval AS_TR_CPP(HAVE_PYMOD_$1)=yes + else + AC_MSG_RESULT(no) + eval AS_TR_CPP(HAVE_PYMOD_$1)=no + # + if test -n "$2" + then + AC_MSG_ERROR(failed to find required module $1) + exit 1 + fi + fi +]) -- cgit v1.2.3