test: update STK test script for conformance

Update the STK test script to be able to use it for
conformance test. Using 'agent' as parameter the
script will now register a STK agent to be able to
handle unsolicited proactive command. Without any
parameter or with 'menu' the script will try to
display the STK main menu of the (U)SIM.
This commit is contained in:
Guillaume Lucas 2010-12-21 14:24:56 +00:00 committed by Denis Kenzior
parent 67486801d0
commit 06912dff3d
1 changed files with 73 additions and 22 deletions

View File

@ -13,6 +13,9 @@ class GoBack(dbus.DBusException):
class EndSession(dbus.DBusException): class EndSession(dbus.DBusException):
_dbus_error_name = "org.ofono.Error.EndSession" _dbus_error_name = "org.ofono.Error.EndSession"
class Busy(dbus.DBusException):
_dbus_error_name = "org.ofono.Error.Busy"
class StkAgent(dbus.service.Object): class StkAgent(dbus.service.Object):
exit_on_release = True exit_on_release = True
@ -30,9 +33,10 @@ class StkAgent(dbus.service.Object):
in_signature="sya(sy)n", out_signature="y") in_signature="sya(sy)n", out_signature="y")
def RequestSelection(self, title, icon, items, default): def RequestSelection(self, title, icon, items, default):
print "Title: (%s)" % (title) print "Title: (%s)" % (title)
print "Icon: (%d)" % (icon)
index = 0; index = 0;
for item in items: for item in items:
print "%d. %s" % (index, item[0]) print "%d. %s (icon: %d)" % (index, item[0], item[1])
index += 1 index += 1
print "\nDefault: %d" % (default) print "\nDefault: %d" % (default)
@ -48,14 +52,27 @@ class StkAgent(dbus.service.Object):
@dbus.service.method("org.ofono.SimToolkitAgent", @dbus.service.method("org.ofono.SimToolkitAgent",
in_signature="syb", out_signature="") in_signature="syb", out_signature="")
def DisplayText(self, title, icon, urgent): def DisplayText(self, title, icon, urgent):
print "DisplayText (%s, %s)" % (title, urgent) print "DisplayText (%s)" % (title)
print "Icon: (%d)" % (icon)
print "Urgent: (%d)" % (urgent)
key = raw_input("Press return to clear ('t' terminates, "
"'b' goest back, 'n' busy):")
if key == 'b':
raise GoBack("User wishes to go back")
elif key == 't':
raise EndSession("User wishes to terminate session")
elif key == 'n':
raise Busy("User wishes to simulate busy screen")
@dbus.service.method("org.ofono.SimToolkitAgent", @dbus.service.method("org.ofono.SimToolkitAgent",
in_signature="sysyyb", out_signature="s") in_signature="sysyyb", out_signature="s")
def RequestInput(self, title, icon, default, min_chars, max_chars, def RequestInput(self, title, icon, default, min_chars, max_chars,
hide_typing): hide_typing):
print "Title: (%s)" % (title) print "Title: (%s)" % (title)
print "Icon: (%d)" % (icon)
print "Default: (%s)" % (default) print "Default: (%s)" % (default)
print "Hide typing: (%s)" % (hide_typing)
print "Enter characters, min: %d, max: %d:" % (min_chars, print "Enter characters, min: %d, max: %d:" % (min_chars,
max_chars) max_chars)
userin = raw_input(""); userin = raw_input("");
@ -67,7 +84,9 @@ class StkAgent(dbus.service.Object):
def RequestDigits(self, title, icon, default, min_chars, max_chars, def RequestDigits(self, title, icon, default, min_chars, max_chars,
hide_typing): hide_typing):
print "Title: (%s)" % (title) print "Title: (%s)" % (title)
print "Icon: (%d)" % (icon)
print "Default: (%s)" % (default) print "Default: (%s)" % (default)
print "Hide typing: (%s)" % (hide_typing)
print "Enter digits, min: %d, max: %d:" % (min_chars, print "Enter digits, min: %d, max: %d:" % (min_chars,
max_chars) max_chars)
userin = raw_input("'t' terminates, 'b' goes back:"); userin = raw_input("'t' terminates, 'b' goes back:");
@ -83,6 +102,7 @@ class StkAgent(dbus.service.Object):
in_signature="sy", out_signature="s") in_signature="sy", out_signature="s")
def RequestKey(self, title, icon): def RequestKey(self, title, icon):
print "Title: (%s)" % (title) print "Title: (%s)" % (title)
print "Icon: (%d)" % (icon)
key = raw_input("Enter Key (t, b):") key = raw_input("Enter Key (t, b):")
if key == 'b': if key == 'b':
@ -96,6 +116,7 @@ class StkAgent(dbus.service.Object):
in_signature="sy", out_signature="s") in_signature="sy", out_signature="s")
def RequestDigit(self, title, icon): def RequestDigit(self, title, icon):
print "Title: (%s)" % (title) print "Title: (%s)" % (title)
print "Icon: (%d)" % (icon)
key = raw_input("Enter Digit (t, b):") key = raw_input("Enter Digit (t, b):")
if key == 'b': if key == 'b':
@ -109,6 +130,7 @@ class StkAgent(dbus.service.Object):
in_signature="sy", out_signature="b") in_signature="sy", out_signature="b")
def RequestConfirmation(self, title, icon): def RequestConfirmation(self, title, icon):
print "Title: (%s)" % (title) print "Title: (%s)" % (title)
print "Icon: (%d)" % (icon)
key = raw_input("Enter Confirmation (t, b, y, n):") key = raw_input("Enter Confirmation (t, b, y, n):")
if key == 'b': if key == 'b':
@ -124,6 +146,7 @@ class StkAgent(dbus.service.Object):
in_signature="sy", out_signature="b") in_signature="sy", out_signature="b")
def ConfirmCallSetup(self, info, icon): def ConfirmCallSetup(self, info, icon):
print "Information: (%s)" % (info) print "Information: (%s)" % (info)
print "Icon: (%d)" % (icon)
key = raw_input("Enter Confirmation (t, y, n):") key = raw_input("Enter Confirmation (t, y, n):")
if key == 't': if key == 't':
@ -141,14 +164,30 @@ class StkAgent(dbus.service.Object):
@dbus.service.method("org.ofono.SimToolkitAgent", @dbus.service.method("org.ofono.SimToolkitAgent",
in_signature="ssy", out_signature="") in_signature="ssy", out_signature="")
def PlayTone(self, tone, text, icon): def PlayTone(self, tone, text, icon):
print "playtone is %s" % (tone) print "PlayTone: %s" % (tone)
print "Text: %s" % (text)
print "Icon: %d" % (icon)
@dbus.service.method("org.ofono.SimToolkitAgent", @dbus.service.method("org.ofono.SimToolkitAgent",
in_signature="ssy", out_signature="") in_signature="ssy", out_signature="")
def LoopTone(self, tone, text, icon): def LoopTone(self, tone, text, icon):
print "the loop tone is %s" % (tone) print "LoopTone: %s" % (tone)
print "Text: %s" % (text)
print "Icon: %d" % (icon)
key = raw_input("Press return to end before timeout (t):")
if key == 't':
raise EndSession("User wishes to terminate session");
def property_changed(name, value):
print "SimToolKit property: %s changed to '%s'" % (name, value)
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) == 2:
mode = sys.argv[1]
else:
mode = 'menu'
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus() bus = dbus.SystemBus()
@ -164,26 +203,38 @@ if __name__ == '__main__':
stk = dbus.Interface(bus.get_object('org.ofono', path), stk = dbus.Interface(bus.get_object('org.ofono', path),
'org.ofono.SimToolkit') 'org.ofono.SimToolkit')
stk.connect_to_signal("PropertyChanged", property_changed)
properties = stk.GetProperties() properties = stk.GetProperties()
if "MainMenuTitle" in properties: if mode == 'menu':
print "Main Menu:" if "MainMenuTitle" in properties:
print "%s" % (properties["MainMenuTitle"]) print "Main Menu:"
print "\n" print "%s" % (properties["MainMenuTitle"])
print "\n"
if "MainMenu" in properties: if "MainMenu" in properties:
print "Items:" print "Items:"
index = 0 index = 0
for item in properties["MainMenu"]: for item in properties["MainMenu"]:
print "%d. %s" % (index, item[0]) print "%d. %s" % (index, item[0])
index += 1 index += 1
path = "/test/agent" path = "/test/agent"
agent = StkAgent(bus, path) agent = StkAgent(bus, path)
select = int(raw_input("Enter Selection: ")) select = int(raw_input("Enter Selection: "))
stk.SelectItem(select, path) stk.SelectItem(select, path)
print "Agent registered for session" elif mode == 'agent':
path = "/test/agent"
agent = StkAgent(bus, path)
stk.RegisterAgent(path)
print "Agent registered for session - Wait SIM ToolKit command..."
else:
print "%s [menu|agent]" % (sys.argv[0])
exit(0)
mainloop = gobject.MainLoop() mainloop = gobject.MainLoop()
mainloop.run() mainloop.run()