From 7f4a14cafe750fd18f7f9ac0282ad34b57881f3a Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 2 Nov 2010 10:52:30 -0500 Subject: [PATCH] test: Add test-push-notification script --- Makefile.am | 3 ++- test/test-push-notification | 47 +++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100755 test/test-push-notification diff --git a/Makefile.am b/Makefile.am index a9ea953f..6839c36e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -416,7 +416,8 @@ test_scripts = test/backtrace \ test/enable-gprs \ test/disable-gprs \ test/get-icon \ - test/set-fast-dormancy + test/set-fast-dormancy \ + test/test-push-notification if TEST testdir = $(pkglibdir)/test diff --git a/test/test-push-notification b/test/test-push-notification new file mode 100755 index 00000000..4dca0d46 --- /dev/null +++ b/test/test-push-notification @@ -0,0 +1,47 @@ +#!/usr/bin/python + +import gobject + +import sys +import dbus +import dbus.service +import dbus.mainloop.glib + +class PushNotificationAgent(dbus.service.Object): + @dbus.service.method("org.ofono.PushNotificationAgent", + in_signature="", out_signature="") + def Release(self): + print "Release" + mainloop.quit() + + @dbus.service.method("org.ofono.PushNotificationAgent", + in_signature="aya{sv}", out_signature="") + def ReceiveNotification(self, data, props): + for key in props.keys(): + print "Key: %s, Value: %s" % (key, props[key]) + + print "Received notification of size: %d" % len(data) + +if __name__ == '__main__': + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + + bus = dbus.SystemBus() + manager = dbus.Interface(bus.get_object("org.ofono", "/"), + "org.ofono.Manager") + + modems = manager.GetModems() + + for path, properties in modems: + if "org.ofono.PushNotification" not in properties["Interfaces"]: + continue + + pn = dbus.Interface(bus.get_object('org.ofono', path), + 'org.ofono.PushNotification') + + path = "/test/agent" + agent = PushNotificationAgent(bus, path) + pn.RegisterAgent(path) + print "Agent registered" + + mainloop = gobject.MainLoop() + mainloop.run()