| 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 import logging | 10 import logging |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 | 89 |
| 90 class BatteryUtilsSetBatteryMeasurementTest(BatteryUtilsTest): | 90 class BatteryUtilsSetBatteryMeasurementTest(BatteryUtilsTest): |
| 91 | 91 |
| 92 def testBatteryMeasurement(self): | 92 def testBatteryMeasurement(self): |
| 93 with self.assertCalls( | 93 with self.assertCalls( |
| 94 (self.call.device.RunShellCommand( | 94 (self.call.device.RunShellCommand( |
| 95 mock.ANY, retries=0, single_line=True, | 95 mock.ANY, retries=0, single_line=True, |
| 96 timeout=10, check_return=True), '22'), | 96 timeout=10, check_return=True), '22'), |
| 97 (self.call.device.RunShellCommand( | 97 (self.call.device.RunShellCommand( |
| 98 ['dumpsys', 'battery', 'set', 'usb', '1'], check_return=True), []), | 98 ['dumpsys', 'battery', 'reset'], check_return=True), []), |
| 99 (self.call.device.RunShellCommand( | 99 (self.call.device.RunShellCommand( |
| 100 ['dumpsys', 'batterystats', '--reset'], check_return=True), []), | 100 ['dumpsys', 'batterystats', '--reset'], check_return=True), []), |
| 101 (self.call.device.RunShellCommand( | 101 (self.call.device.RunShellCommand( |
| 102 ['dumpsys', 'batterystats', '--charged', '--checkin'], | 102 ['dumpsys', 'batterystats', '--charged', '--checkin'], |
| 103 check_return=True), []), | 103 check_return=True), []), |
| 104 (self.call.device.RunShellCommand( | 104 (self.call.device.RunShellCommand( |
| 105 ['dumpsys', 'battery', 'set', 'ac', '0'], check_return=True), []), |
| 106 (self.call.device.RunShellCommand( |
| 105 ['dumpsys', 'battery', 'set', 'usb', '0'], check_return=True), []), | 107 ['dumpsys', 'battery', 'set', 'usb', '0'], check_return=True), []), |
| 106 (self.call.battery.GetCharging(), False), | 108 (self.call.battery.GetCharging(), False), |
| 107 (self.call.device.RunShellCommand( | 109 (self.call.device.RunShellCommand( |
| 108 ['dumpsys', 'battery', 'set', 'usb', '1'], check_return=True), []), | |
| 109 (self.call.device.RunShellCommand( | |
| 110 ['dumpsys', 'battery', 'reset'], check_return=True), []), | 110 ['dumpsys', 'battery', 'reset'], check_return=True), []), |
| 111 (self.call.battery.GetCharging(), True)): | 111 (self.call.battery.GetCharging(), True)): |
| 112 with self.battery.BatteryMeasurement(): | 112 with self.battery.BatteryMeasurement(): |
| 113 pass | 113 pass |
| 114 | 114 |
| 115 | 115 |
| 116 class BatteryUtilsGetPowerData(BatteryUtilsTest): | 116 class BatteryUtilsGetPowerData(BatteryUtilsTest): |
| 117 | 117 |
| 118 _DUMPSYS_OUTPUT = [ | 118 _DUMPSYS_OUTPUT = [ |
| 119 '9,0,i,uid,1000,test_package1', | 119 '9,0,i,uid,1000,test_package1', |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 207 |
| 208 def testGetCharging_unknown(self): | 208 def testGetCharging_unknown(self): |
| 209 with self.assertCall( | 209 with self.assertCall( |
| 210 self.call.battery.GetBatteryInfo(), {'level': '42'}): | 210 self.call.battery.GetBatteryInfo(), {'level': '42'}): |
| 211 self.assertFalse(self.battery.GetCharging()) | 211 self.assertFalse(self.battery.GetCharging()) |
| 212 | 212 |
| 213 | 213 |
| 214 if __name__ == '__main__': | 214 if __name__ == '__main__': |
| 215 logging.getLogger().setLevel(logging.DEBUG) | 215 logging.getLogger().setLevel(logging.DEBUG) |
| 216 unittest.main(verbosity=2) | 216 unittest.main(verbosity=2) |
| OLD | NEW |