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
4 # found in the LICENSE file.
7 Unit tests for the contents of battery_utils.py
10 # pylint: disable=W0613
17 from pylib
import constants
18 from pylib
.device
import battery_utils
19 from pylib
.device
import device_errors
20 from pylib
.device
import device_utils
21 from pylib
.device
import device_utils_test
22 from pylib
.utils
import mock_calls
24 # RunCommand from third_party/android_testrunner/run_command.py is mocked
25 # below, so its path needs to be in sys.path.
26 sys
.path
.append(os
.path
.join(
27 constants
.DIR_SOURCE_ROOT
, 'third_party', 'android_testrunner'))
29 sys
.path
.append(os
.path
.join(
30 constants
.DIR_SOURCE_ROOT
, 'third_party', 'pymock'))
31 import mock
# pylint: disable=F0401
34 '9,0,i,uid,1000,test_package1',
35 '9,0,i,uid,1001,test_package2',
41 class BatteryUtilsTest(mock_calls
.TestCase
):
45 'witness_file': '/sys/kernel/debug/bq24192/INPUT_SRC_CONT',
47 'echo 0x4A > /sys/kernel/debug/bq24192/INPUT_SRC_CONT && '
48 'echo 1 > /sys/class/power_supply/usb/online'),
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,
61 'enable_command': None,
62 'disable_command': None,
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',
72 'enable_command': None,
73 'disable_command': None,
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',
80 def ShellError(self
, output
=None, status
=1):
81 def action(cmd
, *args
, **kwargs
):
82 raise device_errors
.AdbShellCommandFailedError(
83 cmd
, output
, status
, str(self
.device
))
85 output
= 'Permission denied\n'
89 self
.adb
= device_utils_test
._AdbWrapperMock
('0123456789abcdef')
90 self
.device
= device_utils
.DeviceUtils(
91 self
.adb
, default_timeout
=10, default_retries
=0)
92 self
.watchMethodCalls(self
.call
.adb
, ignore
=['GetDeviceSerial'])
93 self
.battery
= battery_utils
.BatteryUtils(
94 self
.device
, default_timeout
=10, default_retries
=0)
97 class BatteryUtilsInitTest(unittest
.TestCase
):
99 def testInitWithDeviceUtil(self
):
100 serial
= '0fedcba987654321'
101 d
= device_utils
.DeviceUtils(serial
)
102 b
= battery_utils
.BatteryUtils(d
)
103 self
.assertEqual(d
, b
._device
)
105 def testInitWithMissing_fails(self
):
106 with self
.assertRaises(TypeError):
107 battery_utils
.BatteryUtils(None)
108 with self
.assertRaises(TypeError):
109 battery_utils
.BatteryUtils('')
112 class BatteryUtilsSetChargingTest(BatteryUtilsTest
):
114 @mock.patch('time.sleep', mock
.Mock())
115 def testSetCharging_enabled(self
):
116 self
.battery
._cache
['profile'] = self
._NEXUS
_5
117 with self
.assertCalls(
118 (self
.call
.device
.RunShellCommand(
119 mock
.ANY
, check_return
=True, as_root
=True), []),
120 (self
.call
.battery
.GetCharging(), False),
121 (self
.call
.device
.RunShellCommand(
122 mock
.ANY
, check_return
=True, as_root
=True), []),
123 (self
.call
.battery
.GetCharging(), True)):
124 self
.battery
.SetCharging(True)
126 def testSetCharging_alreadyEnabled(self
):
127 self
.battery
._cache
['profile'] = self
._NEXUS
_5
128 with self
.assertCalls(
129 (self
.call
.device
.RunShellCommand(
130 mock
.ANY
, check_return
=True, as_root
=True), []),
131 (self
.call
.battery
.GetCharging(), True)):
132 self
.battery
.SetCharging(True)
134 @mock.patch('time.sleep', mock
.Mock())
135 def testSetCharging_disabled(self
):
136 self
.battery
._cache
['profile'] = self
._NEXUS
_5
137 with self
.assertCalls(
138 (self
.call
.device
.RunShellCommand(
139 mock
.ANY
, check_return
=True, as_root
=True), []),
140 (self
.call
.battery
.GetCharging(), True),
141 (self
.call
.device
.RunShellCommand(
142 mock
.ANY
, check_return
=True, as_root
=True), []),
143 (self
.call
.battery
.GetCharging(), False)):
144 self
.battery
.SetCharging(False)
147 class BatteryUtilsSetBatteryMeasurementTest(BatteryUtilsTest
):
149 @mock.patch('time.sleep', mock
.Mock())
150 def testBatteryMeasurementWifi(self
):
151 with self
.assertCalls(
152 (self
.call
.device
.RunShellCommand(
153 mock
.ANY
, retries
=0, single_line
=True,
154 timeout
=10, check_return
=True), '22'),
155 (self
.call
.battery
._ClearPowerData
(), True),
156 (self
.call
.device
.RunShellCommand(
157 ['dumpsys', 'battery', 'set', 'ac', '0'], check_return
=True), []),
158 (self
.call
.device
.RunShellCommand(
159 ['dumpsys', 'battery', 'set', 'usb', '0'], check_return
=True), []),
160 (self
.call
.battery
.GetCharging(), False),
161 (self
.call
.device
.RunShellCommand(
162 ['dumpsys', 'battery', 'reset'], check_return
=True), []),
163 (self
.call
.battery
.GetCharging(), False),
164 (self
.call
.device
.RunShellCommand(
165 ['dumpsys', 'battery'], check_return
=True), ['UPDATES STOPPED']),
166 (self
.call
.battery
.GetCharging(), False),
167 (self
.call
.device
.RunShellCommand(
168 ['dumpsys', 'battery'], check_return
=True), [])):
169 with self
.battery
.BatteryMeasurement():
172 @mock.patch('time.sleep', mock
.Mock())
173 def testBatteryMeasurementUsb(self
):
174 with self
.assertCalls(
175 (self
.call
.device
.RunShellCommand(
176 mock
.ANY
, retries
=0, single_line
=True,
177 timeout
=10, check_return
=True), '22'),
178 (self
.call
.battery
._ClearPowerData
(), True),
179 (self
.call
.device
.RunShellCommand(
180 ['dumpsys', 'battery', 'set', 'ac', '0'], check_return
=True), []),
181 (self
.call
.device
.RunShellCommand(
182 ['dumpsys', 'battery', 'set', 'usb', '0'], check_return
=True), []),
183 (self
.call
.battery
.GetCharging(), False),
184 (self
.call
.device
.RunShellCommand(
185 ['dumpsys', 'battery', 'reset'], check_return
=True), []),
186 (self
.call
.battery
.GetCharging(), False),
187 (self
.call
.device
.RunShellCommand(
188 ['dumpsys', 'battery'], check_return
=True), ['UPDATES STOPPED']),
189 (self
.call
.battery
.GetCharging(), True)):
190 with self
.battery
.BatteryMeasurement():
194 class BatteryUtilsGetPowerData(BatteryUtilsTest
):
196 def testGetPowerData(self
):
197 with self
.assertCalls(
198 (self
.call
.device
.RunShellCommand(
199 ['dumpsys', 'batterystats', '-c'], check_return
=True),
201 data
= self
.battery
.GetPowerData()
203 'test_package1': {'uid': '1000', 'data': [1.0]},
204 'test_package2': {'uid': '1001', 'data': [2.0]}
206 self
.assertEqual(data
, check
)
208 def testGetPowerData_packageCollisionSame(self
):
209 self
.battery
._cache
['uids'] = {'test_package1': '1000'}
210 with self
.assertCall(
211 self
.call
.device
.RunShellCommand(
212 ['dumpsys', 'batterystats', '-c'], check_return
=True),
214 data
= self
.battery
.GetPowerData()
216 'test_package1': {'uid': '1000', 'data': [1.0]},
217 'test_package2': {'uid': '1001', 'data': [2.0]}
219 self
.assertEqual(data
, check
)
221 def testGetPowerData_packageCollisionDifferent(self
):
222 self
.battery
._cache
['uids'] = {'test_package1': '1'}
223 with self
.assertCall(
224 self
.call
.device
.RunShellCommand(
225 ['dumpsys', 'batterystats', '-c'], check_return
=True),
227 with self
.assertRaises(device_errors
.CommandFailedError
):
228 self
.battery
.GetPowerData()
230 def testGetPowerData_cacheCleared(self
):
231 with self
.assertCalls(
232 (self
.call
.device
.RunShellCommand(
233 ['dumpsys', 'batterystats', '-c'], check_return
=True),
235 self
.battery
._cache
.clear()
236 data
= self
.battery
.GetPowerData()
238 'test_package1': {'uid': '1000', 'data': [1.0]},
239 'test_package2': {'uid': '1001', 'data': [2.0]}
241 self
.assertEqual(data
, check
)
243 def testGetPackagePowerData(self
):
244 with self
.assertCalls(
245 (self
.call
.device
.RunShellCommand(
246 ['dumpsys', 'batterystats', '-c'], check_return
=True),
248 data
= self
.battery
.GetPackagePowerData('test_package2')
249 self
.assertEqual(data
, {'uid': '1001', 'data': [2.0]})
251 def testGetPackagePowerData_badPackage(self
):
252 with self
.assertCalls(
253 (self
.call
.device
.RunShellCommand(
254 ['dumpsys', 'batterystats', '-c'], check_return
=True),
256 data
= self
.battery
.GetPackagePowerData('not_a_package')
257 self
.assertEqual(data
, None)
260 class BatteryUtilsChargeDevice(BatteryUtilsTest
):
262 @mock.patch('time.sleep', mock
.Mock())
263 def testChargeDeviceToLevel(self
):
264 with self
.assertCalls(
265 (self
.call
.battery
.SetCharging(True)),
266 (self
.call
.battery
.GetBatteryInfo(), {'level': '50'}),
267 (self
.call
.battery
.GetBatteryInfo(), {'level': '100'})):
268 self
.battery
.ChargeDeviceToLevel(95)
271 class BatteryUtilsGetBatteryInfoTest(BatteryUtilsTest
):
273 def testGetBatteryInfo_normal(self
):
274 with self
.assertCall(
275 self
.call
.device
.RunShellCommand(
276 ['dumpsys', 'battery'], check_return
=True),
278 'Current Battery Service state:',
279 ' AC powered: false',
280 ' USB powered: true',
286 'AC powered': 'false',
287 'USB powered': 'true',
289 'temperature': '321',
291 self
.battery
.GetBatteryInfo())
293 def testGetBatteryInfo_nothing(self
):
294 with self
.assertCall(
295 self
.call
.device
.RunShellCommand(
296 ['dumpsys', 'battery'], check_return
=True), []):
297 self
.assertEquals({}, self
.battery
.GetBatteryInfo())
300 class BatteryUtilsGetChargingTest(BatteryUtilsTest
):
302 def testGetCharging_usb(self
):
303 with self
.assertCall(
304 self
.call
.battery
.GetBatteryInfo(), {'USB powered': 'true'}):
305 self
.assertTrue(self
.battery
.GetCharging())
307 def testGetCharging_usbFalse(self
):
308 with self
.assertCall(
309 self
.call
.battery
.GetBatteryInfo(), {'USB powered': 'false'}):
310 self
.assertFalse(self
.battery
.GetCharging())
312 def testGetCharging_ac(self
):
313 with self
.assertCall(
314 self
.call
.battery
.GetBatteryInfo(), {'AC powered': 'true'}):
315 self
.assertTrue(self
.battery
.GetCharging())
317 def testGetCharging_wireless(self
):
318 with self
.assertCall(
319 self
.call
.battery
.GetBatteryInfo(), {'Wireless powered': 'true'}):
320 self
.assertTrue(self
.battery
.GetCharging())
322 def testGetCharging_unknown(self
):
323 with self
.assertCall(
324 self
.call
.battery
.GetBatteryInfo(), {'level': '42'}):
325 self
.assertFalse(self
.battery
.GetCharging())
328 class BatteryUtilsGetNetworkDataTest(BatteryUtilsTest
):
330 def testGetNetworkData_noDataUsage(self
):
331 with self
.assertCalls(
332 (self
.call
.device
.RunShellCommand(
333 ['dumpsys', 'batterystats', '-c'], check_return
=True),
335 (self
.call
.device
.ReadFile('/proc/uid_stat/1000/tcp_snd'),
337 (self
.call
.device
.ReadFile('/proc/uid_stat/1000/tcp_rcv'),
339 self
.assertEquals(self
.battery
.GetNetworkData('test_package1'), (0, 0))
341 def testGetNetworkData_badPackage(self
):
342 with self
.assertCall(
343 self
.call
.device
.RunShellCommand(
344 ['dumpsys', 'batterystats', '-c'], check_return
=True),
346 self
.assertEqual(self
.battery
.GetNetworkData('asdf'), None)
348 def testGetNetworkData_packageNotCached(self
):
349 with self
.assertCalls(
350 (self
.call
.device
.RunShellCommand(
351 ['dumpsys', 'batterystats', '-c'], check_return
=True),
353 (self
.call
.device
.ReadFile('/proc/uid_stat/1000/tcp_snd'), 1),
354 (self
.call
.device
.ReadFile('/proc/uid_stat/1000/tcp_rcv'), 2)):
355 self
.assertEqual(self
.battery
.GetNetworkData('test_package1'), (1,2))
357 def testGetNetworkData_packageCached(self
):
358 self
.battery
._cache
['uids'] = {'test_package1': '1000'}
359 with self
.assertCalls(
360 (self
.call
.device
.ReadFile('/proc/uid_stat/1000/tcp_snd'), 1),
361 (self
.call
.device
.ReadFile('/proc/uid_stat/1000/tcp_rcv'), 2)):
362 self
.assertEqual(self
.battery
.GetNetworkData('test_package1'), (1,2))
364 def testGetNetworkData_clearedCache(self
):
365 with self
.assertCalls(
366 (self
.call
.device
.RunShellCommand(
367 ['dumpsys', 'batterystats', '-c'], check_return
=True),
369 (self
.call
.device
.ReadFile('/proc/uid_stat/1000/tcp_snd'), 1),
370 (self
.call
.device
.ReadFile('/proc/uid_stat/1000/tcp_rcv'), 2)):
371 self
.battery
._cache
.clear()
372 self
.assertEqual(self
.battery
.GetNetworkData('test_package1'), (1,2))
375 class BatteryUtilsLetBatteryCoolToTemperatureTest(BatteryUtilsTest
):
377 @mock.patch('time.sleep', mock
.Mock())
378 def testLetBatteryCoolToTemperature_startUnder(self
):
379 with self
.assertCalls(
380 (self
.call
.battery
.EnableBatteryUpdates(), []),
381 (self
.call
.battery
.GetBatteryInfo(), {'temperature': '500'})):
382 self
.battery
.LetBatteryCoolToTemperature(600)
384 @mock.patch('time.sleep', mock
.Mock())
385 def testLetBatteryCoolToTemperature_startOver(self
):
386 with self
.assertCalls(
387 (self
.call
.battery
.EnableBatteryUpdates(), []),
388 (self
.call
.battery
.GetBatteryInfo(), {'temperature': '500'}),
389 (self
.call
.battery
.GetBatteryInfo(), {'temperature': '400'})):
390 self
.battery
.LetBatteryCoolToTemperature(400)
392 class BatteryUtilsSupportsFuelGaugeTest(BatteryUtilsTest
):
394 def testSupportsFuelGauge_false(self
):
395 self
.battery
._cache
['profile'] = self
._NEXUS
_5
396 self
.assertFalse(self
.battery
.SupportsFuelGauge())
398 def testSupportsFuelGauge_trueMax(self
):
399 self
.battery
._cache
['profile'] = self
._NEXUS
_6
400 # TODO(rnephew): Change this to assertTrue when we have support for
401 # disabling hardware charging on nexus 6.
402 self
.assertFalse(self
.battery
.SupportsFuelGauge())
404 def testSupportsFuelGauge_trueDS(self
):
405 self
.battery
._cache
['profile'] = self
._NEXUS
_10
406 # TODO(rnephew): Change this to assertTrue when we have support for
407 # disabling hardware charging on nexus 10.
408 self
.assertFalse(self
.battery
.SupportsFuelGauge())
411 class BatteryUtilsGetFuelGaugeChargeCounterTest(BatteryUtilsTest
):
413 def testGetFuelGaugeChargeCounter_noFuelGauge(self
):
414 self
.battery
._cache
['profile'] = self
._NEXUS
_5
415 with self
.assertRaises(device_errors
.CommandFailedError
):
416 self
.battery
.GetFuelGaugeChargeCounter()
418 def testGetFuelGaugeChargeCounter_fuelGaugePresent(self
):
419 self
.battery
._cache
['profile']= self
._NEXUS
_6
420 with self
.assertCalls(
421 (self
.call
.battery
.SupportsFuelGauge(), True),
422 (self
.call
.device
.ReadFile(mock
.ANY
), '123')):
423 self
.assertEqual(self
.battery
.GetFuelGaugeChargeCounter(), 123)
426 class BatteryUtilsTieredSetCharging(BatteryUtilsTest
):
428 @mock.patch('time.sleep', mock
.Mock())
429 def testTieredSetCharging_softwareSetTrue(self
):
430 self
.battery
._cache
['profile'] = self
._NEXUS
_6
431 with self
.assertCalls(
432 (self
.call
.battery
.GetCharging(), False),
433 (self
.call
.device
.RunShellCommand(
434 ['dumpsys', 'battery', 'reset'], check_return
=True), []),
435 (self
.call
.battery
.GetCharging(), False),
436 (self
.call
.device
.RunShellCommand(
437 ['dumpsys', 'battery'], check_return
=True), ['UPDATES STOPPED']),
438 (self
.call
.battery
.GetCharging(), True)):
439 self
.battery
.TieredSetCharging(True)
441 @mock.patch('time.sleep', mock
.Mock())
442 def testTieredSetCharging_softwareSetFalse(self
):
443 self
.battery
._cache
['profile'] = self
._NEXUS
_6
444 with self
.assertCalls(
445 (self
.call
.battery
.GetCharging(), True),
446 (self
.call
.battery
._ClearPowerData
(), True),
447 (self
.call
.battery
._ClearPowerData
(), True),
448 (self
.call
.device
.RunShellCommand(
449 ['dumpsys', 'battery', 'set', 'ac', '0'], check_return
=True), []),
450 (self
.call
.device
.RunShellCommand(
451 ['dumpsys', 'battery', 'set', 'usb', '0'], check_return
=True), []),
452 (self
.call
.battery
.GetCharging(), False)):
453 self
.battery
.TieredSetCharging(False)
455 @mock.patch('time.sleep', mock
.Mock())
456 def testTieredSetCharging_hardwareSetTrue(self
):
457 self
.battery
._cache
['profile'] = self
._NEXUS
_5
458 with self
.assertCalls(
459 (self
.call
.battery
.GetCharging(), False),
460 (self
.call
.battery
.SetCharging(True))):
461 self
.battery
.TieredSetCharging(True)
463 @mock.patch('time.sleep', mock
.Mock())
464 def testTieredSetCharging_hardwareSetFalse(self
):
465 self
.battery
._cache
['profile'] = self
._NEXUS
_5
466 with self
.assertCalls(
467 (self
.call
.battery
.GetCharging(), True),
468 (self
.call
.battery
._ClearPowerData
(), True),
469 (self
.call
.battery
.SetCharging(False))):
470 self
.battery
.TieredSetCharging(False)
472 def testTieredSetCharging_expectedStateAlreadyTrue(self
):
473 with self
.assertCalls((self
.call
.battery
.GetCharging(), True)):
474 self
.battery
.TieredSetCharging(True)
476 def testTieredSetCharging_expectedStateAlreadyFalse(self
):
477 with self
.assertCalls((self
.call
.battery
.GetCharging(), False)):
478 self
.battery
.TieredSetCharging(False)
481 class BatteryUtilsPowerMeasurement(BatteryUtilsTest
):
483 def testPowerMeasurement_hardware(self
):
484 self
.battery
._cache
['profile'] = self
._NEXUS
_5
485 with self
.assertCalls(
486 (self
.call
.battery
.GetCharging(), True),
487 (self
.call
.battery
._ClearPowerData
(), True),
488 (self
.call
.battery
.SetCharging(False)),
489 (self
.call
.battery
.GetCharging(), False),
490 (self
.call
.battery
.SetCharging(True))):
491 with self
.battery
.PowerMeasurement():
494 @mock.patch('time.sleep', mock
.Mock())
495 def testPowerMeasurement_software(self
):
496 self
.battery
._cache
['profile'] = self
._NEXUS
_6
497 with self
.assertCalls(
498 (self
.call
.battery
.GetCharging(), True),
499 (self
.call
.battery
._ClearPowerData
(), True),
500 (self
.call
.battery
._ClearPowerData
(), True),
501 (self
.call
.device
.RunShellCommand(
502 ['dumpsys', 'battery', 'set', 'ac', '0'], check_return
=True), []),
503 (self
.call
.device
.RunShellCommand(
504 ['dumpsys', 'battery', 'set', 'usb', '0'], check_return
=True), []),
505 (self
.call
.battery
.GetCharging(), False),
506 (self
.call
.battery
.GetCharging(), False),
507 (self
.call
.device
.RunShellCommand(
508 ['dumpsys', 'battery', 'reset'], check_return
=True), []),
509 (self
.call
.battery
.GetCharging(), False),
510 (self
.call
.device
.RunShellCommand(
511 ['dumpsys', 'battery'], check_return
=True), ['UPDATES STOPPED']),
512 (self
.call
.battery
.GetCharging(), True)):
513 with self
.battery
.PowerMeasurement():
517 class BatteryUtilsDiscoverDeviceProfile(BatteryUtilsTest
):
519 def testDiscoverDeviceProfile_known(self
):
520 with self
.assertCalls(
521 (self
.call
.adb
.Shell('getprop ro.product.model'), "Nexus 4")):
522 self
.battery
._DiscoverDeviceProfile
()
523 self
.assertEqual(self
.battery
._cache
['profile']['name'], "Nexus 4")
525 def testDiscoverDeviceProfile_unknown(self
):
526 with self
.assertCalls(
527 (self
.call
.adb
.Shell('getprop ro.product.model'), "Other")):
528 self
.battery
._DiscoverDeviceProfile
()
529 self
.assertEqual(self
.battery
._cache
['profile']['name'], None)
532 class BatteryUtilsClearPowerData(BatteryUtilsTest
):
534 def testClearPowerData_preL(self
):
535 with self
.assertCalls(
536 (self
.call
.device
.RunShellCommand(mock
.ANY
, retries
=0,
537 single_line
=True, timeout
=10, check_return
=True), '20')):
538 self
.assertFalse(self
.battery
._ClearPowerData
())
540 def testClearPowerData_clearedL(self
):
541 with self
.assertCalls(
542 (self
.call
.device
.RunShellCommand(mock
.ANY
, retries
=0,
543 single_line
=True, timeout
=10, check_return
=True), '22'),
544 (self
.call
.device
.RunShellCommand(
545 ['dumpsys', 'battery', 'set', 'usb', '1'], check_return
=True), []),
546 (self
.call
.device
.RunShellCommand(
547 ['dumpsys', 'battery', 'set', 'ac', '1'], check_return
=True), []),
548 (self
.call
.device
.RunShellCommand(
549 ['dumpsys', 'batterystats', '--reset'], check_return
=True), []),
550 (self
.call
.device
.RunShellCommand(
551 ['dumpsys', 'batterystats', '--charged', '--checkin'],
552 check_return
=True, large_output
=True), []),
553 (self
.call
.device
.RunShellCommand(
554 ['dumpsys', 'battery', 'reset'], check_return
=True), [])):
555 self
.assertTrue(self
.battery
._ClearPowerData
())
557 def testClearPowerData_notClearedL(self
):
558 with self
.assertCalls(
559 (self
.call
.device
.RunShellCommand(mock
.ANY
, retries
=0,
560 single_line
=True, timeout
=10, check_return
=True), '22'),
561 (self
.call
.device
.RunShellCommand(
562 ['dumpsys', 'battery', 'set', 'usb', '1'], check_return
=True), []),
563 (self
.call
.device
.RunShellCommand(
564 ['dumpsys', 'battery', 'set', 'ac', '1'], check_return
=True), []),
565 (self
.call
.device
.RunShellCommand(
566 ['dumpsys', 'batterystats', '--reset'], check_return
=True), []),
567 (self
.call
.device
.RunShellCommand(
568 ['dumpsys', 'batterystats', '--charged', '--checkin'],
569 check_return
=True, large_output
=True),
570 ['9,1000,l,pwi,uid,0.0327']),
571 (self
.call
.device
.RunShellCommand(
572 ['dumpsys', 'battery', 'reset'], check_return
=True), [])):
573 with self
.assertRaises(device_errors
.CommandFailedError
):
574 self
.battery
._ClearPowerData
()
577 if __name__
== '__main__':
578 logging
.getLogger().setLevel(logging
.DEBUG
)
579 unittest
.main(verbosity
=2)