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

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

Issue 993733002: Add new method to disable android device charging. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « build/android/pylib/device/device_utils.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 device_utils.py (mostly DeviceUtils). 7 Unit tests for the contents of device_utils.py (mostly DeviceUtils).
8 """ 8 """
9 9
10 # pylint: disable=C0321 10 # pylint: disable=C0321
(...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 def testSetCharging_disabled(self): 1461 def testSetCharging_disabled(self):
1462 with self.assertCalls( 1462 with self.assertCalls(
1463 (self.call.device.FileExists(mock.ANY), True), 1463 (self.call.device.FileExists(mock.ANY), True),
1464 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []), 1464 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []),
1465 (self.call.device.GetCharging(), True), 1465 (self.call.device.GetCharging(), True),
1466 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []), 1466 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []),
1467 (self.call.device.GetCharging(), False)): 1467 (self.call.device.GetCharging(), False)):
1468 self.device.SetCharging(False) 1468 self.device.SetCharging(False)
1469 1469
1470 1470
1471 class DeviceUtilsSetBatteryMeasurementTest(DeviceUtilsTest):
1472
1473 def testBatteryMeasurement(self):
1474 with self.assertCalls(
1475 (self.call.device.RunShellCommand(
1476 mock.ANY, retries=0, single_line=True,
1477 timeout=10, check_return=True), '22'),
1478 (self.call.device.RunShellCommand(
1479 ['dumpsys', 'batterystats', '--reset'], check_return=True), []),
1480 (self.call.device.RunShellCommand(
1481 ['dumpsys', 'batterystats', '--charged', '--checkin'],
1482 check_return=True), []),
1483 (self.call.device.RunShellCommand(
1484 ['dumpsys', 'battery', 'set', 'usb', '0'], check_return=True), []),
1485 (self.call.device.GetCharging(), False),
1486 (self.call.device.RunShellCommand(
1487 ['dumpsys', 'battery', 'reset'], check_return=True), []),
1488 (self.call.device.GetCharging(), True)):
1489 with self.device.BatteryMeasurement():
1490 pass
1491
1471 1492
1472 class DeviceUtilsStrTest(DeviceUtilsTest): 1493 class DeviceUtilsStrTest(DeviceUtilsTest):
1473 1494
1474 def testStr_returnsSerial(self): 1495 def testStr_returnsSerial(self):
1475 with self.assertCalls( 1496 with self.assertCalls(
1476 (self.call.adb.GetDeviceSerial(), '0123456789abcdef')): 1497 (self.call.adb.GetDeviceSerial(), '0123456789abcdef')):
1477 self.assertEqual('0123456789abcdef', str(self.device)) 1498 self.assertEqual('0123456789abcdef', str(self.device))
1478 1499
1479 1500
1480 class DeviceUtilsParallelTest(mock_calls.TestCase): 1501 class DeviceUtilsParallelTest(mock_calls.TestCase):
(...skipping 14 matching lines...) Expand all
1495 with self.assertCall( 1516 with self.assertCall(
1496 mock.call.pylib.device.adb_wrapper.AdbWrapper.GetDevices(), []): 1517 mock.call.pylib.device.adb_wrapper.AdbWrapper.GetDevices(), []):
1497 with self.assertRaises(device_errors.NoDevicesError): 1518 with self.assertRaises(device_errors.NoDevicesError):
1498 device_utils.DeviceUtils.parallel() 1519 device_utils.DeviceUtils.parallel()
1499 1520
1500 1521
1501 if __name__ == '__main__': 1522 if __name__ == '__main__':
1502 logging.getLogger().setLevel(logging.DEBUG) 1523 logging.getLogger().setLevel(logging.DEBUG)
1503 unittest.main(verbosity=2) 1524 unittest.main(verbosity=2)
1504 1525
OLDNEW
« no previous file with comments | « build/android/pylib/device/device_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698