summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2009-05-28 16:05:26 -0500
committerDenis Kenzior <denkenz@gmail.com>2009-05-28 18:28:56 -0500
commit0c10adf5575d6384efc95b61e46ab139add3d10f (patch)
tree36948af281dd04697e42fe890ec9fad37ebf31d7
parent558799db9ccf269be284f989db7371d570b892c7 (diff)
downloadofono-0c10adf5575d6384efc95b61e46ab139add3d10f.tar.bz2
Adding test script for CallMeter interface
-rwxr-xr-xtest/test-advice-of-charge83
1 files changed, 83 insertions, 0 deletions
diff --git a/test/test-advice-of-charge b/test/test-advice-of-charge
new file mode 100755
index 00000000..2ed2b5c6
--- /dev/null
+++ b/test/test-advice-of-charge
@@ -0,0 +1,83 @@
+#!/usr/bin/python
+
+import gobject
+import sys
+import dbus
+import dbus.mainloop.glib
+
+
+def cm_property_changed(name, value):
+ print "CallMeter property: '%s' changed to '%s'" % (name, str(value))
+ if canexit:
+ mainloop.quit()
+
+def cm_maximum_reached():
+ print "Only 30 seconds call time remains, recharge."
+
+def print_useage(s):
+ print "Useage: %s <property> <newvalue> <password>" % (s)
+ print "Useage: %s reset <password>" % (s)
+ sys.exit(1);
+
+if __name__ == "__main__":
+ if len(sys.argv) != 3 and len(sys.argv) != 4:
+ print_useage(sys.argv[0])
+
+ if (sys.argv[1] == 'reset'):
+ pin = sys.argv[2]
+ else:
+ if (len(sys.argv) != 4):
+ print_useage(sys.argv[0])
+ property = sys.argv[1]
+ newvalue = sys.argv[2]
+ pin = sys.argv[3]
+
+ 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.GetProperties()['Modems']
+
+ cm = dbus.Interface(bus.get_object('org.ofono', modems[0]),
+ 'org.ofono.CallMeter')
+
+ cm.connect_to_signal("PropertyChanged", cm_property_changed)
+ cm.connect_to_signal("NearMaximumWarning", cm_maximum_reached)
+
+ properties = cm.GetProperties()
+
+ print "Currency: %s" % (properties['Currency'])
+ print "PricePerUnit %s" % (properties['PricePerUnit'])
+ print "Call meter for the current call: %s" % (properties['CallMeter'])
+ print "Call meter for current and previous calls: %s" %\
+ properties['AccumulatedCallMeter']
+ print "Call meter maximum, once reached calls are not possible: %s" %\
+ properties['AccumulatedCallMeterMaximum']
+
+ total = properties['PricePerUnit'] * properties['AccumulatedCallMeter']
+ print "Accumulated Meter in Currency: %s %s" %\
+ (total, properties['Currency'])
+
+ if (sys.argv[1] == 'reset'):
+ print "Resetting Accumulated Call Meter"
+ try:
+ cm.Reset(pin)
+ except dbus.DBusException, e:
+ print "Unable to reset ACM: ", e
+ sys.exit(1)
+ else:
+ try:
+ cm.SetProperty(property, newvalue, pin)
+ except dbus.DBusException, e:
+ print "Unable to set property: ", e
+ sys.exit(1)
+
+ canexit = True
+
+ mainloop = gobject.MainLoop()
+ mainloop.run()