Merge lp:~larsu/indicator-messages/notify-stopped-running into lp:~indicator-applet-developers/indicator-messages/trunk.13.10

Proposed by Lars Karlitski
Status: Merged
Approved by: Ted Gould
Approved revision: 343
Merged at revision: 348
Proposed branch: lp:~larsu/indicator-messages/notify-stopped-running
Merge into: lp:~indicator-applet-developers/indicator-messages/trunk.13.10
Diff against target: 288 lines (+183/-6)
9 files modified
configure.ac (+12/-6)
debian/control (+1/-0)
libmessaging-menu/messaging-menu.c (+4/-0)
m4/ax_python_module.m4 (+49/-0)
src/messages-service.c (+25/-0)
src/messages-service.xml (+4/-0)
test/Makefile.am (+11/-0)
test/applications/test.desktop (+2/-0)
test/test-client.py (+75/-0)
To merge this branch: bzr merge lp:~larsu/indicator-messages/notify-stopped-running
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Ted Gould (community) Approve
Mathieu Trudel-Lapierre Pending
Review via email: mp+168202@code.launchpad.net

This proposal supersedes a proposal from 2013-06-07.

Commit message

Notify the service when an app unrefs its MessagingMenuApp

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote : Posted in a previous version of this proposal

Can we add some kind of automated test for this?

review: Needs Information
Revision history for this message
Lars Karlitski (larsu) wrote : Posted in a previous version of this proposal

You're right of course. I didn't add them originally because the client lib wasn't tested at all.

Added testing for registration in r338.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote : Posted in a previous version of this proposal

Look fine, however both autoconf-archive and python3-dbusmock are in universe and are going to need to get to main for indicator-messages to be buildable once released with this changeset.

Can you please follow the steps in the wiki for the Main Inclusion Process and file the appropriate two bugs for this?

https://wiki.ubuntu.com/MainInclusionProcess

review: Needs Information
Revision history for this message
Ted Gould (ted) wrote :

Looks like Mathieu's issues have been solved with dbusmock getting into main and autoconf-archive being removed.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
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 2013-01-22 20:30:05 +0000
+++ configure.ac 2013-06-07 21:40:41 +0000
@@ -75,7 +75,7 @@
75AC_SUBST(COVERAGE_LDFLAGS)75AC_SUBST(COVERAGE_LDFLAGS)
7676
77###########################77###########################
78# Google Test framework78# Tests
79###########################79###########################
8080
81AC_ARG_ENABLE([tests],81AC_ARG_ENABLE([tests],
@@ -85,10 +85,16 @@
85if test "x$enable_tests" != "xno"; then85if test "x$enable_tests" != "xno"; then
86 m4_include([m4/gtest.m4])86 m4_include([m4/gtest.m4])
87 CHECK_GTEST87 CHECK_GTEST
88 if test "x$enable_tests" = "xauto"; then88 AM_PATH_PYTHON(3.0,, [:])
89 enable_tests=${have_gtest}89 AC_PYTHON_MODULE(dbusmock)
90 elif test "x$enable_tests" = "xyes" && test "x$have_gtest" != "xyes"; then90 if test "x$have_gtest" = "xyes" -a "x$HAVE_PYMOD_DBUSMOCK" = "xyes"; then
91 AC_MSG_ERROR([tests were requested but gtest is not installed.])91 enable_tests="yes"
92 else
93 if test "x$enable_tests" = "xyes"; then
94 AC_MSG_ERROR([tests were requested but gtest or dbusmock are not installed.])
95 else
96 enable_tests="no"
97 fi
92 fi98 fi
93fi99fi
94AM_CONDITIONAL([BUILD_TESTS],[test "x$enable_tests" = "xyes"])100AM_CONDITIONAL([BUILD_TESTS],[test "x$enable_tests" = "xyes"])
@@ -193,7 +199,7 @@
193199
194 Prefix: $prefix200 Prefix: $prefix
195 Indicator Dir: $INDICATORDIR201 Indicator Dir: $INDICATORDIR
196 gtest: $enable_tests202 tests: $enable_tests
197 gcov: $use_gcov203 gcov: $use_gcov
198 introspecion: $enable_introspection204 introspecion: $enable_introspection
199 documentation: $enable_gtk_doc205 documentation: $enable_gtk_doc
200206
=== modified file 'debian/control'
--- debian/control 2013-06-07 12:19:11 +0000
+++ debian/control 2013-06-07 21:40:41 +0000
@@ -19,6 +19,7 @@
19 libgirepository1.0-dev (>= 0.9.12),19 libgirepository1.0-dev (>= 0.9.12),
20 gtk-doc-tools,20 gtk-doc-tools,
21 libgtest-dev,21 libgtest-dev,
22 python3-dbusmock,
22Standards-Version: 3.9.323Standards-Version: 3.9.3
23Homepage: https://launchpad.net/indicator-messages24Homepage: https://launchpad.net/indicator-messages
24# If you aren't a member of ~indicator-applet-developers but need to upload25# If you aren't a member of ~indicator-applet-developers but need to upload
2526
=== modified file 'libmessaging-menu/messaging-menu.c'
--- libmessaging-menu/messaging-menu.c 2013-05-15 16:09:18 +0000
+++ libmessaging-menu/messaging-menu.c 2013-06-07 21:40:41 +0000
@@ -277,6 +277,10 @@
277277
278 if (app->messages_service)278 if (app->messages_service)
279 {279 {
280 indicator_messages_service_call_application_stopped_running (app->messages_service,
281 g_app_info_get_id (G_APP_INFO (app->appinfo)),
282 NULL, NULL, NULL);
283
280 g_signal_handlers_disconnect_by_func (app->messages_service,284 g_signal_handlers_disconnect_by_func (app->messages_service,
281 global_status_changed,285 global_status_changed,
282 app);286 app);
283287
=== added file 'm4/ax_python_module.m4'
--- m4/ax_python_module.m4 1970-01-01 00:00:00 +0000
+++ m4/ax_python_module.m4 2013-06-07 21:40:41 +0000
@@ -0,0 +1,49 @@
1# ===========================================================================
2# http://www.gnu.org/software/autoconf-archive/ax_python_module.html
3# ===========================================================================
4#
5# SYNOPSIS
6#
7# AX_PYTHON_MODULE(modname[, fatal])
8#
9# DESCRIPTION
10#
11# Checks for Python module.
12#
13# If fatal is non-empty then absence of a module will trigger an error.
14#
15# LICENSE
16#
17# Copyright (c) 2008 Andrew Collier <colliera@ukzn.ac.za>
18#
19# Copying and distribution of this file, with or without modification, are
20# permitted in any medium without royalty provided the copyright notice
21# and this notice are preserved. This file is offered as-is, without any
22# warranty.
23
24#serial 5
25
26AU_ALIAS([AC_PYTHON_MODULE], [AX_PYTHON_MODULE])
27AC_DEFUN([AX_PYTHON_MODULE],[
28 if test -z $PYTHON;
29 then
30 PYTHON="python"
31 fi
32 PYTHON_NAME=`basename $PYTHON`
33 AC_MSG_CHECKING($PYTHON_NAME module: $1)
34 $PYTHON -c "import $1" 2>/dev/null
35 if test $? -eq 0;
36 then
37 AC_MSG_RESULT(yes)
38 eval AS_TR_CPP(HAVE_PYMOD_$1)=yes
39 else
40 AC_MSG_RESULT(no)
41 eval AS_TR_CPP(HAVE_PYMOD_$1)=no
42 #
43 if test -n "$2"
44 then
45 AC_MSG_ERROR(failed to find required module $1)
46 exit 1
47 fi
48 fi
49])
050
=== modified file 'src/messages-service.c'
--- src/messages-service.c 2013-04-03 15:40:56 +0000
+++ src/messages-service.c 2013-06-07 21:40:41 +0000
@@ -474,6 +474,29 @@
474}474}
475475
476static void476static void
477application_stopped_running (IndicatorMessagesService *service,
478 GDBusMethodInvocation *invocation,
479 const gchar *desktop_id,
480 gpointer user_data)
481{
482 GDesktopAppInfo *appinfo;
483 gchar *id;
484 AppSection *section;
485
486 indicator_messages_service_complete_application_stopped_running (service, invocation);
487
488 if (!(appinfo = g_desktop_app_info_new (desktop_id)))
489 return;
490
491 id = g_app_info_get_simple_id (G_APP_INFO (appinfo));
492 section = g_hash_table_lookup (applications, id);
493 app_section_unset_object_path (section);
494
495 g_free (id);
496 g_object_unref (appinfo);
497}
498
499static void
477set_status (IndicatorMessagesService *service,500set_status (IndicatorMessagesService *service,
478 GDBusMethodInvocation *invocation,501 GDBusMethodInvocation *invocation,
479 const gchar *desktop_id,502 const gchar *desktop_id,
@@ -650,6 +673,8 @@
650 G_CALLBACK (register_application), NULL);673 G_CALLBACK (register_application), NULL);
651 g_signal_connect (messages_service, "handle-unregister-application",674 g_signal_connect (messages_service, "handle-unregister-application",
652 G_CALLBACK (unregister_application), NULL);675 G_CALLBACK (unregister_application), NULL);
676 g_signal_connect (messages_service, "handle-application-stopped-running",
677 G_CALLBACK (application_stopped_running), NULL);
653 g_signal_connect (messages_service, "handle-set-status",678 g_signal_connect (messages_service, "handle-set-status",
654 G_CALLBACK (set_status), NULL);679 G_CALLBACK (set_status), NULL);
655680
656681
=== modified file 'src/messages-service.xml'
--- src/messages-service.xml 2012-09-18 19:54:37 +0000
+++ src/messages-service.xml 2013-06-07 21:40:41 +0000
@@ -11,6 +11,10 @@
11 <arg type="s" name="desktop_id" direction="in" />11 <arg type="s" name="desktop_id" direction="in" />
12 </method>12 </method>
1313
14 <method name="ApplicationStoppedRunning">
15 <arg type="s" name="desktop_id" direction="in" />
16 </method>
17
14 <method name="SetStatus">18 <method name="SetStatus">
15 <arg type="s" name="desktop_id" direction="in" />19 <arg type="s" name="desktop_id" direction="in" />
16 <arg type="s" name="status" direction="in" />20 <arg type="s" name="status" direction="in" />
1721
=== modified file 'test/Makefile.am'
--- test/Makefile.am 2012-08-21 10:07:19 +0000
+++ test/Makefile.am 2013-06-07 21:40:41 +0000
@@ -65,3 +65,14 @@
6565
66libindicator_messages_service_la_LDFLAGS = \66libindicator_messages_service_la_LDFLAGS = \
67 $(COVERAGE_LDFLAGS)67 $(COVERAGE_LDFLAGS)
68
69######################################
70# Test client with dbusmock
71######################################
72
73TESTS_ENVIRONMENT = \
74 export LD_LIBRARY_PATH=$(top_builddir)/libmessaging-menu/.libs; \
75 export GI_TYPELIB_PATH=$(top_builddir)/libmessaging-menu; \
76 export XDG_DATA_DIRS=$(abs_srcdir);
77
78TESTS += test-client.py
6879
=== added directory 'test/applications'
=== added file 'test/applications/test.desktop'
--- test/applications/test.desktop 1970-01-01 00:00:00 +0000
+++ test/applications/test.desktop 2013-06-07 21:40:41 +0000
@@ -0,0 +1,2 @@
1[Desktop Entry]
2Type=Application
03
=== added file 'test/test-client.py'
--- test/test-client.py 1970-01-01 00:00:00 +0000
+++ test/test-client.py 2013-06-07 21:40:41 +0000
@@ -0,0 +1,75 @@
1#!/usr/bin/env python3
2
3import unittest
4import dbus
5from dbus.mainloop.glib import DBusGMainLoop
6import dbusmock
7import subprocess
8from gi.repository import GLib, Gio, MessagingMenu
9
10DBusGMainLoop(set_as_default=True)
11
12class MessagingMenuTest(dbusmock.DBusTestCase):
13 @classmethod
14 def setUpClass(klass):
15 klass.start_session_bus()
16 klass.bus = klass.get_dbus(False)
17
18 def setUp(self):
19 name = 'com.canonical.indicator.messages'
20 obj_path = '/com/canonical/indicator/messages/service'
21 iface = 'com.canonical.indicator.messages.service'
22
23 self.messaging_service = self.spawn_server(name, obj_path, iface, stdout=subprocess.PIPE)
24 self.mock = dbus.Interface(self.bus.get_object(name, obj_path), dbusmock.MOCK_IFACE)
25 self.mock.AddMethod('', 'RegisterApplication', 'so', '', '')
26 self.mock.AddMethod('', 'UnregisterApplication', 's', '', '')
27 self.mock.AddMethod('', 'ApplicationStoppedRunning', 's', '', '')
28 self.mock.AddMethod('', 'SetStatus', 'ss', '', '')
29
30 self.loop = GLib.MainLoop()
31
32 def tearDown(self):
33 self.messaging_service.terminate()
34 self.messaging_service.wait()
35
36 def assertArgumentsEqual(self, args, *expected_args):
37 self.assertEqual(len(args), len(expected_args))
38 for i in range(len(args)):
39 if expected_args[i]:
40 self.assertEqual(args[i], expected_args[i])
41
42 def assertMethodCalled(self, name, *expected_args):
43 # set a flag on timeout, assertions don't get bubbled up through c functions
44 self.timed_out = False
45 def timeout(): self.timed_out = True
46 timeout_id = GLib.timeout_add_seconds(10, timeout)
47 while 1:
48 calls = self.mock.GetMethodCalls(name)
49 if len(calls) > 0:
50 GLib.source_remove(timeout_id)
51 self.assertArgumentsEqual(calls[0][1], *expected_args)
52 break
53 GLib.MainContext.default().iteration(True)
54 if self.timed_out:
55 raise self.failureException('method %s was not called after 10 seconds' % name)
56
57 def test_registration(self):
58 mmapp = MessagingMenu.App.new('test.desktop')
59 mmapp.register()
60 self.assertMethodCalled('RegisterApplication', 'test.desktop', None)
61
62 mmapp.unregister()
63 self.assertMethodCalled('UnregisterApplication', 'test.desktop')
64
65 # ApplicationStoppedRunning is called when the last ref on mmapp is dropped
66 del mmapp
67 self.assertMethodCalled('ApplicationStoppedRunning', 'test.desktop')
68
69 def test_status(self):
70 mmapp = MessagingMenu.App.new('test.desktop')
71 mmapp.register()
72 mmapp.set_status(MessagingMenu.Status.AWAY)
73 self.assertMethodCalled('SetStatus', 'test.desktop', 'away')
74
75unittest.main(testRunner=unittest.TextTestRunner())

Subscribers

People subscribed via source and target branches