From e175760bda2945b781e3d2dc5ca8315ced9c6c8e Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Fri, 20 Aug 2010 13:14:06 +0200 Subject: test: Rename script for testing STK menus --- test/simple-agent | 169 ----------------------------------------------------- test/test-stk-menu | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 169 insertions(+), 169 deletions(-) delete mode 100755 test/simple-agent create mode 100755 test/test-stk-menu (limited to 'test') diff --git a/test/simple-agent b/test/simple-agent deleted file mode 100755 index a342b1f7..00000000 --- a/test/simple-agent +++ /dev/null @@ -1,169 +0,0 @@ -#!/usr/bin/python - -import gobject - -import sys -import dbus -import dbus.service -import dbus.mainloop.glib - -class GoBack(dbus.DBusException): - _dbus_error_name = "org.ofono.Error.GoBack" - -class EndSession(dbus.DBusException): - _dbus_error_name = "org.ofono.Error.EndSession" - -class StkAgent(dbus.service.Object): - exit_on_release = True - - def set_exit_on_release(self, exit_on_release): - self.exit_on_release = exit_on_release - - @dbus.service.method("org.ofono.SimToolkitAgent", - in_signature="", out_signature="") - def Release(self): - print "Release" - if self.exit_on_release: - mainloop.quit() - - @dbus.service.method("org.ofono.SimToolkitAgent", - in_signature="sya(sy)y", out_signature="y") - def RequestSelection(self, title, icon, items, default): - print "Title: (%s)" % (title) - index = 0; - for item in items: - print "%d. %s" % (index, item[0]) - index += 1 - - print "\nDefault: %d" % (default) - select = raw_input("Enter Selection (t, b):") - - if select == 'b': - raise GoBack("User wishes to go back") - elif select == 't': - raise EndSession("User wishes to terminate session") - else: - return int(select); - - @dbus.service.method("org.ofono.SimToolkitAgent", - in_signature="syb", out_signature="") - def DisplayText(self, title, icon, urgent): - print "DisplayText (%s, %s)" % (title, urgent) - - @dbus.service.method("org.ofono.SimToolkitAgent", - in_signature="sysyyb", out_signature="s") - def RequestInput(self, title, icon, default, min_chars, max_chars, - hide_typing): - print "Title: (%s)" % (title) - print "Default: (%s)" % (default) - print "Enter characters, min: %d, max: %d:" % (min_chars, - max_chars) - userin = raw_input(""); - - return userin - - @dbus.service.method("org.ofono.SimToolkitAgent", - in_signature="sysyyb", out_signature="s") - def RequestDigits(self, title, icon, default, min_chars, max_chars, - hide_typing): - print "Title: (%s)" % (title) - print "Default: (%s)" % (default) - print "Enter digits, min: %d, max: %d:" % (min_chars, - max_chars) - userin = raw_input("'t' terminates, 'b' goes back:"); - - if userin == 'b': - raise GoBack("User wishes to go back") - elif userin == 't': - raise EndSession("User wishes to terminate session") - else: - return userin - - @dbus.service.method("org.ofono.SimToolkitAgent", - in_signature="sy", out_signature="s") - def RequestKey(self, title, icon): - print "Title: (%s)" % (title) - key = raw_input("Enter Key (t, b):") - - if key == 'b': - raise GoBack("User wishes to go back"); - elif key == 't': - raise EndSession("User wishes to terminate session"); - else: - return key - - @dbus.service.method("org.ofono.SimToolkitAgent", - in_signature="sy", out_signature="s") - def RequestDigit(self, title, icon): - print "Title: (%s)" % (title) - key = raw_input("Enter Digit (t, b):") - - if key == 'b': - raise GoBack("User wishes to go back"); - elif key == 't': - raise EndSession("User wishes to terminate session"); - else: - return key - - @dbus.service.method("org.ofono.SimToolkitAgent", - in_signature="sy", out_signature="b") - def RequestConfirmation(self, title, icon): - print "Title: (%s)" % (title) - key = raw_input("Enter Digit (t, b, y, n):") - - if key == 'b': - raise GoBack("User wishes to go back"); - elif key == 't': - raise EndSession("User wishes to terminate session"); - elif key == 'y': - return True - else: - return False - - @dbus.service.method("org.ofono.SimToolkitAgent", - in_signature="", out_signature="") - def Cancel(self): - print "Cancel" - -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") - - properties = manager.GetProperties() - - for path in properties["Modems"]: - modem = dbus.Interface(bus.get_object('org.ofono', path), - 'org.ofono.Modem') - - properties = modem.GetProperties() - - if "org.ofono.SimToolkit" not in properties["Interfaces"]: - continue - - stk = dbus.Interface(bus.get_object('org.ofono', path), - 'org.ofono.SimToolkit') - - properties = stk.GetProperties() - - print "Main Menu:" - print "%s" % (properties["MainMenuTitle"]) - - print "\nItems:" - - index = 0 - for item in properties["MainMenu"]: - print "%d. %s" % (index, item[0]) - index += 1 - - path = "/test/agent" - agent = StkAgent(bus, path) - - select = int(raw_input("Enter Selection: ")) - stk.SelectItem(select, path) - print "Agent registered for session" - - mainloop = gobject.MainLoop() - mainloop.run() diff --git a/test/test-stk-menu b/test/test-stk-menu new file mode 100755 index 00000000..a342b1f7 --- /dev/null +++ b/test/test-stk-menu @@ -0,0 +1,169 @@ +#!/usr/bin/python + +import gobject + +import sys +import dbus +import dbus.service +import dbus.mainloop.glib + +class GoBack(dbus.DBusException): + _dbus_error_name = "org.ofono.Error.GoBack" + +class EndSession(dbus.DBusException): + _dbus_error_name = "org.ofono.Error.EndSession" + +class StkAgent(dbus.service.Object): + exit_on_release = True + + def set_exit_on_release(self, exit_on_release): + self.exit_on_release = exit_on_release + + @dbus.service.method("org.ofono.SimToolkitAgent", + in_signature="", out_signature="") + def Release(self): + print "Release" + if self.exit_on_release: + mainloop.quit() + + @dbus.service.method("org.ofono.SimToolkitAgent", + in_signature="sya(sy)y", out_signature="y") + def RequestSelection(self, title, icon, items, default): + print "Title: (%s)" % (title) + index = 0; + for item in items: + print "%d. %s" % (index, item[0]) + index += 1 + + print "\nDefault: %d" % (default) + select = raw_input("Enter Selection (t, b):") + + if select == 'b': + raise GoBack("User wishes to go back") + elif select == 't': + raise EndSession("User wishes to terminate session") + else: + return int(select); + + @dbus.service.method("org.ofono.SimToolkitAgent", + in_signature="syb", out_signature="") + def DisplayText(self, title, icon, urgent): + print "DisplayText (%s, %s)" % (title, urgent) + + @dbus.service.method("org.ofono.SimToolkitAgent", + in_signature="sysyyb", out_signature="s") + def RequestInput(self, title, icon, default, min_chars, max_chars, + hide_typing): + print "Title: (%s)" % (title) + print "Default: (%s)" % (default) + print "Enter characters, min: %d, max: %d:" % (min_chars, + max_chars) + userin = raw_input(""); + + return userin + + @dbus.service.method("org.ofono.SimToolkitAgent", + in_signature="sysyyb", out_signature="s") + def RequestDigits(self, title, icon, default, min_chars, max_chars, + hide_typing): + print "Title: (%s)" % (title) + print "Default: (%s)" % (default) + print "Enter digits, min: %d, max: %d:" % (min_chars, + max_chars) + userin = raw_input("'t' terminates, 'b' goes back:"); + + if userin == 'b': + raise GoBack("User wishes to go back") + elif userin == 't': + raise EndSession("User wishes to terminate session") + else: + return userin + + @dbus.service.method("org.ofono.SimToolkitAgent", + in_signature="sy", out_signature="s") + def RequestKey(self, title, icon): + print "Title: (%s)" % (title) + key = raw_input("Enter Key (t, b):") + + if key == 'b': + raise GoBack("User wishes to go back"); + elif key == 't': + raise EndSession("User wishes to terminate session"); + else: + return key + + @dbus.service.method("org.ofono.SimToolkitAgent", + in_signature="sy", out_signature="s") + def RequestDigit(self, title, icon): + print "Title: (%s)" % (title) + key = raw_input("Enter Digit (t, b):") + + if key == 'b': + raise GoBack("User wishes to go back"); + elif key == 't': + raise EndSession("User wishes to terminate session"); + else: + return key + + @dbus.service.method("org.ofono.SimToolkitAgent", + in_signature="sy", out_signature="b") + def RequestConfirmation(self, title, icon): + print "Title: (%s)" % (title) + key = raw_input("Enter Digit (t, b, y, n):") + + if key == 'b': + raise GoBack("User wishes to go back"); + elif key == 't': + raise EndSession("User wishes to terminate session"); + elif key == 'y': + return True + else: + return False + + @dbus.service.method("org.ofono.SimToolkitAgent", + in_signature="", out_signature="") + def Cancel(self): + print "Cancel" + +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") + + properties = manager.GetProperties() + + for path in properties["Modems"]: + modem = dbus.Interface(bus.get_object('org.ofono', path), + 'org.ofono.Modem') + + properties = modem.GetProperties() + + if "org.ofono.SimToolkit" not in properties["Interfaces"]: + continue + + stk = dbus.Interface(bus.get_object('org.ofono', path), + 'org.ofono.SimToolkit') + + properties = stk.GetProperties() + + print "Main Menu:" + print "%s" % (properties["MainMenuTitle"]) + + print "\nItems:" + + index = 0 + for item in properties["MainMenu"]: + print "%d. %s" % (index, item[0]) + index += 1 + + path = "/test/agent" + agent = StkAgent(bus, path) + + select = int(raw_input("Enter Selection: ")) + stk.SelectItem(select, path) + print "Agent registered for session" + + mainloop = gobject.MainLoop() + mainloop.run() -- cgit v1.2.3