test: Add test-push-notification script

This commit is contained in:
Denis Kenzior 2010-11-02 10:52:30 -05:00
parent 348bdb7f1d
commit 7f4a14cafe
2 changed files with 49 additions and 1 deletions

View 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

47
test/test-push-notification Executable file
View File

@ -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()