test: Add test-push-notification script
authorDenis Kenzior <denkenz@gmail.com>
Tue, 2 Nov 2010 15:52:30 +0000 (10:52 -0500)
committerDenis Kenzior <denkenz@gmail.com>
Tue, 2 Nov 2010 19:58:18 +0000 (14:58 -0500)
Makefile.am
test/test-push-notification [new file with mode: 0755]

index a9ea953..6839c36 100644 (file)
@@ -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 (executable)
index 0000000..4dca0d4
--- /dev/null
@@ -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()