diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-05-03 12:11:31 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-05-03 12:11:31 +0100 |
commit | e6d5bb0209c9cba4d42f12a448bd708a2cabaa9f (patch) | |
tree | d4f668bf5d2082576a651186cc15156fca62709e /test | |
parent | 717837a91498f9f928a0affbfa39d8cd68de5ca1 (diff) | |
download | dbus-python-e6d5bb0209c9cba4d42f12a448bd708a2cabaa9f.tar.gz |
dbus/gobject_service.py: Make ExportedGObject work correctly.
Also add a simple unit test for it.
Diffstat (limited to 'test')
-rwxr-xr-x | test/test-client.py | 10 | ||||
-rwxr-xr-x | test/test-service.py | 11 |
2 files changed, 21 insertions, 0 deletions
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() |