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

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

Issue 6732040: PyAuto automation hooks: blocking wifi connect, disconnect, and network scan. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial commit. Created 9 years, 9 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
Index: chrome/test/pyautolib/pyauto.py
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index 2f7e3717feb1e5bedeed7077dd7c7c0db3df0310..323962c64300805e9f2675fd2b29bf7b4bdba232 100644
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -471,7 +471,10 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
Raises:
pyauto_errors.JSONInterfaceError if the automation call returns an error.
"""
- ret_dict = json.loads(self._SendJSONRequest(windex, json.dumps(cmd_dict)))
+ result = self._SendJSONRequest(windex, json.dumps(cmd_dict))
+ if len(result) == 0:
+ raise JSONInterfaceError('Automation call received no response.')
+ ret_dict = json.loads(result)
if ret_dict.has_key('error'):
raise JSONInterfaceError(ret_dict['error'])
return ret_dict
@@ -2288,7 +2291,7 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
pyauto_errors.JSONInterfaceError if the automation call returns an error.
"""
cmd_dict = { 'command': 'GetLoginInfo' }
- return self._GetResultFromJSONRequest(cmd_dict)
+ return self._GetResultFromJSONRequest(cmd_dict, windex=-1)
def LoginAsGuest(self):
"""Login to chromeos as a guest user.
@@ -2377,10 +2380,40 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
cmd_dict = { 'command': 'GetNetworkInfo' }
return self._GetResultFromJSONRequest(cmd_dict, windex=-1)
+ def NetworkScan(self):
+ """Causes ChromeOS to scan for available wifi networks.
+
+ Blocks until scanning is complete.
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ cmd_dict = { 'command': 'NetworkScan' }
+ self._GetResultFromJSONRequest(cmd_dict, windex=-1)
+
+ CONNECTION_ERROR_UNKNOWN = 0
+ CONNECTION_ERROR_OUT_OF_RANGE = 1
+ CONNECTION_ERROR_PIN_MISSING = 2
+ CONNECTION_ERROR_DHCP_FAILED = 3
+ CONNECTION_ERROR_CONNECT_FAILED = 4
+ CONNECTION_ERROR_BAD_PASSPHRASE = 5
+ CONNECTION_ERROR_BAD_WEPKEY = 6
+ CONNECTION_ERROR_ACTIVATION_FAILED = 7
+ CONNECTION_ERROR_NEED_EVDO = 8
+ CONNECTION_ERROR_NEED_HOME_NETWORK = 9
+ CONNECTION_ERROR_OTASP_FAILED = 10
+ CONNECTION_ERROR_AAA_FAILED = 11
+
def ConnectToWifiNetwork(self, service_path,
password='', identity='', certpath=''):
"""Connect to a wifi network by its service path.
+ Blocks until connection suceeds or fails.
dennis_jeffrey 2011/03/24 23:48:54 "suceeds" --> "succeeds"
dtu 2011/03/25 22:22:11 Done.
+
+ Returns:
+ A tuple. The first element is True on success and False on failure.
+ The second element contains an integer error code in case of failure.
stanleyw 2011/03/24 23:16:03 Rewrite as integer is too cumbersome to decode
dtu 2011/03/25 22:22:11 Done. Using string error messages instead and comm
stanleyw 2011/03/25 22:40:03 What are the possible values of error strings? Or
+
Raises:
pyauto_errors.JSONInterfaceError if the automation call returns an error.
"""
@@ -2391,7 +2424,26 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
'identity': identity,
'certpath': certpath,
}
- return self._GetResultFromJSONRequest(cmd_dict, windex=-1)
+ result = self._GetResultFromJSONRequest(cmd_dict, windex=-1)
+ if result.has_key('error_code'):
+ return (False, result['error_code'])
stanleyw 2011/03/24 23:16:03 result['error_code'] is too cumbersome to decode
dtu 2011/03/25 22:22:11 It's decoded for you, a caller of this function wi
+ else:
+ return (True, None)
+
+ def DisconnectFromWifiNetwork(self, service_path,
+ password='', identity='', certpath=''):
dennis_jeffrey 2011/03/24 23:48:54 Indent underneath first parameter in the previous
dtu 2011/03/25 22:22:11 Done.
+ """Disconnect from a wifi network by its service path.
+
+ Blocks until disconnect is complete.
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ cmd_dict = {
+ 'command': 'DisconnectFromWifiNetwork',
+ 'service_path': service_path,
+ }
+ self._GetResultFromJSONRequest(cmd_dict, windex=-1)
## ChromeOS section -- end
« chrome/test/functional/chromeos_wifi.py ('K') | « chrome/test/functional/chromeos_wifi.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698