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

Unified Diff: chrome/test/functional/chromeos_battery.py

Issue 6990069: Adding PyAuto Battery test for ChromeOS (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/functional/chromeos_battery.py
===================================================================
--- chrome/test/functional/chromeos_battery.py (revision 0)
+++ chrome/test/functional/chromeos_battery.py (revision 0)
@@ -0,0 +1,120 @@
+#!/usr/bin/python
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that
+# can be found in the LICENSE file.
+
+import os
+import time
dtu 2011/06/01 01:09:23 Remove extra import.
xot 2011/06/06 02:27:19 Done.
+
+import pyauto_functional # Must be imported before pyauto
+import pyauto
+
+from chromeos.power_strip import PowerStrip
+
+class ChromeosBattery(pyauto.PyUITest):
+ """Tests ChromeOS Battery Status API.
Nirnimesh 2011/06/01 00:33:00 nit: leave a blank line after this line Remove 'A
xot 2011/06/06 02:27:19 Done.
+ Preconditions:
+ 1) Device under test (DUT) is connected to the corporate LAN
Nirnimesh 2011/06/01 00:33:00 remove reference to 'corporate'. Just mention that
xot 2011/06/06 02:27:19 Done.
+ LAN via Ethernet-to-USB adapter plugged into one of its
+ USB ports.
+ 2) AC power cable is connected to the DUT, and plugged into
+ the IP controlled Power Switch, outlet #4, located in the
Nirnimesh 2011/06/01 00:33:00 remove name of the lab
xot 2011/06/06 02:27:19 Done.
+ Oyster Bay lab.
+ 3) Battery is installed in the DUT, and battery is not fully
+ discharged.
+
+ Note about calculation time:
+ When AC power is turned off or on, the battery will take from 2
+ to 60 seconds to calculate the time left. While calculating, the
+ keys 'battery_time_to_full' and 'battery_time_to_empty' are
+ absent.
+ """
+
+ _OUTLET_WITH_BATTERY = '.a4'
dtu 2011/06/01 01:09:23 Put this in the configuration file and read it fro
xot 2011/06/06 02:27:19 Done.
+ _BATTERY_CONFIG_FILE = os.path.join(pyauto.PyUITest.DataDir(),
+ 'pyauto_private', 'chromeos', 'power',
dtu 2011/06/01 01:09:23 nit: Indent these lines by one space.
xot 2011/06/06 02:27:19 Done.
+ 'battery_testbed_config')
dtu 2011/06/01 01:09:23 Does this configuration file exist yet? Please sta
xot 2011/06/06 02:27:19 Yes file exists. It was sent out as issue https://
+
+ def setUp(self):
+ pyauto.PyUITest.setUp(self)
+ self.InitPowerStrip()
+
+ def tearDown(self):
+ # Leave power outlet On so battery does not discharge
+ self._power_strip.PowerOn(ChromeosBattery._OUTLET_WITH_BATTERY)
+ pyauto.PyUITest.tearDown(self)
+
+ def InitPowerStrip(self):
+ self.assertTrue(
Nirnimesh 2011/06/01 00:33:00 replace self.assertTrue with 'assert' Use self.as
xot 2011/06/06 02:27:19 Done.
+ lambda: os.path.exists(ChromeosBattery._BATTERY_CONFIG_FILE),
+ msg = 'Power Strip configuration file does not exist.')
+ power_config = pyauto.PyUITest.EvalDataFrom(
+ ChromeosBattery._BATTERY_CONFIG_FILE)
+ self._power_strip = PowerStrip(power_config['strip_ip'])
+
+ def WaitUntilBatteryTimeIsCalculated(self):
+ battery_status = self.GetBatteryInfo()
+ if battery_status.get('line_power_on'):
+ time_key = 'battery_time_to_full'
+ else:
+ time_key = 'battery_time_to_empty'
+ return self.WaitUntil(lambda: self.GetBatteryInfo().get(time_key) != None,
+ timeout=60,
+ retry_sleep=2)
+
+ def testBatteryChargesWhenACisOn(self):
+ """AC power ON to CrOS device with battery."""
+ self._power_strip.PowerOn(ChromeosBattery._OUTLET_WITH_BATTERY)
+
+ # Get info about charging battery
+ self.assertTrue(self.WaitUntilBatteryTimeIsCalculated(),
+ msg='Battery charge time was not calculated')
+ battery_status = self.GetBatteryInfo()
+ self.assertTrue(battery_status.get('battery_is_present'),
+ msg='Battery is not present.')
+ self.assertTrue(battery_status.get('line_power_on'),
+ msg='Line power is off.')
+ self.assertTrue(battery_status.get('battery_time_to_full') >= 0,
+ msg='Battery charge time is negative.')
+
+ def testBatteryDischargesWhenACisOff(self):
+ """AC power OFF to CrOS device with battery."""
+ self._power_strip.PowerOff(ChromeosBattery._OUTLET_WITH_BATTERY)
+
+ # Get info about discharging battery
+ self.assertTrue(self.WaitUntilBatteryTimeIsCalculated(),
+ msg='Battery discharge time was not calculated.')
+ battery_status = self.GetBatteryInfo()
+ self.assertTrue(battery_status.get('battery_is_present'),
+ msg='Battery is not present.')
+ self.assertFalse(battery_status.get('line_power_on'),
+ msg='Line power is off.')
+ self.assertTrue(battery_status.get('battery_time_to_empty') >= 0,
+ msg='Battery discharge time is negative.')
+
+ def testBatteryTimesAreDifferent(self):
+ """Time until full is different than Time until empty"""
+ # Turn AC Power ON
+ self._power_strip.PowerOn(ChromeosBattery._OUTLET_WITH_BATTERY)
+
+ # Get charging battery time to full
+ self.WaitUntilBatteryTimeIsCalculated()
+ battery_status = self.GetBatteryInfo()
+ time_to_full = battery_status.get('battery_time_to_full')
+
+ # Turn AC Power OFF
+ self._power_strip.PowerOff(ChromeosBattery._OUTLET_WITH_BATTERY)
+
+ # Get discharging battery time to empty
+ self.WaitUntilBatteryTimeIsCalculated()
+ battery_status = self.GetBatteryInfo()
+ time_to_empty = battery_status.get('battery_time_to_empty')
+
+ # Compare times
+ self.assertNotEqual(time_to_full, time_to_empty,
+ msg='Battery time to full equals time to empty. '
+ 'Though very unlikely, this is not impossible. '
+ 'If test failed falsely, Kris owes Scott a beer. ')
+
Nirnimesh 2011/06/01 00:33:00 nit: need another blank line here
xot 2011/06/06 02:27:19 Done.
+if __name__ == '__main__':
+ pyauto_functional.Main()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698