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

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
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,
perezju 2015/03/13 10:19:07 I'm never quite sure what is the "right" level of
rnephew (Wrong account) 2015/03/16 16:33:40 Done.
1477 timeout=10, check_return=True), '22'),
1478 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []),
1479 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []),
1480 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []),
1481 (self.call.device.GetCharging(), False),
1482 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []),
1483 (self.call.device.GetCharging(), True)):
1484 with self.device.BatteryMeasurement():
1485 pass
1486
1471 1487
1472 class DeviceUtilsStrTest(DeviceUtilsTest): 1488 class DeviceUtilsStrTest(DeviceUtilsTest):
1473 1489
1474 def testStr_returnsSerial(self): 1490 def testStr_returnsSerial(self):
1475 with self.assertCalls( 1491 with self.assertCalls(
1476 (self.call.adb.GetDeviceSerial(), '0123456789abcdef')): 1492 (self.call.adb.GetDeviceSerial(), '0123456789abcdef')):
1477 self.assertEqual('0123456789abcdef', str(self.device)) 1493 self.assertEqual('0123456789abcdef', str(self.device))
1478 1494
1479 1495
1480 class DeviceUtilsParallelTest(mock_calls.TestCase): 1496 class DeviceUtilsParallelTest(mock_calls.TestCase):
(...skipping 14 matching lines...) Expand all
1495 with self.assertCall( 1511 with self.assertCall(
1496 mock.call.pylib.device.adb_wrapper.AdbWrapper.GetDevices(), []): 1512 mock.call.pylib.device.adb_wrapper.AdbWrapper.GetDevices(), []):
1497 with self.assertRaises(device_errors.NoDevicesError): 1513 with self.assertRaises(device_errors.NoDevicesError):
1498 device_utils.DeviceUtils.parallel() 1514 device_utils.DeviceUtils.parallel()
1499 1515
1500 1516
1501 if __name__ == '__main__': 1517 if __name__ == '__main__':
1502 logging.getLogger().setLevel(logging.DEBUG) 1518 logging.getLogger().setLevel(logging.DEBUG)
1503 unittest.main(verbosity=2) 1519 unittest.main(verbosity=2)
1504 1520
OLDNEW
« build/android/pylib/device/device_utils.py ('K') | « 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