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

Side by Side Diff: build/android/pylib/device/battery_utils_test.py

Issue 1057563002: [Android] Convert to BatteryUtils (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """ 6 """
7 Unit tests for the contents of battery_utils.py 7 Unit tests for the contents of battery_utils.py
8 """ 8 """
9 9
10 import logging 10 import logging
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 def testGetPackagePowerData(self): 135 def testGetPackagePowerData(self):
136 with self.assertCalls( 136 with self.assertCalls(
137 (self.call.device.RunShellCommand( 137 (self.call.device.RunShellCommand(
138 ['dumpsys', 'batterystats', '-c'], check_return=True), 138 ['dumpsys', 'batterystats', '-c'], check_return=True),
139 self._DUMPSYS_OUTPUT)): 139 self._DUMPSYS_OUTPUT)):
140 data = self.battery.GetPackagePowerData('test_package2') 140 data = self.battery.GetPackagePowerData('test_package2')
141 self.assertEqual(data, {'uid': '1001', 'data': [2.0]}) 141 self.assertEqual(data, {'uid': '1001', 'data': [2.0]})
142 142
143 143
144 class BatteryUtilsChargeDevice(BatteryUtilsTest):
145
146 @mock.patch('time.sleep', mock.Mock())
147 def testChargeDeviceToLevel(self):
148 with self.assertCalls(
149 (self.call.battery.SetCharging(True)),
150 (self.call.battery.GetBatteryInfo(), {'level': '50'}),
151 (self.call.battery.GetBatteryInfo(), {'level': '100'})):
152 self.battery.ChargeDeviceToLevel(95)
153
154
144 if __name__ == '__main__': 155 if __name__ == '__main__':
145 logging.getLogger().setLevel(logging.DEBUG) 156 logging.getLogger().setLevel(logging.DEBUG)
146 unittest.main(verbosity=2) 157 unittest.main(verbosity=2)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698