Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6249)

Unified Diff: chrome/test/pyautolib/pyauto.py

Issue 10829203: GetServicePath should perform a scan (Closed) Base URL: https://git.chromium.org/git/chromium/src@master
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698