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 22 matching lines...) Expand all Loading... |
33 _DUMPSYS_OUTPUT = [ | 33 _DUMPSYS_OUTPUT = [ |
34 '9,0,i,uid,1000,test_package1', | 34 '9,0,i,uid,1000,test_package1', |
35 '9,0,i,uid,1001,test_package2', | 35 '9,0,i,uid,1001,test_package2', |
36 '9,1000,l,pwi,uid,1', | 36 '9,1000,l,pwi,uid,1', |
37 '9,1001,l,pwi,uid,2' | 37 '9,1001,l,pwi,uid,2' |
38 ] | 38 ] |
39 | 39 |
40 | 40 |
41 class BatteryUtilsTest(mock_calls.TestCase): | 41 class BatteryUtilsTest(mock_calls.TestCase): |
42 | 42 |
| 43 _NEXUS_5 = { |
| 44 'name': 'Nexus 5', |
| 45 'witness_file': '/sys/kernel/debug/bq24192/INPUT_SRC_CONT', |
| 46 'enable_command': ( |
| 47 'echo 0x4A > /sys/kernel/debug/bq24192/INPUT_SRC_CONT && ' |
| 48 'echo 1 > /sys/class/power_supply/usb/online'), |
| 49 'disable_command': ( |
| 50 'echo 0xCA > /sys/kernel/debug/bq24192/INPUT_SRC_CONT && ' |
| 51 'chmod 644 /sys/class/power_supply/usb/online && ' |
| 52 'echo 0 > /sys/class/power_supply/usb/online'), |
| 53 'charge_counter': None, |
| 54 'voltage': None, |
| 55 'current': None, |
| 56 } |
| 57 |
| 58 _NEXUS_6 = { |
| 59 'name': 'Nexus 6', |
| 60 'witness_file': None, |
| 61 'enable_command': None, |
| 62 'disable_command': None, |
| 63 'charge_counter': ( |
| 64 '/sys/class/power_supply/max170xx_battery/charge_counter_ext'), |
| 65 'voltage': '/sys/class/power_supply/max170xx_battery/voltage_now', |
| 66 'current': '/sys/class/power_supply/max170xx_battery/current_now', |
| 67 } |
| 68 |
| 69 _NEXUS_10 = { |
| 70 'name': 'Nexus 10', |
| 71 'witness_file': None, |
| 72 'enable_command': None, |
| 73 'disable_command': None, |
| 74 'charge_counter': ( |
| 75 '/sys/class/power_supply/ds2784-fuelgauge/charge_counter_ext'), |
| 76 'voltage': '/sys/class/power_supply/ds2784-fuelgauge/voltage_now', |
| 77 'current': '/sys/class/power_supply/ds2784-fuelgauge/current_now', |
| 78 } |
| 79 |
43 def ShellError(self, output=None, status=1): | 80 def ShellError(self, output=None, status=1): |
44 def action(cmd, *args, **kwargs): | 81 def action(cmd, *args, **kwargs): |
45 raise device_errors.AdbShellCommandFailedError( | 82 raise device_errors.AdbShellCommandFailedError( |
46 cmd, output, status, str(self.device)) | 83 cmd, output, status, str(self.device)) |
47 if output is None: | 84 if output is None: |
48 output = 'Permission denied\n' | 85 output = 'Permission denied\n' |
49 return action | 86 return action |
50 | 87 |
51 def setUp(self): | 88 def setUp(self): |
52 self.adb = device_utils_test._AdbWrapperMock('0123456789abcdef') | 89 self.adb = device_utils_test._AdbWrapperMock('0123456789abcdef') |
(...skipping 16 matching lines...) Expand all Loading... |
69 with self.assertRaises(TypeError): | 106 with self.assertRaises(TypeError): |
70 battery_utils.BatteryUtils(None) | 107 battery_utils.BatteryUtils(None) |
71 with self.assertRaises(TypeError): | 108 with self.assertRaises(TypeError): |
72 battery_utils.BatteryUtils('') | 109 battery_utils.BatteryUtils('') |
73 | 110 |
74 | 111 |
75 class BatteryUtilsSetChargingTest(BatteryUtilsTest): | 112 class BatteryUtilsSetChargingTest(BatteryUtilsTest): |
76 | 113 |
77 @mock.patch('time.sleep', mock.Mock()) | 114 @mock.patch('time.sleep', mock.Mock()) |
78 def testSetCharging_enabled(self): | 115 def testSetCharging_enabled(self): |
| 116 self.battery._cache['profile'] = self._NEXUS_5 |
79 with self.assertCalls( | 117 with self.assertCalls( |
80 (self.call.device.FileExists(mock.ANY), True), | |
81 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []), | 118 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []), |
82 (self.call.battery.GetCharging(), False), | 119 (self.call.battery.GetCharging(), False), |
83 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []), | 120 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []), |
84 (self.call.battery.GetCharging(), True)): | 121 (self.call.battery.GetCharging(), True)): |
85 self.battery.SetCharging(True) | 122 self.battery.SetCharging(True) |
86 | 123 |
87 def testSetCharging_alreadyEnabled(self): | 124 def testSetCharging_alreadyEnabled(self): |
| 125 self.battery._cache['profile'] = self._NEXUS_5 |
88 with self.assertCalls( | 126 with self.assertCalls( |
89 (self.call.device.FileExists(mock.ANY), True), | |
90 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []), | 127 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []), |
91 (self.call.battery.GetCharging(), True)): | 128 (self.call.battery.GetCharging(), True)): |
92 self.battery.SetCharging(True) | 129 self.battery.SetCharging(True) |
93 | 130 |
94 @mock.patch('time.sleep', mock.Mock()) | 131 @mock.patch('time.sleep', mock.Mock()) |
95 def testSetCharging_disabled(self): | 132 def testSetCharging_disabled(self): |
| 133 self.battery._cache['profile'] = self._NEXUS_5 |
96 with self.assertCalls( | 134 with self.assertCalls( |
97 (self.call.device.FileExists(mock.ANY), True), | |
98 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []), | 135 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []), |
99 (self.call.battery.GetCharging(), True), | 136 (self.call.battery.GetCharging(), True), |
100 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []), | 137 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []), |
101 (self.call.battery.GetCharging(), False)): | 138 (self.call.battery.GetCharging(), False)): |
102 self.battery.SetCharging(False) | 139 self.battery.SetCharging(False) |
103 | 140 |
104 | 141 |
105 class BatteryUtilsSetBatteryMeasurementTest(BatteryUtilsTest): | 142 class BatteryUtilsSetBatteryMeasurementTest(BatteryUtilsTest): |
106 | 143 |
107 @mock.patch('time.sleep', mock.Mock()) | 144 @mock.patch('time.sleep', mock.Mock()) |
108 def testBatteryMeasurement(self): | 145 def testBatteryMeasurementWifi(self): |
109 with self.assertCalls( | 146 with self.assertCalls( |
110 (self.call.device.RunShellCommand( | 147 (self.call.device.RunShellCommand( |
111 mock.ANY, retries=0, single_line=True, | 148 mock.ANY, retries=0, single_line=True, |
112 timeout=10, check_return=True), '22'), | 149 timeout=10, check_return=True), '22'), |
113 (self.call.device.RunShellCommand( | 150 (self.call.battery._ClearPowerData(), True), |
114 ['dumpsys', 'battery', 'set', 'usb', '1'], check_return=True), []), | |
115 (self.call.device.RunShellCommand( | |
116 ['dumpsys', 'battery', 'set', 'ac', '1'], check_return=True), []), | |
117 (self.call.device.RunShellCommand( | |
118 ['dumpsys', 'batterystats', '--reset'], check_return=True), []), | |
119 (self.call.device.RunShellCommand( | |
120 ['dumpsys', 'batterystats', '--charged', '--checkin'], | |
121 check_return=True, large_output=True), []), | |
122 (self.call.device.RunShellCommand( | 151 (self.call.device.RunShellCommand( |
123 ['dumpsys', 'battery', 'set', 'ac', '0'], check_return=True), []), | 152 ['dumpsys', 'battery', 'set', 'ac', '0'], check_return=True), []), |
124 (self.call.device.RunShellCommand( | 153 (self.call.device.RunShellCommand( |
| 154 ['dumpsys', 'battery', 'set', 'usb', '0'], check_return=True), []), |
| 155 (self.call.battery.GetCharging(), False), |
| 156 (self.call.device.RunShellCommand( |
| 157 ['dumpsys', 'battery', 'reset'], check_return=True), []), |
| 158 (self.call.battery.GetCharging(), False), |
| 159 (self.call.device.RunShellCommand( |
| 160 ['dumpsys', 'battery'], check_return=True), ['UPDATES STOPPED']), |
| 161 (self.call.battery.GetCharging(), False), |
| 162 (self.call.device.RunShellCommand( |
| 163 ['dumpsys', 'battery'], check_return=True), [])): |
| 164 with self.battery.BatteryMeasurement(): |
| 165 pass |
| 166 |
| 167 @mock.patch('time.sleep', mock.Mock()) |
| 168 def testBatteryMeasurementUsb(self): |
| 169 with self.assertCalls( |
| 170 (self.call.device.RunShellCommand( |
| 171 mock.ANY, retries=0, single_line=True, |
| 172 timeout=10, check_return=True), '22'), |
| 173 (self.call.battery._ClearPowerData(), True), |
| 174 (self.call.device.RunShellCommand( |
| 175 ['dumpsys', 'battery', 'set', 'ac', '0'], check_return=True), []), |
| 176 (self.call.device.RunShellCommand( |
125 ['dumpsys', 'battery', 'set', 'usb', '0'], check_return=True), []), | 177 ['dumpsys', 'battery', 'set', 'usb', '0'], check_return=True), []), |
126 (self.call.battery.GetCharging(), False), | 178 (self.call.battery.GetCharging(), False), |
127 (self.call.device.RunShellCommand( | 179 (self.call.device.RunShellCommand( |
128 ['dumpsys', 'battery', 'reset'], check_return=True), []), | 180 ['dumpsys', 'battery', 'reset'], check_return=True), []), |
| 181 (self.call.battery.GetCharging(), False), |
| 182 (self.call.device.RunShellCommand( |
| 183 ['dumpsys', 'battery'], check_return=True), ['UPDATES STOPPED']), |
129 (self.call.battery.GetCharging(), True)): | 184 (self.call.battery.GetCharging(), True)): |
130 with self.battery.BatteryMeasurement(): | 185 with self.battery.BatteryMeasurement(): |
131 pass | 186 pass |
132 | 187 |
133 | 188 |
134 class BatteryUtilsGetPowerData(BatteryUtilsTest): | 189 class BatteryUtilsGetPowerData(BatteryUtilsTest): |
135 | 190 |
136 def testGetPowerData(self): | 191 def testGetPowerData(self): |
137 with self.assertCalls( | 192 with self.assertCalls( |
138 (self.call.device.RunShellCommand( | 193 (self.call.device.RunShellCommand( |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 def testGetNetworkData_clearedCache(self): | 359 def testGetNetworkData_clearedCache(self): |
305 with self.assertCalls( | 360 with self.assertCalls( |
306 (self.call.device.RunShellCommand( | 361 (self.call.device.RunShellCommand( |
307 ['dumpsys', 'batterystats', '-c'], check_return=True), | 362 ['dumpsys', 'batterystats', '-c'], check_return=True), |
308 _DUMPSYS_OUTPUT), | 363 _DUMPSYS_OUTPUT), |
309 (self.call.device.ReadFile('/proc/uid_stat/1000/tcp_snd'), 1), | 364 (self.call.device.ReadFile('/proc/uid_stat/1000/tcp_snd'), 1), |
310 (self.call.device.ReadFile('/proc/uid_stat/1000/tcp_rcv'), 2)): | 365 (self.call.device.ReadFile('/proc/uid_stat/1000/tcp_rcv'), 2)): |
311 self.battery._cache.clear() | 366 self.battery._cache.clear() |
312 self.assertEqual(self.battery.GetNetworkData('test_package1'), (1,2)) | 367 self.assertEqual(self.battery.GetNetworkData('test_package1'), (1,2)) |
313 | 368 |
| 369 |
314 class BatteryUtilsLetBatteryCoolToTemperatureTest(BatteryUtilsTest): | 370 class BatteryUtilsLetBatteryCoolToTemperatureTest(BatteryUtilsTest): |
315 | 371 |
316 @mock.patch('time.sleep', mock.Mock()) | 372 @mock.patch('time.sleep', mock.Mock()) |
317 def testLetBatteryCoolToTemperature_startUnder(self): | 373 def testLetBatteryCoolToTemperature_startUnder(self): |
318 with self.assertCalls( | 374 with self.assertCalls( |
| 375 (self.call.battery.EnableBatteryUpdates(), []), |
319 (self.call.battery.GetBatteryInfo(), {'temperature': '500'})): | 376 (self.call.battery.GetBatteryInfo(), {'temperature': '500'})): |
320 self.battery.LetBatteryCoolToTemperature(600) | 377 self.battery.LetBatteryCoolToTemperature(600) |
321 | 378 |
322 @mock.patch('time.sleep', mock.Mock()) | 379 @mock.patch('time.sleep', mock.Mock()) |
323 def testLetBatteryCoolToTemperature_startOver(self): | 380 def testLetBatteryCoolToTemperature_startOver(self): |
324 with self.assertCalls( | 381 with self.assertCalls( |
| 382 (self.call.battery.EnableBatteryUpdates(), []), |
325 (self.call.battery.GetBatteryInfo(), {'temperature': '500'}), | 383 (self.call.battery.GetBatteryInfo(), {'temperature': '500'}), |
326 (self.call.battery.GetBatteryInfo(), {'temperature': '400'})): | 384 (self.call.battery.GetBatteryInfo(), {'temperature': '400'})): |
327 self.battery.LetBatteryCoolToTemperature(400) | 385 self.battery.LetBatteryCoolToTemperature(400) |
328 | 386 |
| 387 class BatteryUtilsSupportsFuelGaugeTest(BatteryUtilsTest): |
| 388 |
| 389 def testSupportsFuelGauge_false(self): |
| 390 self.battery._cache['profile'] = self._NEXUS_5 |
| 391 self.assertFalse(self.battery.SupportsFuelGauge()) |
| 392 |
| 393 def testSupportsFuelGauge_trueMax(self): |
| 394 self.battery._cache['profile'] = self._NEXUS_6 |
| 395 # TODO(rnephew): Change this to assertTrue when we have support for |
| 396 # disabling hardware charging on nexus 6. |
| 397 self.assertFalse(self.battery.SupportsFuelGauge()) |
| 398 |
| 399 def testSupportsFuelGauge_trueDS(self): |
| 400 self.battery._cache['profile'] = self._NEXUS_10 |
| 401 # TODO(rnephew): Change this to assertTrue when we have support for |
| 402 # disabling hardware charging on nexus 10. |
| 403 self.assertFalse(self.battery.SupportsFuelGauge()) |
| 404 |
| 405 |
| 406 class BatteryUtilsGetFuelGaugeChargeCounterTest(BatteryUtilsTest): |
| 407 |
| 408 def testGetFuelGaugeChargeCounter_noFuelGauge(self): |
| 409 self.battery._cache['profile'] = self._NEXUS_5 |
| 410 with self.assertRaises(device_errors.CommandFailedError): |
| 411 self.battery.GetFuelGaugeChargeCounter() |
| 412 |
| 413 def testGetFuelGaugeChargeCounter_fuelGaugePresent(self): |
| 414 self.battery._cache['profile']= self._NEXUS_6 |
| 415 with self.assertCalls( |
| 416 (self.call.battery.SupportsFuelGauge(), True), |
| 417 (self.call.device.ReadFile(mock.ANY), '123')): |
| 418 self.assertEqual(self.battery.GetFuelGaugeChargeCounter(), 123) |
| 419 |
| 420 |
| 421 class BatteryUtilsTieredSetCharging(BatteryUtilsTest): |
| 422 |
| 423 @mock.patch('time.sleep', mock.Mock()) |
| 424 def testTieredSetCharging_softwareSetTrue(self): |
| 425 self.battery._cache['profile'] = self._NEXUS_6 |
| 426 with self.assertCalls( |
| 427 (self.call.battery.GetCharging(), False), |
| 428 (self.call.device.RunShellCommand( |
| 429 ['dumpsys', 'battery', 'reset'], check_return=True), []), |
| 430 (self.call.battery.GetCharging(), False), |
| 431 (self.call.device.RunShellCommand( |
| 432 ['dumpsys', 'battery'], check_return=True), ['UPDATES STOPPED']), |
| 433 (self.call.battery.GetCharging(), True)): |
| 434 self.battery.TieredSetCharging(True) |
| 435 |
| 436 @mock.patch('time.sleep', mock.Mock()) |
| 437 def testTieredSetCharging_softwareSetFalse(self): |
| 438 self.battery._cache['profile'] = self._NEXUS_6 |
| 439 with self.assertCalls( |
| 440 (self.call.battery.GetCharging(), True), |
| 441 (self.call.battery._ClearPowerData(), True), |
| 442 (self.call.battery._ClearPowerData(), True), |
| 443 (self.call.device.RunShellCommand( |
| 444 ['dumpsys', 'battery', 'set', 'ac', '0'], check_return=True), []), |
| 445 (self.call.device.RunShellCommand( |
| 446 ['dumpsys', 'battery', 'set', 'usb', '0'], check_return=True), []), |
| 447 (self.call.battery.GetCharging(), False)): |
| 448 self.battery.TieredSetCharging(False) |
| 449 |
| 450 @mock.patch('time.sleep', mock.Mock()) |
| 451 def testTieredSetCharging_hardwareSetTrue(self): |
| 452 self.battery._cache['profile'] = self._NEXUS_5 |
| 453 with self.assertCalls( |
| 454 (self.call.battery.GetCharging(), False), |
| 455 (self.call.battery.SetCharging(True))): |
| 456 self.battery.TieredSetCharging(True) |
| 457 |
| 458 @mock.patch('time.sleep', mock.Mock()) |
| 459 def testTieredSetCharging_hardwareSetFalse(self): |
| 460 self.battery._cache['profile'] = self._NEXUS_5 |
| 461 with self.assertCalls( |
| 462 (self.call.battery.GetCharging(), True), |
| 463 (self.call.battery._ClearPowerData(), True), |
| 464 (self.call.battery.SetCharging(False))): |
| 465 self.battery.TieredSetCharging(False) |
| 466 |
| 467 def testTieredSetCharging_expectedStateAlreadyTrue(self): |
| 468 with self.assertCalls((self.call.battery.GetCharging(), True)): |
| 469 self.battery.TieredSetCharging(True) |
| 470 |
| 471 def testTieredSetCharging_expectedStateAlreadyFalse(self): |
| 472 with self.assertCalls((self.call.battery.GetCharging(), False)): |
| 473 self.battery.TieredSetCharging(False) |
| 474 |
| 475 |
| 476 class BatteryUtilsPowerMeasurement(BatteryUtilsTest): |
| 477 |
| 478 def testPowerMeasurement_hardware(self): |
| 479 self.battery._cache['profile'] = self._NEXUS_5 |
| 480 with self.assertCalls( |
| 481 (self.call.battery.GetCharging(), True), |
| 482 (self.call.battery._ClearPowerData(), True), |
| 483 (self.call.battery.SetCharging(False)), |
| 484 (self.call.battery.GetCharging(), False), |
| 485 (self.call.battery.SetCharging(True))): |
| 486 with self.battery.PowerMeasurement(): |
| 487 pass |
| 488 |
| 489 @mock.patch('time.sleep', mock.Mock()) |
| 490 def testPowerMeasurement_software(self): |
| 491 self.battery._cache['profile'] = self._NEXUS_6 |
| 492 with self.assertCalls( |
| 493 (self.call.battery.GetCharging(), True), |
| 494 (self.call.battery._ClearPowerData(), True), |
| 495 (self.call.battery._ClearPowerData(), True), |
| 496 (self.call.device.RunShellCommand( |
| 497 ['dumpsys', 'battery', 'set', 'ac', '0'], check_return=True), []), |
| 498 (self.call.device.RunShellCommand( |
| 499 ['dumpsys', 'battery', 'set', 'usb', '0'], check_return=True), []), |
| 500 (self.call.battery.GetCharging(), False), |
| 501 (self.call.battery.GetCharging(), False), |
| 502 (self.call.device.RunShellCommand( |
| 503 ['dumpsys', 'battery', 'reset'], check_return=True), []), |
| 504 (self.call.battery.GetCharging(), False), |
| 505 (self.call.device.RunShellCommand( |
| 506 ['dumpsys', 'battery'], check_return=True), ['UPDATES STOPPED']), |
| 507 (self.call.battery.GetCharging(), True)): |
| 508 with self.battery.PowerMeasurement(): |
| 509 pass |
| 510 |
| 511 |
| 512 class BatteryUtilsDiscoverDeviceProfile(BatteryUtilsTest): |
| 513 |
| 514 def testDiscoverDeviceProfile_known(self): |
| 515 with self.assertCalls( |
| 516 (self.call.adb.Shell('getprop ro.product.model'), "Nexus 4")): |
| 517 self.battery._DiscoverDeviceProfile() |
| 518 self.assertEqual(self.battery._cache['profile']['name'], "Nexus 4") |
| 519 |
| 520 def testDiscoverDeviceProfile_unknown(self): |
| 521 with self.assertCalls( |
| 522 (self.call.adb.Shell('getprop ro.product.model'), "Other")): |
| 523 self.battery._DiscoverDeviceProfile() |
| 524 self.assertEqual(self.battery._cache['profile']['name'], None) |
| 525 |
| 526 |
| 527 class BatteryUtilsClearPowerData(BatteryUtilsTest): |
| 528 |
| 529 def testClearPowerData_preL(self): |
| 530 with self.assertCalls( |
| 531 (self.call.device.RunShellCommand(mock.ANY, retries=0, |
| 532 single_line=True, timeout=10, check_return=True), '20')): |
| 533 self.assertFalse(self.battery._ClearPowerData()) |
| 534 |
| 535 def testClearPowerData_clearedL(self): |
| 536 with self.assertCalls( |
| 537 (self.call.device.RunShellCommand(mock.ANY, retries=0, |
| 538 single_line=True, timeout=10, check_return=True), '22'), |
| 539 (self.call.device.RunShellCommand( |
| 540 ['dumpsys', 'battery', 'set', 'usb', '1'], check_return=True), []), |
| 541 (self.call.device.RunShellCommand( |
| 542 ['dumpsys', 'battery', 'set', 'ac', '1'], check_return=True), []), |
| 543 (self.call.device.RunShellCommand( |
| 544 ['dumpsys', 'batterystats', '--reset'], check_return=True), []), |
| 545 (self.call.device.RunShellCommand( |
| 546 ['dumpsys', 'batterystats', '--charged', '--checkin'], |
| 547 check_return=True, large_output=True), []), |
| 548 (self.call.device.RunShellCommand( |
| 549 ['dumpsys', 'battery', 'reset'], check_return=True), [])): |
| 550 self.assertTrue(self.battery._ClearPowerData()) |
| 551 |
| 552 def testClearPowerData_notClearedL(self): |
| 553 with self.assertCalls( |
| 554 (self.call.device.RunShellCommand(mock.ANY, retries=0, |
| 555 single_line=True, timeout=10, check_return=True), '22'), |
| 556 (self.call.device.RunShellCommand( |
| 557 ['dumpsys', 'battery', 'set', 'usb', '1'], check_return=True), []), |
| 558 (self.call.device.RunShellCommand( |
| 559 ['dumpsys', 'battery', 'set', 'ac', '1'], check_return=True), []), |
| 560 (self.call.device.RunShellCommand( |
| 561 ['dumpsys', 'batterystats', '--reset'], check_return=True), []), |
| 562 (self.call.device.RunShellCommand( |
| 563 ['dumpsys', 'batterystats', '--charged', '--checkin'], |
| 564 check_return=True, large_output=True), |
| 565 ['9,1000,l,pwi,uid,0.0327']), |
| 566 (self.call.device.RunShellCommand( |
| 567 ['dumpsys', 'battery', 'reset'], check_return=True), [])): |
| 568 with self.assertRaises(device_errors.CommandFailedError): |
| 569 self.battery._ClearPowerData() |
| 570 |
| 571 |
329 if __name__ == '__main__': | 572 if __name__ == '__main__': |
330 logging.getLogger().setLevel(logging.DEBUG) | 573 logging.getLogger().setLevel(logging.DEBUG) |
331 unittest.main(verbosity=2) | 574 unittest.main(verbosity=2) |
OLD | NEW |