From e6d5bb0209c9cba4d42f12a448bd708a2cabaa9f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 3 May 2007 12:11:31 +0100 Subject: dbus/gobject_service.py: Make ExportedGObject work correctly. Also add a simple unit test for it. --- test/test-client.py | 10 ++++++++++ test/test-service.py | 11 +++++++++++ 2 files changed, 21 insertions(+) (limited to 'test') diff --git a/test/test-client.py b/test/test-client.py index b9d2242..04706df 100755 --- a/test/test-client.py +++ b/test/test-client.py @@ -70,6 +70,16 @@ class TestDBusBindings(unittest.TestCase): self.remote_object = self.bus.get_object(NAME, OBJECT) self.iface = dbus.Interface(self.remote_object, IFACE) + def testGObject(self): + print "Testing ExportedGObject... ", + remote_gobject = self.bus.get_object(NAME, OBJECT + '/GObject') + iface = dbus.Interface(remote_gobject, IFACE) + print "introspection, ", + remote_gobject.Introspect(dbus_interface=dbus.INTROSPECTABLE_IFACE) + print "method call, ", + self.assertEquals(iface.Echo('123'), '123') + print "... OK" + def testWeakRefs(self): # regression test for Sugar crash caused by smcv getting weak refs # wrong - pre-bugfix, this would segfault diff --git a/test/test-service.py b/test/test-service.py index 6c6880a..2ef1e22 100755 --- a/test/test-service.py +++ b/test/test-service.py @@ -36,6 +36,8 @@ import dbus.glib import gobject import random +from dbus.gobject_service import ExportedGObject + logging.basicConfig(filename=builddir + '/test/test-service.log', filemode='w') logging.getLogger().setLevel(1) @@ -46,6 +48,14 @@ NAME = "org.freedesktop.DBus.TestSuitePythonService" IFACE = "org.freedesktop.DBus.TestSuiteInterface" OBJECT = "/org/freedesktop/DBus/TestSuitePythonObject" +class TestGObject(ExportedGObject): + def __init__(self, bus_name, object_path=OBJECT + '/GObject'): + super(TestGObject, self).__init__(bus_name, object_path) + + @dbus.service.method(IFACE) + def Echo(self, arg): + return arg + class TestInterface(dbus.service.Interface): @dbus.service.method(IFACE, in_signature='', out_signature='b') def CheckInheritance(self): @@ -200,5 +210,6 @@ class TestObject(dbus.service.Object, TestInterface): session_bus = dbus.SessionBus() name = dbus.service.BusName(NAME, bus=session_bus) object = TestObject(name) +g_object = TestGObject(name) loop = gobject.MainLoop() loop.run() -- cgit v1.2.1