Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: build/android/pylib/device/battery_utils_test.py

Issue 1217223008: [Android] Add battery status reset to device temperature check (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 (self.call.device.ReadFile('/proc/uid_stat/1000/tcp_rcv'), 2)): 365 (self.call.device.ReadFile('/proc/uid_stat/1000/tcp_rcv'), 2)):
366 self.battery._cache.clear() 366 self.battery._cache.clear()
367 self.assertEqual(self.battery.GetNetworkData('test_package1'), (1,2)) 367 self.assertEqual(self.battery.GetNetworkData('test_package1'), (1,2))
368 368
369 369
370 class BatteryUtilsLetBatteryCoolToTemperatureTest(BatteryUtilsTest): 370 class BatteryUtilsLetBatteryCoolToTemperatureTest(BatteryUtilsTest):
371 371
372 @mock.patch('time.sleep', mock.Mock()) 372 @mock.patch('time.sleep', mock.Mock())
373 def testLetBatteryCoolToTemperature_startUnder(self): 373 def testLetBatteryCoolToTemperature_startUnder(self):
374 with self.assertCalls( 374 with self.assertCalls(
375 (self.call.device.RunShellCommand(
376 ['dumpsys', 'battery', 'reset'], check_return=True), []),
375 (self.call.battery.GetBatteryInfo(), {'temperature': '500'})): 377 (self.call.battery.GetBatteryInfo(), {'temperature': '500'})):
376 self.battery.LetBatteryCoolToTemperature(600) 378 self.battery.LetBatteryCoolToTemperature(600)
377 379
378 @mock.patch('time.sleep', mock.Mock()) 380 @mock.patch('time.sleep', mock.Mock())
379 def testLetBatteryCoolToTemperature_startOver(self): 381 def testLetBatteryCoolToTemperature_startOver(self):
380 with self.assertCalls( 382 with self.assertCalls(
383 (self.call.device.RunShellCommand(
384 ['dumpsys', 'battery', 'reset'], check_return=True), []),
381 (self.call.battery.GetBatteryInfo(), {'temperature': '500'}), 385 (self.call.battery.GetBatteryInfo(), {'temperature': '500'}),
382 (self.call.battery.GetBatteryInfo(), {'temperature': '400'})): 386 (self.call.battery.GetBatteryInfo(), {'temperature': '400'})):
383 self.battery.LetBatteryCoolToTemperature(400) 387 self.battery.LetBatteryCoolToTemperature(400)
384 388
385 class BatteryUtilsSupportsFuelGaugeTest(BatteryUtilsTest): 389 class BatteryUtilsSupportsFuelGaugeTest(BatteryUtilsTest):
386 390
387 def testSupportsFuelGauge_false(self): 391 def testSupportsFuelGauge_false(self):
388 self.battery._cache['profile'] = self._NEXUS_5 392 self.battery._cache['profile'] = self._NEXUS_5
389 self.assertFalse(self.battery.SupportsFuelGauge()) 393 self.assertFalse(self.battery.SupportsFuelGauge())
390 394
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 ['9,1000,l,pwi,uid,0.0327']), 567 ['9,1000,l,pwi,uid,0.0327']),
564 (self.call.device.RunShellCommand( 568 (self.call.device.RunShellCommand(
565 ['dumpsys', 'battery', 'reset'], check_return=True), [])): 569 ['dumpsys', 'battery', 'reset'], check_return=True), [])):
566 with self.assertRaises(device_errors.CommandFailedError): 570 with self.assertRaises(device_errors.CommandFailedError):
567 self.battery._ClearPowerData() 571 self.battery._ClearPowerData()
568 572
569 573
570 if __name__ == '__main__': 574 if __name__ == '__main__':
571 logging.getLogger().setLevel(logging.DEBUG) 575 logging.getLogger().setLevel(logging.DEBUG)
572 unittest.main(verbosity=2) 576 unittest.main(verbosity=2)
OLDNEW
« build/android/pylib/device/battery_utils.py ('K') | « build/android/pylib/device/battery_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698