| 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 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |