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

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

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 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
« no previous file with comments | « build/android/pylib/device/battery_utils.py ('k') | build/android/pylib/device/device_utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 # pylint: disable=W0613 10 # pylint: disable=W0613
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 (self.call.device.FileExists(mock.ANY), True), 97 (self.call.device.FileExists(mock.ANY), True),
98 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []), 98 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []),
99 (self.call.battery.GetCharging(), True), 99 (self.call.battery.GetCharging(), True),
100 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []), 100 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []),
101 (self.call.battery.GetCharging(), False)): 101 (self.call.battery.GetCharging(), False)):
102 self.battery.SetCharging(False) 102 self.battery.SetCharging(False)
103 103
104 104
105 class BatteryUtilsSetBatteryMeasurementTest(BatteryUtilsTest): 105 class BatteryUtilsSetBatteryMeasurementTest(BatteryUtilsTest):
106 106
107 @mock.patch('time.sleep', mock.Mock())
107 def testBatteryMeasurement(self): 108 def testBatteryMeasurement(self):
108 with self.assertCalls( 109 with self.assertCalls(
109 (self.call.device.RunShellCommand( 110 (self.call.device.RunShellCommand(
110 mock.ANY, retries=0, single_line=True, 111 mock.ANY, retries=0, single_line=True,
111 timeout=10, check_return=True), '22'), 112 timeout=10, check_return=True), '22'),
112 (self.call.device.RunShellCommand( 113 (self.call.device.RunShellCommand(
113 ['dumpsys', 'battery', 'reset'], check_return=True), []), 114 ['dumpsys', 'battery', 'set', 'usb', '1'], check_return=True), []),
115 (self.call.device.RunShellCommand(
116 ['dumpsys', 'battery', 'set', 'ac', '1'], check_return=True), []),
114 (self.call.device.RunShellCommand( 117 (self.call.device.RunShellCommand(
115 ['dumpsys', 'batterystats', '--reset'], check_return=True), []), 118 ['dumpsys', 'batterystats', '--reset'], check_return=True), []),
116 (self.call.device.RunShellCommand( 119 (self.call.device.RunShellCommand(
117 ['dumpsys', 'batterystats', '--charged', '--checkin'], 120 ['dumpsys', 'batterystats', '--charged', '--checkin'],
118 check_return=True), []), 121 check_return=True, large_output=True), []),
119 (self.call.device.RunShellCommand( 122 (self.call.device.RunShellCommand(
120 ['dumpsys', 'battery', 'set', 'ac', '0'], check_return=True), []), 123 ['dumpsys', 'battery', 'set', 'ac', '0'], check_return=True), []),
121 (self.call.device.RunShellCommand( 124 (self.call.device.RunShellCommand(
122 ['dumpsys', 'battery', 'set', 'usb', '0'], check_return=True), []), 125 ['dumpsys', 'battery', 'set', 'usb', '0'], check_return=True), []),
123 (self.call.battery.GetCharging(), False), 126 (self.call.battery.GetCharging(), False),
124 (self.call.device.RunShellCommand( 127 (self.call.device.RunShellCommand(
125 ['dumpsys', 'battery', 'reset'], check_return=True), []), 128 ['dumpsys', 'battery', 'reset'], check_return=True), []),
126 (self.call.battery.GetCharging(), True)): 129 (self.call.battery.GetCharging(), True)):
127 with self.battery.BatteryMeasurement(): 130 with self.battery.BatteryMeasurement():
128 pass 131 pass
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 @mock.patch('time.sleep', mock.Mock()) 322 @mock.patch('time.sleep', mock.Mock())
320 def testLetBatteryCoolToTemperature_startOver(self): 323 def testLetBatteryCoolToTemperature_startOver(self):
321 with self.assertCalls( 324 with self.assertCalls(
322 (self.call.battery.GetBatteryInfo(), {'temperature': '500'}), 325 (self.call.battery.GetBatteryInfo(), {'temperature': '500'}),
323 (self.call.battery.GetBatteryInfo(), {'temperature': '400'})): 326 (self.call.battery.GetBatteryInfo(), {'temperature': '400'})):
324 self.battery.LetBatteryCoolToTemperature(400) 327 self.battery.LetBatteryCoolToTemperature(400)
325 328
326 if __name__ == '__main__': 329 if __name__ == '__main__':
327 logging.getLogger().setLevel(logging.DEBUG) 330 logging.getLogger().setLevel(logging.DEBUG)
328 unittest.main(verbosity=2) 331 unittest.main(verbosity=2)
OLDNEW
« no previous file with comments | « build/android/pylib/device/battery_utils.py ('k') | build/android/pylib/device/device_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698