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

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

Issue 10264012: Move WaitUntilWifiNetworkAvailable and GetServicePath to pyauto so it can be reached from autotest (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | « chrome/test/pyautolib/chromeos_network.py ('k') | 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
===================================================================
--- chrome/test/pyautolib/pyauto.py (revision 134390)
+++ chrome/test/pyautolib/pyauto.py (working copy)
@@ -4233,6 +4233,34 @@
return network_info
+ def GetConnectedWifi(self):
+ """Returns the SSID of the currently connected wifi network.
dtu 2012/04/30 21:26:05 Add "on ChromeOS" or something like that. Same wit
+
+ Returns:
+ The SSID of the connected network or None if we're not connected.
+ """
+ service_list = self.GetNetworkInfo()
+ connected_service_path = service_list.get('connected_wifi')
+ if 'wifi_networks' in service_list and \
+ connected_service_path in service_list['wifi_networks']:
+ return service_list['wifi_networks'][connected_service_path]['name']
+
+ def GetServicePath(self, ssid):
+ """Returns the service path associated with an SSID.
+
+ Args:
+ ssid: String defining the SSID we are searching for.
+
+ 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
+ return None
+
def NetworkScan(self):
"""Causes ChromeOS to scan for available wifi networks.
@@ -4267,6 +4295,43 @@
PROXY_TYPE_MANUAL = 2
PROXY_TYPE_PAC = 3
+ def WaitUntilWifiNetworkAvailable(self, ssid, timeout=60, is_hidden=False):
+ """Waits until the given network is available.
+
+ Routers that are just turned on may take up to 1 minute upon turning them
+ on to broadcast their SSID.
+
+ Args:
+ ssid: SSID of the service we want to connect to.
+ timeout: timeout (in seconds)
+
+ Raises:
+ Exception if timeout duration has been hit before wifi router is seen.
+
+ Returns:
+ True, when the wifi network is seen within the timout period.
+ False, otherwise.
+ """
+ def _GotWifiNetwork():
+ # Returns non-empty array if desired SSID is available.
+ try:
+ return [wifi for wifi in
+ self.NetworkScan().get('wifi_networks', {}).values()
+ if wifi.get('name') == ssid]
+ except pyauto_errors.JSONInterfaceError:
+ # Temporary fix until crosbug.com/14174 is fixed.
+ # NetworkScan is only used in updating the list of networks so errors
+ # thrown by it are not critical to the results of wifi tests that use
+ # this method.
+ return False
+
+ # The hidden AP's will always be on, thus we will assume it is ready to
+ # connect to.
+ if is_hidden:
+ return bool(_GotWifiNetwork())
+
+ return self.WaitUntil(_GotWifiNetwork, timeout=timeout, retry_sleep=1)
+
def GetProxyTypeName(self, proxy_type):
values = { self.PROXY_TYPE_DIRECT: 'Direct Internet connection',
self.PROXY_TYPE_MANUAL: 'Manual proxy configuration',
« no previous file with comments | « chrome/test/pyautolib/chromeos_network.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698