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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) |
OLD | NEW |