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

Side by Side Diff: chrome/test/pyautolib/pyauto.py

Issue 6760013: GetBatteryInfo() battery automation hook. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add chromeos_power.py 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 2353 matching lines...) Expand 10 before | Expand all | Expand 10 after
2364 2364
2365 Effectively the same as clicking the "Sign out" link on the screen locker. 2365 Effectively the same as clicking the "Sign out" link on the screen locker.
2366 Screen should be locked for this to work. 2366 Screen should be locked for this to work.
2367 2367
2368 Raises: 2368 Raises:
2369 pyauto_errors.JSONInterfaceError if the automation call returns an error. 2369 pyauto_errors.JSONInterfaceError if the automation call returns an error.
2370 """ 2370 """
2371 cmd_dict = { 'command': 'SignoutInScreenLocker' } 2371 cmd_dict = { 'command': 'SignoutInScreenLocker' }
2372 self._GetResultFromJSONRequest(cmd_dict, windex=-1) 2372 self._GetResultFromJSONRequest(cmd_dict, windex=-1)
2373 2373
2374 def GetBatteryInfo(self):
2375 """Get details about battery state.
2376
2377 Returns:
2378 A dictionary with the following keys:
2379
2380 'battery_is_present' : bool
2381 'line_power_on' : bool
2382 if 'battery_is_present':
2383 'battery_percentage' : float (0 ~ 100)
2384 'battery_fully_charged' : bool
2385 if 'line_power_on':
2386 'battery_time_to_full' : int (seconds)
2387 else:
2388 'battery_time_to_empty' : int (seconds)
2389
2390 If it is still calculating the time left, 'battery_time_to_full'
2391 and 'battery_time_to_empty' will be absent.
2392
2393 Use 'battery_fully_charged' instead of 'battery_percentage'
2394 of 'battery_time_to_full' to determine whether the battery
dennis_jeffrey 2011/03/29 15:21:31 "of" --> "or"
2395 is fully charged, since the percentage is only approximate.
2396
2397 Sample:
2398 { u'battery_is_present': True,
2399 u'line_power_on': False,
2400 u'battery_time_to_empty': 29617,
2401 u'battery_percentage': 100.0,
2402 u'battery_fully_charged': False }
2403
2404 Raises:
2405 pyauto_errors.JSONInterfaceError if the automation call returns an error.
2406 """
2407 cmd_dict = { 'command': 'GetBatteryInfo' }
2408 return self._GetResultFromJSONRequest(cmd_dict, windex=-1)
2409
2374 def GetNetworkInfo(self): 2410 def GetNetworkInfo(self):
2375 """Get details about ethernet, wifi, and cellular networks on chromeos. 2411 """Get details about ethernet, wifi, and cellular networks on chromeos.
2376 2412
2377 Raises: 2413 Raises:
2378 pyauto_errors.JSONInterfaceError if the automation call returns an error. 2414 pyauto_errors.JSONInterfaceError if the automation call returns an error.
2379 """ 2415 """
2380 cmd_dict = { 'command': 'GetNetworkInfo' } 2416 cmd_dict = { 'command': 'GetNetworkInfo' }
2381 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) 2417 return self._GetResultFromJSONRequest(cmd_dict, windex=-1)
2382 2418
2383 def NetworkScan(self): 2419 def NetworkScan(self):
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
2824 if self._options.verbose: 2860 if self._options.verbose:
2825 verbosity = 2 2861 verbosity = 2
2826 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) 2862 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite)
2827 del loaded_tests # Need to destroy test cases before the suite 2863 del loaded_tests # Need to destroy test cases before the suite
2828 del pyauto_suite 2864 del pyauto_suite
2829 sys.exit(not result.wasSuccessful()) 2865 sys.exit(not result.wasSuccessful())
2830 2866
2831 2867
2832 if __name__ == '__main__': 2868 if __name__ == '__main__':
2833 Main() 2869 Main()
OLDNEW
« chrome/test/functional/chromeos_power.py ('K') | « chrome/test/functional/chromeos_power.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698