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 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 with self.assertCall( | 724 with self.assertCall( |
725 self.call.device.RunShellCommand( | 725 self.call.device.RunShellCommand( |
726 'ps | grep foo; echo "PIPESTATUS: ${PIPESTATUS[@]}"', | 726 'ps | grep foo; echo "PIPESTATUS: ${PIPESTATUS[@]}"', |
727 check_return=True), | 727 check_return=True), |
728 ['foo.bar'] * 256 + ['foo.ba']): | 728 ['foo.bar'] * 256 + ['foo.ba']): |
729 with self.assertRaises(device_errors.AdbShellCommandFailedError) as ec: | 729 with self.assertRaises(device_errors.AdbShellCommandFailedError) as ec: |
730 self.device._RunPipedShellCommand('ps | grep foo') | 730 self.device._RunPipedShellCommand('ps | grep foo') |
731 self.assertIs(None, ec.exception.status) | 731 self.assertIs(None, ec.exception.status) |
732 | 732 |
733 | 733 |
734 class DeviceUtilsGetDevicePieWrapper(DeviceUtilsTest): | |
735 | |
736 def testGetDevicePieWrapper_jb(self): | |
737 with self.assertCall( | |
738 self.call.device.build_version_sdk(), | |
739 constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN): | |
740 self.assertEqual('', self.device.GetDevicePieWrapper()) | |
741 | |
742 def testGetDevicePieWrapper_ics(self): | |
743 with self.assertCalls( | |
744 (self.call.device.build_version_sdk(), | |
745 constants.ANDROID_SDK_VERSION_CODES.ICE_CREAM_SANDWICH), | |
746 (mock.call.pylib.constants.GetOutDirectory(), '/foo/bar'), | |
747 (mock.call.os.path.exists(mock.ANY), True), | |
748 (self.call.adb.Push(mock.ANY, mock.ANY), '')): | |
749 self.assertNotEqual('', self.device.GetDevicePieWrapper()) | |
750 | |
751 | |
752 @mock.patch('time.sleep', mock.Mock()) | 734 @mock.patch('time.sleep', mock.Mock()) |
753 class DeviceUtilsKillAllTest(DeviceUtilsTest): | 735 class DeviceUtilsKillAllTest(DeviceUtilsTest): |
754 | 736 |
755 def testKillAll_noMatchingProcessesFailure(self): | 737 def testKillAll_noMatchingProcessesFailure(self): |
756 with self.assertCall(self.call.device.GetPids('test_process'), {}): | 738 with self.assertCall(self.call.device.GetPids('test_process'), {}): |
757 with self.assertRaises(device_errors.CommandFailedError): | 739 with self.assertRaises(device_errors.CommandFailedError): |
758 self.device.KillAll('test_process') | 740 self.device.KillAll('test_process') |
759 | 741 |
760 def testKillAll_noMatchingProcessesQuiet(self): | 742 def testKillAll_noMatchingProcessesQuiet(self): |
761 with self.assertCall(self.call.device.GetPids('test_process'), {}): | 743 with self.assertCall(self.call.device.GetPids('test_process'), {}): |
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1691 devices = device_utils.DeviceUtils.HealthyDevices() | 1673 devices = device_utils.DeviceUtils.HealthyDevices() |
1692 self.assertEquals(1, len(devices)) | 1674 self.assertEquals(1, len(devices)) |
1693 self.assertTrue(isinstance(devices[0], device_utils.DeviceUtils)) | 1675 self.assertTrue(isinstance(devices[0], device_utils.DeviceUtils)) |
1694 self.assertEquals('0123456789abcdef', devices[0].adb.GetDeviceSerial()) | 1676 self.assertEquals('0123456789abcdef', devices[0].adb.GetDeviceSerial()) |
1695 | 1677 |
1696 | 1678 |
1697 if __name__ == '__main__': | 1679 if __name__ == '__main__': |
1698 logging.getLogger().setLevel(logging.DEBUG) | 1680 logging.getLogger().setLevel(logging.DEBUG) |
1699 unittest.main(verbosity=2) | 1681 unittest.main(verbosity=2) |
1700 | 1682 |
OLD | NEW |