Chromium Code Reviews| Index: chrome/test/pyautolib/pyauto.py |
| diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py |
| index 2c95c63cbad9567df7c988654821db5f21eb3cee..d1c943b32a47de4b8a612accd92f6d4c959f06a9 100755 |
| --- a/chrome/test/pyautolib/pyauto.py |
| +++ b/chrome/test/pyautolib/pyauto.py |
| @@ -5064,20 +5064,31 @@ 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. |
|
Nirnimesh
2012/08/07 23:44:50
Update to mention "Wait until"
stanleyw
2012/08/08 19:29:08
Done.
|
| 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: |
|
Nirnimesh
2012/08/07 23:44:50
Do not reinvent polling loop. Use WaitUntil()
stanleyw
2012/08/08 00:35:17
I did initially. Unfortunately, I need a particul
Nirnimesh
2012/08/08 00:48:26
WaitUntil returns the value that the callable retu
stanleyw
2012/08/08 19:29:08
Re-did WaitUntil to do this.
On 2012/08/08 00:48
|
| + 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() |
| + time.sleep(1) |
| return None |
| def NetworkScan(self): |