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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 ['dumpsys', 'battery'], check_return=True), ['UPDATES STOPPED']), | 432 ['dumpsys', 'battery'], check_return=True), ['UPDATES STOPPED']), |
433 (self.call.battery.GetCharging(), True)): | 433 (self.call.battery.GetCharging(), True)): |
434 self.battery.TieredSetCharging(True) | 434 self.battery.TieredSetCharging(True) |
435 | 435 |
436 @mock.patch('time.sleep', mock.Mock()) | 436 @mock.patch('time.sleep', mock.Mock()) |
437 def testTieredSetCharging_softwareSetFalse(self): | 437 def testTieredSetCharging_softwareSetFalse(self): |
438 self.battery._cache['profile'] = self._NEXUS_6 | 438 self.battery._cache['profile'] = self._NEXUS_6 |
439 with self.assertCalls( | 439 with self.assertCalls( |
440 (self.call.battery.GetCharging(), True), | 440 (self.call.battery.GetCharging(), True), |
441 (self.call.battery._ClearPowerData(), True), | 441 (self.call.battery._ClearPowerData(), True), |
442 (self.call.battery._ClearPowerData(), True), | |
443 (self.call.device.RunShellCommand( | 442 (self.call.device.RunShellCommand( |
444 ['dumpsys', 'battery', 'set', 'ac', '0'], check_return=True), []), | 443 ['dumpsys', 'battery', 'set', 'ac', '0'], check_return=True), []), |
445 (self.call.device.RunShellCommand( | 444 (self.call.device.RunShellCommand( |
446 ['dumpsys', 'battery', 'set', 'usb', '0'], check_return=True), []), | 445 ['dumpsys', 'battery', 'set', 'usb', '0'], check_return=True), []), |
447 (self.call.battery.GetCharging(), False)): | 446 (self.call.battery.GetCharging(), False)): |
448 self.battery.TieredSetCharging(False) | 447 self.battery.TieredSetCharging(False) |
449 | 448 |
450 @mock.patch('time.sleep', mock.Mock()) | 449 @mock.patch('time.sleep', mock.Mock()) |
451 def testTieredSetCharging_hardwareSetTrue(self): | 450 def testTieredSetCharging_hardwareSetTrue(self): |
452 self.battery._cache['profile'] = self._NEXUS_5 | 451 self.battery._cache['profile'] = self._NEXUS_5 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 (self.call.battery.SetCharging(True))): | 484 (self.call.battery.SetCharging(True))): |
486 with self.battery.PowerMeasurement(): | 485 with self.battery.PowerMeasurement(): |
487 pass | 486 pass |
488 | 487 |
489 @mock.patch('time.sleep', mock.Mock()) | 488 @mock.patch('time.sleep', mock.Mock()) |
490 def testPowerMeasurement_software(self): | 489 def testPowerMeasurement_software(self): |
491 self.battery._cache['profile'] = self._NEXUS_6 | 490 self.battery._cache['profile'] = self._NEXUS_6 |
492 with self.assertCalls( | 491 with self.assertCalls( |
493 (self.call.battery.GetCharging(), True), | 492 (self.call.battery.GetCharging(), True), |
494 (self.call.battery._ClearPowerData(), True), | 493 (self.call.battery._ClearPowerData(), True), |
495 (self.call.battery._ClearPowerData(), True), | |
496 (self.call.device.RunShellCommand( | 494 (self.call.device.RunShellCommand( |
497 ['dumpsys', 'battery', 'set', 'ac', '0'], check_return=True), []), | 495 ['dumpsys', 'battery', 'set', 'ac', '0'], check_return=True), []), |
498 (self.call.device.RunShellCommand( | 496 (self.call.device.RunShellCommand( |
499 ['dumpsys', 'battery', 'set', 'usb', '0'], check_return=True), []), | 497 ['dumpsys', 'battery', 'set', 'usb', '0'], check_return=True), []), |
500 (self.call.battery.GetCharging(), False), | 498 (self.call.battery.GetCharging(), False), |
501 (self.call.battery.GetCharging(), False), | 499 (self.call.battery.GetCharging(), False), |
502 (self.call.device.RunShellCommand( | 500 (self.call.device.RunShellCommand( |
503 ['dumpsys', 'battery', 'reset'], check_return=True), []), | 501 ['dumpsys', 'battery', 'reset'], check_return=True), []), |
504 (self.call.battery.GetCharging(), False), | 502 (self.call.battery.GetCharging(), False), |
505 (self.call.device.RunShellCommand( | 503 (self.call.device.RunShellCommand( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 ['9,1000,l,pwi,uid,0.0327']), | 563 ['9,1000,l,pwi,uid,0.0327']), |
566 (self.call.device.RunShellCommand( | 564 (self.call.device.RunShellCommand( |
567 ['dumpsys', 'battery', 'reset'], check_return=True), [])): | 565 ['dumpsys', 'battery', 'reset'], check_return=True), [])): |
568 with self.assertRaises(device_errors.CommandFailedError): | 566 with self.assertRaises(device_errors.CommandFailedError): |
569 self.battery._ClearPowerData() | 567 self.battery._ClearPowerData() |
570 | 568 |
571 | 569 |
572 if __name__ == '__main__': | 570 if __name__ == '__main__': |
573 logging.getLogger().setLevel(logging.DEBUG) | 571 logging.getLogger().setLevel(logging.DEBUG) |
574 unittest.main(verbosity=2) | 572 unittest.main(verbosity=2) |
OLD | NEW |