Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions test/set-call-forwarding
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,42 @@ def property_changed(property, value):
mainloop.quit();

if __name__ == "__main__":
if len(sys.argv) < 3:
print("Usage: %s <property> <value>" % (sys.argv[0]))

dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()

if len(sys.argv) == 4:
path = sys.argv[1]
property = sys.argv[2]
value = sys.argv[3]
elif len(sys.argv) == 3:
manager = dbus.Interface(bus.get_object('org.ofono', '/'),
'org.ofono.Manager')
modems = manager.GetModems()

path = modems[0][0]
property = sys.argv[1]
value = sys.argv[2]
else:
print("Usage: %s [PATH] <property> <value>" % (sys.argv[0]))
print("Properties can be: VoiceUnconditional, VoiceBusy,")
print(" VoiceNoReply, VoiceNoReplyTimeout, VoiceNotReachable")
print("Value: number to or the timeout")
sys.exit(1)

property = sys.argv[1]
value = sys.argv[2]

canexit = False

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()
if property not in ["VoiceUnconditional",
"VoiceBusy",
"VoiceNoReply",
"VoiceNoReplyTimeout",
"VoiceNotReachable"]:
print("Properties can be: VoiceUnconditional, VoiceBusy,")
print(" VoiceNoReply, VoiceNoReplyTimeout, VoiceNotReachable")
print("Value: number to or the timeout")
sys.exit(1)

cf = dbus.Interface(bus.get_object('org.ofono', modems[0][0]),
cf = dbus.Interface(bus.get_object('org.ofono', path),
'org.ofono.CallForwarding')

cf.connect_to_signal("PropertyChanged", property_changed)
Expand Down
33 changes: 31 additions & 2 deletions test/test-call-forwarding
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ from gi.repository import GLib
import argparse
import dbus
import dbus.mainloop.glib
import sys

def property_changed(property, value):
print("CallForwarding property %s changed to %s" % (property, value))

def print_properties(cf):
properties = cf.GetProperties()

for p in properties:
for p in ["VoiceBusy", "VoiceNoReplyTimeout", "VoiceNotReachable",
"VoiceUnconditional", "VoiceNoReply",
"ForwardingFlagOnSim"]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you do this change? The set you use between the brackets is exactly the same contained in "properties".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this so that I could get rid of the first test case in:

https://wiki.ubuntu.com/Process/Merges/TestPlans/ofono/CallForwarding

This change now causes the script to verify that the interface and all the properties are properly exported.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, but taking into account that that is Ubuntu Touch's test plan, I am not sure if upstream would accept this change if that is the only reason. If we want to fully automatize CallForwarding testing I think we should create a different script similar to the ones you created for testing the SIM interface, because I do not think that test-call-forwarding fully fits our testing needs.

if len(properties[p].__str__()) > 0:
print("%s call forwarding rule is: %s" % (p, properties[p]))
else:
Expand Down Expand Up @@ -42,6 +45,16 @@ def parse_arguments():
help="""Specify an unconditional forwarding number""",
default="+155555",
)
parser.add_argument("--unreach-num",
dest="unreach_num",
help="""Specify an un-reachable forwarding number""",
default="+155555",
)
parser.add_argument("--busy-num",
dest="busy_num",
help="""Specify a busy forwarding number""",
default="+155555",
)
parser.add_argument("--noreply-timeout",
dest="noreply_timeout",
help="""Specify a no-reply timeout""",
Expand Down Expand Up @@ -140,9 +153,21 @@ def main(args):
except dbus.DBusException as e:
print("Unable to set Voice Unconditional - Bad")

try:
cf.SetProperty("VoiceBusy", args.busy_num)
except dbus.DBusException as e:
print("Unable to set Voice Busy - Bad")

try:
cf.SetProperty("VoiceNotReachable", args.unreach_num)
except dbus.DBusException as e:
print("Unable to set Voice Not Reachable - Bad")

properties = cf.GetProperties()

print(properties["VoiceUnconditional"])
print(properties["VoiceBusy"])
print(properties["VoiceNotReachable"])

try:
cf.DisableAll("foobar")
Expand Down Expand Up @@ -171,4 +196,8 @@ def main(args):

if __name__ == "__main__":
args = parse_arguments()
main(args)

try:
main(args)
except KeyboardInterrupt as e:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handling the interrupt is nice, but I think that adding some timeout (~30 secs) to exit the script would be good to have too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, if you think that's warranted, I can add...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think making sure it exits would remove the feeling that something went wrong when executing the script. An alternative could be to print something like "Waiting for property changes, press Ctrl+C when finished" if you prefer that.

sys.exit(0)