| 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(mock.ANY, check_return=True), []), |
| 1476 (self.call.device.GetCharging(), False), |
| 1477 (self.call.device.RunShellCommand(mock.ANY, check_return=True), []), |
| 1478 (self.call.device.GetCharging(), True)): |
| 1479 with self.device.BatteryMeasurement(): |
| 1480 pass |
| 1481 |
| 1471 | 1482 |
| 1472 class DeviceUtilsStrTest(DeviceUtilsTest): | 1483 class DeviceUtilsStrTest(DeviceUtilsTest): |
| 1473 | 1484 |
| 1474 def testStr_returnsSerial(self): | 1485 def testStr_returnsSerial(self): |
| 1475 with self.assertCalls( | 1486 with self.assertCalls( |
| 1476 (self.call.adb.GetDeviceSerial(), '0123456789abcdef')): | 1487 (self.call.adb.GetDeviceSerial(), '0123456789abcdef')): |
| 1477 self.assertEqual('0123456789abcdef', str(self.device)) | 1488 self.assertEqual('0123456789abcdef', str(self.device)) |
| 1478 | 1489 |
| 1479 | 1490 |
| 1480 class DeviceUtilsParallelTest(mock_calls.TestCase): | 1491 class DeviceUtilsParallelTest(mock_calls.TestCase): |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1495 with self.assertCall( | 1506 with self.assertCall( |
| 1496 mock.call.pylib.device.adb_wrapper.AdbWrapper.GetDevices(), []): | 1507 mock.call.pylib.device.adb_wrapper.AdbWrapper.GetDevices(), []): |
| 1497 with self.assertRaises(device_errors.NoDevicesError): | 1508 with self.assertRaises(device_errors.NoDevicesError): |
| 1498 device_utils.DeviceUtils.parallel() | 1509 device_utils.DeviceUtils.parallel() |
| 1499 | 1510 |
| 1500 | 1511 |
| 1501 if __name__ == '__main__': | 1512 if __name__ == '__main__': |
| 1502 logging.getLogger().setLevel(logging.DEBUG) | 1513 logging.getLogger().setLevel(logging.DEBUG) |
| 1503 unittest.main(verbosity=2) | 1514 unittest.main(verbosity=2) |
| 1504 | 1515 |
| OLD | NEW |