OLD | NEW |
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 Loading... |
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 Loading... |
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) |
OLD | NEW |