Index: chrome/test/pyautolib/pyauto.py |
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py |
index 2c95c63cbad9567df7c988654821db5f21eb3cee..8f344f751d441f8716cce34e90bc6d18f1cce97d 100755 |
--- a/chrome/test/pyautolib/pyauto.py |
+++ b/chrome/test/pyautolib/pyauto.py |
@@ -5064,20 +5064,30 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
connected_service_path in service_list['wifi_networks']: |
return service_list['wifi_networks'][connected_service_path]['name'] |
- def GetServicePath(self, ssid): |
+ def GetServicePath(self, ssid, encryption=None, timeout=30): |
"""Returns the service path associated with an SSID. |
Args: |
ssid: String defining the SSID we are searching for. |
+ encryption: Encryption type of the network; either None to return the |
+ first instance of network that matches the ssid, '' for |
+ an empty network, 'PSK', 'WEP' or '8021X'. |
+ timeout: Duration to wait for ssid to appear. |
Returns: |
- The service path or None if SSID does not exist. |
- """ |
- service_list = self.GetNetworkInfo() |
- service_list = service_list.get('wifi_networks', []) |
- for service_path, service_obj in service_list.iteritems(): |
- if service_obj['name'] == ssid: |
- return service_path |
+ The service path or None if SSID does not exist after timeout period. |
+ """ |
+ end_time = time.time() + timeout |
+ while time.time() < end_time: |
krisr
2012/08/06 23:39:13
How fast does this spin? i.e. are we spiking the
stanleyw
2012/08/07 01:22:13
Done.
|
+ service_list = self.GetNetworkInfo().get('wifi_networks', []) |
+ for service_path, service_obj in service_list.iteritems(): |
+ service_encr = 'PSK' if service_obj['encryption'] in ['WPA', 'RSN'] \ |
+ else service_obj['encryption'] |
+ |
+ if service_obj['name'] == ssid and \ |
+ (encryption == None or service_encr == encryption): |
+ return service_path |
+ self.NetworkScan() |
return None |
def NetworkScan(self): |