summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2010-02-16 11:52:11 +0100
committerMarcel Holtmann <marcel@holtmann.org>2010-02-16 07:43:23 -0800
commitc9479134d6444c9e9da98ad5bb5ba4891a86d51b (patch)
tree29e4b642844171ce58c757e0da0b9cafb77a51ef /test
parent913898ed5da9c9721c90d49bfc64a8e2b1ad4b5c (diff)
downloadconnman-c9479134d6444c9e9da98ad5bb5ba4891a86d51b.tar.gz
connman-c9479134d6444c9e9da98ad5bb5ba4891a86d51b.tar.bz2
connman-c9479134d6444c9e9da98ad5bb5ba4891a86d51b.zip
Update all test scripts using devices properties directly
We need to go through the technology list first in order to access the devices properties.
Diffstat (limited to 'test')
-rwxr-xr-xtest/disable-device26
-rwxr-xr-xtest/enable-device26
-rwxr-xr-xtest/set-passphrase36
-rwxr-xr-xtest/show-introspection14
-rwxr-xr-xtest/test-connman131
5 files changed, 134 insertions, 99 deletions
diff --git a/test/disable-device b/test/disable-device
index caa954f0..acf962b2 100755
--- a/test/disable-device
+++ b/test/disable-device
@@ -14,18 +14,24 @@ manager = dbus.Interface(bus.get_object('org.moblin.connman', "/"),
properties = manager.GetProperties()
-for path in properties["Devices"]:
- device = dbus.Interface(bus.get_object('org.moblin.connman', path),
- 'org.moblin.connman.Device')
+for path in properties["Technologies"]:
+ technology = dbus.Interface(bus.get_object("org.moblin.connman", path),
+ "org.moblin.connman.Technology")
- properties = device.GetProperties()
+ properties = technology.GetProperties()
- if "Interface" not in properties.keys():
- continue
+ for path in properties["Devices"]:
+ device = dbus.Interface(bus.get_object('org.moblin.connman', path),
+ 'org.moblin.connman.Device')
- if properties["Interface"] != sys.argv[1]:
- continue
+ properties = device.GetProperties()
- print "Disabling device %s" % (path)
+ if "Interface" not in properties.keys():
+ continue
- device.SetProperty("Powered", dbus.Boolean(0));
+ if properties["Interface"] != sys.argv[1]:
+ continue
+
+ print "Disabling device %s" % (path)
+
+ device.SetProperty("Powered", dbus.Boolean(0));
diff --git a/test/enable-device b/test/enable-device
index 64514416..e6f95181 100755
--- a/test/enable-device
+++ b/test/enable-device
@@ -14,18 +14,24 @@ manager = dbus.Interface(bus.get_object('org.moblin.connman', "/"),
properties = manager.GetProperties()
-for path in properties["Devices"]:
- device = dbus.Interface(bus.get_object('org.moblin.connman', path),
- 'org.moblin.connman.Device')
+for path in properties["Technologies"]:
+ technology = dbus.Interface(bus.get_object("org.moblin.connman", path),
+ "org.moblin.connman.Technology")
- properties = device.GetProperties()
+ properties = technology.GetProperties()
- if "Interface" not in properties.keys():
- continue
+ for path in properties["Devices"]:
+ device = dbus.Interface(bus.get_object('org.moblin.connman', path),
+ 'org.moblin.connman.Device')
- if properties["Interface"] != sys.argv[1]:
- continue
+ properties = device.GetProperties()
- print "Enabling device %s" % (path)
+ if "Interface" not in properties.keys():
+ continue
- device.SetProperty("Powered", dbus.Boolean(1));
+ if properties["Interface"] != sys.argv[1]:
+ continue
+
+ print "Enabling device %s" % (path)
+
+ device.SetProperty("Powered", dbus.Boolean(1));
diff --git a/test/set-passphrase b/test/set-passphrase
index a1044162..acce3502 100755
--- a/test/set-passphrase
+++ b/test/set-passphrase
@@ -14,24 +14,30 @@ manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"),
properties = manager.GetProperties()
-for path in properties["Devices"]:
- device = dbus.Interface(bus.get_object("org.moblin.connman", path),
- "org.moblin.connman.Device")
+for path in properties["Technologies"]:
+ technology = dbus.Interface(bus.get_object("org.moblin.connman", path),
+ "org.moblin.connman.Technology")
- properties = device.GetProperties()
+ properties = technology.GetProperties()
- if (properties["Type"] != "wifi" and properties["Type"] != "wimax"):
- continue;
+ for path in properties["Devices"]:
+ device = dbus.Interface(bus.get_object("org.moblin.connman", path),
+ "org.moblin.connman.Device")
- for path in properties["Networks"]:
- network = dbus.Interface(bus.get_object("org.moblin.connman", path),
- "org.moblin.connman.Network")
+ properties = device.GetProperties()
- properties = network.GetProperties()
+ if (properties["Type"] != "wifi" and properties["Type"] != "wimax"):
+ continue;
- if "Name" not in properties:
- continue
+ for path in properties["Networks"]:
+ network = dbus.Interface(bus.get_object("org.moblin.connman", path),
+ "org.moblin.connman.Network")
- if properties["Name"] == sys.argv[1]:
- print "Setting passphrase for %s" % (path)
- network.SetProperty("WiFi.Passphrase", sys.argv[2])
+ properties = network.GetProperties()
+
+ if "Name" not in properties:
+ continue
+
+ if properties["Name"] == sys.argv[1]:
+ print "Setting passphrase for %s" % (path)
+ network.SetProperty("WiFi.Passphrase", sys.argv[2])
diff --git a/test/show-introspection b/test/show-introspection
index bbf93c8b..5e392c75 100755
--- a/test/show-introspection
+++ b/test/show-introspection
@@ -14,8 +14,14 @@ manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"),
properties = manager.GetProperties()
-for path in properties["Devices"]:
- object = dbus.Interface(bus.get_object("org.moblin.connman", path),
- "org.freedesktop.DBus.Introspectable")
+for path in properties["Technologies"]:
+ technology = dbus.Interface(bus.get_object("org.moblin.connman", path),
+ "org.moblin.connman.Technology")
- print object.Introspect()
+ properties = technology.GetProperties()
+
+ for path in properties["Devices"]:
+ object = dbus.Interface(bus.get_object("org.moblin.connman", path),
+ "org.freedesktop.DBus.Introspectable")
+
+ print object.Introspect()
diff --git a/test/test-connman b/test/test-connman
index 38455087..aa781c3b 100755
--- a/test/test-connman
+++ b/test/test-connman
@@ -149,6 +149,72 @@ def print_services(services):
print "%s %-26s { %s }" % (favorite, name, identifier)
+def device_handle(devices, interface):
+ for path in devices:
+ device = dbus.Interface(bus.get_object("org.moblin.connman", path),
+ "org.moblin.connman.Device")
+
+ properties = device.GetProperties()
+
+ if "Interface" not in properties.keys():
+ continue
+
+ if interface != "" and properties["Interface"] != interface:
+ continue
+
+ if command == "scan":
+ if properties["Type"] in ["wifi", "wimax"]:
+ interface = properties["Interface"]
+ print "Scan for device %s" % (interface)
+ device.ProposeScan()
+ else:
+ print "No scanning for device %s" % (interface)
+ elif command == "scan_interval" and value != "":
+ device.SetProperty("ScanInterval", dbus.UInt16(value))
+ elif command in ["networks", "net"]:
+ if "Networks" in properties.keys():
+ print_networks(properties["Networks"])
+ else:
+ print "Device has no networks"
+ elif command in ["connect", "conn"] and value != "":
+ if "Networks" in properties.keys():
+ select_network(properties["Networks"], value)
+ else:
+ print "Device can't connect networks"
+ elif command in ["connect", "conn"]:
+ print "Need to specify network"
+ elif command in ["disconnect", "disc"] and value != "":
+ if "Networks" in properties.keys():
+ disconnect_network(properties["Networks"], value)
+ else:
+ print "Device has no networks"
+ elif command in ["discconnect", "disc"]:
+ if "Networks" in properties.keys():
+ disconnect_network(properties["Networks"], "")
+ else:
+ print "Device has no networks"
+ elif command == "powered" and value != "":
+ if value == "on":
+ powered = dbus.Boolean(1)
+ elif value == "off":
+ powered = dbus.Boolean(0)
+ else:
+ powered = dbus.Boolean(value)
+ device.SetProperty("Powered", powered)
+ elif command == "powered":
+ interface = properties["Interface"]
+ if properties["Powered"] == dbus.Boolean(1):
+ powered = "on"
+ else:
+ powered = "off"
+ print "Device %s is powered %s" % (interface, powered)
+ elif command == "list" or command == "":
+ print_properties(path, properties)
+ else:
+ print "Unknown command"
+
+
+
if sys.argv[1] == "state":
properties = manager.GetProperties()
@@ -349,68 +415,13 @@ elif sys.argv[1] == "dev":
if len(sys.argv) > 4:
value = sys.argv[4]
- for path in properties["Devices"]:
- device = dbus.Interface(bus.get_object("org.moblin.connman", path),
- "org.moblin.connman.Device")
-
- properties = device.GetProperties()
-
- if "Interface" not in properties.keys():
- continue
+ for path in properties["Technologies"]:
+ technology = dbus.Interface(bus.get_object("org.moblin.connman", path),
+ "org.moblin.connman.Technology")
- if interface != "" and properties["Interface"] != interface:
- continue
+ properties = technology.GetProperties()
- if command == "scan":
- if properties["Type"] in ["wifi", "wimax"]:
- interface = properties["Interface"]
- print "Scan for device %s" % (interface)
- device.ProposeScan()
- else:
- print "No scanning for device %s" % (interface)
- elif command == "scan_interval" and value != "":
- device.SetProperty("ScanInterval", dbus.UInt16(value))
- elif command in ["networks", "net"]:
- if "Networks" in properties.keys():
- print_networks(properties["Networks"])
- else:
- print "Device has no networks"
- elif command in ["connect", "conn"] and value != "":
- if "Networks" in properties.keys():
- select_network(properties["Networks"], value)
- else:
- print "Device can't connect networks"
- elif command in ["connect", "conn"]:
- print "Need to specify network"
- elif command in ["disconnect", "disc"] and value != "":
- if "Networks" in properties.keys():
- disconnect_network(properties["Networks"], value)
- else:
- print "Device has no networks"
- elif command in ["discconnect", "disc"]:
- if "Networks" in properties.keys():
- disconnect_network(properties["Networks"], "")
- else:
- print "Device has no networks"
- elif command == "powered" and value != "":
- if value == "on":
- powered = dbus.Boolean(1)
- elif value == "off":
- powered = dbus.Boolean(0)
- else:
- powered = dbus.Boolean(value)
- device.SetProperty("Powered", powered)
- elif command == "powered":
- interface = properties["Interface"]
- if properties["Powered"] == dbus.Boolean(1):
- powered = "on"
- else:
- powered = "off"
- print "Device %s is powered %s" % (interface, powered)
- elif command == "list" or command == "":
- print_properties(path, properties)
- else:
- print "Unknown command"
+ device_handle(properties["Devices"], interface)
else:
print "Unknown command"