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

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

Issue 6760013: GetBatteryInfo() battery automation hook. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge. 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
« no previous file with comments | « chrome/test/functional/chromeos_power.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
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index d1b99fb044c0b3e21bc733f4ef057dc7f4adc1c6..2439928496080fb960b3c5f8a3a3516ac751c52d 100644
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -2407,6 +2407,42 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
cmd_dict = { 'command': 'SignoutInScreenLocker' }
self._GetResultFromJSONRequest(cmd_dict, windex=-1)
+ def GetBatteryInfo(self):
+ """Get details about battery state.
+
+ Returns:
+ A dictionary with the following keys:
+
+ 'battery_is_present' : bool
+ 'line_power_on' : bool
+ if 'battery_is_present':
+ 'battery_percentage' : float (0 ~ 100)
+ 'battery_fully_charged' : bool
+ if 'line_power_on':
+ 'battery_time_to_full' : int (seconds)
+ else:
+ 'battery_time_to_empty' : int (seconds)
+
+ If it is still calculating the time left, 'battery_time_to_full'
+ and 'battery_time_to_empty' will be absent.
+
+ Use 'battery_fully_charged' instead of 'battery_percentage'
+ or 'battery_time_to_full' to determine whether the battery
+ is fully charged, since the percentage is only approximate.
+
+ Sample:
+ { u'battery_is_present': True,
+ u'line_power_on': False,
+ u'battery_time_to_empty': 29617,
+ u'battery_percentage': 100.0,
+ u'battery_fully_charged': False }
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ cmd_dict = { 'command': 'GetBatteryInfo' }
+ return self._GetResultFromJSONRequest(cmd_dict, windex=-1)
+
def GetNetworkInfo(self):
"""Get details about ethernet, wifi, and cellular networks on chromeos.
« no previous file with comments | « chrome/test/functional/chromeos_power.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698