diff options
author | dtu@chromium.org <dtu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-26 00:33:21 +0000 |
---|---|---|
committer | dtu@chromium.org <dtu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-26 00:33:21 +0000 |
commit | 8989bb4acf8e75ebbdf50d0fd2145fcbbdfc928a (patch) | |
tree | c3909c42ab25b1d4c3a769ca5d75c21685e598a5 /chrome/test | |
parent | 67c5be79a53904e4ab5a6617bf9cbad9f7f5de6f (diff) | |
download | chromium_src-8989bb4acf8e75ebbdf50d0fd2145fcbbdfc928a.zip chromium_src-8989bb4acf8e75ebbdf50d0fd2145fcbbdfc928a.tar.gz chromium_src-8989bb4acf8e75ebbdf50d0fd2145fcbbdfc928a.tar.bz2 |
ConnectToWifiNetwork() is now blocking.
Add DisconnectFromWifiNetwork(), which is also blocking.
Add NetworkScan(), which is also blocking.
Move chromeos automation observers into their own file.
Add better error message for when automation calls time out.
BUG=chromium-os:12727
TEST=Mostly manual. Automated tests will be set up in a lab with real wifi access points.
Review URL: http://codereview.chromium.org/6732040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79476 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/functional/chromeos_wifi.py | 4 | ||||
-rw-r--r-- | chrome/test/pyautolib/pyauto.py | 46 |
2 files changed, 47 insertions, 3 deletions
diff --git a/chrome/test/functional/chromeos_wifi.py b/chrome/test/functional/chromeos_wifi.py index 1d87e74..012f540 100644 --- a/chrome/test/functional/chromeos_wifi.py +++ b/chrome/test/functional/chromeos_wifi.py @@ -18,6 +18,10 @@ class ChromeosWifi(chromeos_network.PyNetworkUITest): self.assertTrue(result) logging.debug(result) + def testNetworkScan(self): + """Basic check to ensure that a network scan doesn't throw errors.""" + self.NetworkScan() + if __name__ == '__main__': pyauto_functional.Main() diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py index 2f7e371..edb4243 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,28 @@ 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) + def ConnectToWifiNetwork(self, service_path, password='', identity='', certpath=''): """Connect to a wifi network by its service path. + Blocks until connection succeeds or fails. + + Returns: + A tuple. + The first element is True on success and False on failure. + The second element is None on success or an error string on failure. + Raises: pyauto_errors.JSONInterfaceError if the automation call returns an error. """ @@ -2391,7 +2412,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']) + else: + return (True, None) + + def DisconnectFromWifiNetwork(self, service_path, + password='', identity='', certpath=''): + """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 |