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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """PyAuto: Python Interface to Chromium's Automation Proxy. 7 """PyAuto: Python Interface to Chromium's Automation Proxy.
8 8
9 PyAuto uses swig to expose Automation Proxy interfaces to Python. 9 PyAuto uses swig to expose Automation Proxy interfaces to Python.
10 For complete documentation on the functionality available, 10 For complete documentation on the functionality available,
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 windex: 0-based window index on which to work. Default: 0 (first window) 464 windex: 0-based window index on which to work. Default: 0 (first window)
465 Use -ve windex if the automation command does not apply to a 465 Use -ve windex if the automation command does not apply to a
466 browser window. example: chromeos login 466 browser window. example: chromeos login
467 467
468 Returns: 468 Returns:
469 a dictionary for the output returned by the automation channel. 469 a dictionary for the output returned by the automation channel.
470 470
471 Raises: 471 Raises:
472 pyauto_errors.JSONInterfaceError if the automation call returns an error. 472 pyauto_errors.JSONInterfaceError if the automation call returns an error.
473 """ 473 """
474 ret_dict = json.loads(self._SendJSONRequest(windex, json.dumps(cmd_dict))) 474 result = self._SendJSONRequest(windex, json.dumps(cmd_dict))
475 if len(result) == 0:
476 raise JSONInterfaceError('Automation call received no response.')
477 ret_dict = json.loads(result)
475 if ret_dict.has_key('error'): 478 if ret_dict.has_key('error'):
476 raise JSONInterfaceError(ret_dict['error']) 479 raise JSONInterfaceError(ret_dict['error'])
477 return ret_dict 480 return ret_dict
478 481
479 def GetBookmarkModel(self): 482 def GetBookmarkModel(self):
480 """Return the bookmark model as a BookmarkModel object. 483 """Return the bookmark model as a BookmarkModel object.
481 484
482 This is a snapshot of the bookmark model; it is not a proxy and 485 This is a snapshot of the bookmark model; it is not a proxy and
483 does not get updated as the bookmark model changes. 486 does not get updated as the bookmark model changes.
484 """ 487 """
(...skipping 1796 matching lines...) Expand 10 before | Expand all | Expand 10 after
2281 Sample: 2284 Sample:
2282 2285
2283 { u'is_logged_in': True, 2286 { u'is_logged_in': True,
2284 u'is_guest': False, 2287 u'is_guest': False,
2285 u'is_screen_locked': False} 2288 u'is_screen_locked': False}
2286 2289
2287 Raises: 2290 Raises:
2288 pyauto_errors.JSONInterfaceError if the automation call returns an error. 2291 pyauto_errors.JSONInterfaceError if the automation call returns an error.
2289 """ 2292 """
2290 cmd_dict = { 'command': 'GetLoginInfo' } 2293 cmd_dict = { 'command': 'GetLoginInfo' }
2291 return self._GetResultFromJSONRequest(cmd_dict) 2294 return self._GetResultFromJSONRequest(cmd_dict, windex=-1)
2292 2295
2293 def LoginAsGuest(self): 2296 def LoginAsGuest(self):
2294 """Login to chromeos as a guest user. 2297 """Login to chromeos as a guest user.
2295 2298
2296 Waits until logged in. 2299 Waits until logged in.
2297 Should be displaying the login screen to work. 2300 Should be displaying the login screen to work.
2298 2301
2299 Raises: 2302 Raises:
2300 pyauto_errors.JSONInterfaceError if the automation call returns an error. 2303 pyauto_errors.JSONInterfaceError if the automation call returns an error.
2301 """ 2304 """
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2370 2373
2371 def GetNetworkInfo(self): 2374 def GetNetworkInfo(self):
2372 """Get details about ethernet, wifi, and cellular networks on chromeos. 2375 """Get details about ethernet, wifi, and cellular networks on chromeos.
2373 2376
2374 Raises: 2377 Raises:
2375 pyauto_errors.JSONInterfaceError if the automation call returns an error. 2378 pyauto_errors.JSONInterfaceError if the automation call returns an error.
2376 """ 2379 """
2377 cmd_dict = { 'command': 'GetNetworkInfo' } 2380 cmd_dict = { 'command': 'GetNetworkInfo' }
2378 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) 2381 return self._GetResultFromJSONRequest(cmd_dict, windex=-1)
2379 2382
2383 def NetworkScan(self):
2384 """Causes ChromeOS to scan for available wifi networks.
2385
2386 Blocks until scanning is complete.
2387
2388 Raises:
2389 pyauto_errors.JSONInterfaceError if the automation call returns an error.
2390 """
2391 cmd_dict = { 'command': 'NetworkScan' }
2392 self._GetResultFromJSONRequest(cmd_dict, windex=-1)
2393
2394 CONNECTION_ERROR_UNKNOWN = 0
2395 CONNECTION_ERROR_OUT_OF_RANGE = 1
2396 CONNECTION_ERROR_PIN_MISSING = 2
2397 CONNECTION_ERROR_DHCP_FAILED = 3
2398 CONNECTION_ERROR_CONNECT_FAILED = 4
2399 CONNECTION_ERROR_BAD_PASSPHRASE = 5
2400 CONNECTION_ERROR_BAD_WEPKEY = 6
2401 CONNECTION_ERROR_ACTIVATION_FAILED = 7
2402 CONNECTION_ERROR_NEED_EVDO = 8
2403 CONNECTION_ERROR_NEED_HOME_NETWORK = 9
2404 CONNECTION_ERROR_OTASP_FAILED = 10
2405 CONNECTION_ERROR_AAA_FAILED = 11
2406
2380 def ConnectToWifiNetwork(self, service_path, 2407 def ConnectToWifiNetwork(self, service_path,
2381 password='', identity='', certpath=''): 2408 password='', identity='', certpath=''):
2382 """Connect to a wifi network by its service path. 2409 """Connect to a wifi network by its service path.
2383 2410
2411 Blocks until connection suceeds or fails.
dennis_jeffrey 2011/03/24 23:48:54 "suceeds" --> "succeeds"
dtu 2011/03/25 22:22:11 Done.
2412
2413 Returns:
2414 A tuple. The first element is True on success and False on failure.
2415 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
2416
2384 Raises: 2417 Raises:
2385 pyauto_errors.JSONInterfaceError if the automation call returns an error. 2418 pyauto_errors.JSONInterfaceError if the automation call returns an error.
2386 """ 2419 """
2387 cmd_dict = { 2420 cmd_dict = {
2388 'command': 'ConnectToWifiNetwork', 2421 'command': 'ConnectToWifiNetwork',
2389 'service_path': service_path, 2422 'service_path': service_path,
2390 'password': password, 2423 'password': password,
2391 'identity': identity, 2424 'identity': identity,
2392 'certpath': certpath, 2425 'certpath': certpath,
2393 } 2426 }
2394 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) 2427 result = self._GetResultFromJSONRequest(cmd_dict, windex=-1)
2428 if result.has_key('error_code'):
2429 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
2430 else:
2431 return (True, None)
2432
2433 def DisconnectFromWifiNetwork(self, service_path,
2434 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.
2435 """Disconnect from a wifi network by its service path.
2436
2437 Blocks until disconnect is complete.
2438
2439 Raises:
2440 pyauto_errors.JSONInterfaceError if the automation call returns an error.
2441 """
2442 cmd_dict = {
2443 'command': 'DisconnectFromWifiNetwork',
2444 'service_path': service_path,
2445 }
2446 self._GetResultFromJSONRequest(cmd_dict, windex=-1)
2395 2447
2396 ## ChromeOS section -- end 2448 ## ChromeOS section -- end
2397 2449
2398 2450
2399 class PyUITestSuite(pyautolib.PyUITestSuiteBase, unittest.TestSuite): 2451 class PyUITestSuite(pyautolib.PyUITestSuiteBase, unittest.TestSuite):
2400 """Base TestSuite for PyAuto UI tests.""" 2452 """Base TestSuite for PyAuto UI tests."""
2401 2453
2402 def __init__(self, args): 2454 def __init__(self, args):
2403 pyautolib.PyUITestSuiteBase.__init__(self, args) 2455 pyautolib.PyUITestSuiteBase.__init__(self, args)
2404 2456
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
2784 if self._options.verbose: 2836 if self._options.verbose:
2785 verbosity = 2 2837 verbosity = 2
2786 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) 2838 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite)
2787 del loaded_tests # Need to destroy test cases before the suite 2839 del loaded_tests # Need to destroy test cases before the suite
2788 del pyauto_suite 2840 del pyauto_suite
2789 sys.exit(not result.wasSuccessful()) 2841 sys.exit(not result.wasSuccessful())
2790 2842
2791 2843
2792 if __name__ == '__main__': 2844 if __name__ == '__main__':
2793 Main() 2845 Main()
OLDNEW
« 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