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 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 self.device.RunShellCommand(cmd, check_return=True) | 649 self.device.RunShellCommand(cmd, check_return=True) |
650 | 650 |
651 def testRunShellCommand_checkReturn_disabled(self): | 651 def testRunShellCommand_checkReturn_disabled(self): |
652 cmd = 'ls /root' | 652 cmd = 'ls /root' |
653 output = 'opendir failed, Permission denied\n' | 653 output = 'opendir failed, Permission denied\n' |
654 with self.assertCall(self.call.adb.Shell(cmd), self.ShellError(output)): | 654 with self.assertCall(self.call.adb.Shell(cmd), self.ShellError(output)): |
655 self.assertEquals([output.rstrip()], | 655 self.assertEquals([output.rstrip()], |
656 self.device.RunShellCommand(cmd, check_return=False)) | 656 self.device.RunShellCommand(cmd, check_return=False)) |
657 | 657 |
658 | 658 |
| 659 class DeviceUtilsGetDevicePieWrapper(DeviceUtilsNewImplTest): |
| 660 |
| 661 def testGetDevicePieWrapper_jb(self): |
| 662 with self.assertCall( |
| 663 self.call.device.build_version_sdk(), |
| 664 constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN): |
| 665 self.assertEqual('', self.device.GetDevicePieWrapper()) |
| 666 |
| 667 def testGetDevicePieWrapper_ics(self): |
| 668 with self.assertCalls( |
| 669 (self.call.device.build_version_sdk(), |
| 670 constants.ANDROID_SDK_VERSION_CODES.ICE_CREAM_SANDWICH), |
| 671 (mock.call.pylib.constants.GetOutDirectory(), '/foo/bar'), |
| 672 (mock.call.os.path.exists(mock.ANY), True), |
| 673 (self.call.adb.Push(mock.ANY, mock.ANY), '')): |
| 674 self.assertNotEqual('', self.device.GetDevicePieWrapper()) |
| 675 |
| 676 |
659 @mock.patch('time.sleep', mock.Mock()) | 677 @mock.patch('time.sleep', mock.Mock()) |
660 class DeviceUtilsKillAllTest(DeviceUtilsNewImplTest): | 678 class DeviceUtilsKillAllTest(DeviceUtilsNewImplTest): |
661 | 679 |
662 def testKillAll_noMatchingProcesses(self): | 680 def testKillAll_noMatchingProcesses(self): |
663 with self.assertCall(self.call.adb.Shell('ps'), | 681 with self.assertCall(self.call.adb.Shell('ps'), |
664 'USER PID PPID VSIZE RSS WCHAN PC NAME\n'): | 682 'USER PID PPID VSIZE RSS WCHAN PC NAME\n'): |
665 with self.assertRaises(device_errors.CommandFailedError): | 683 with self.assertRaises(device_errors.CommandFailedError): |
666 self.device.KillAll('test_process') | 684 self.device.KillAll('test_process') |
667 | 685 |
668 def testKillAll_nonblocking(self): | 686 def testKillAll_nonblocking(self): |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1439 self.assertTrue( | 1457 self.assertTrue( |
1440 isinstance(device, device_utils.DeviceUtils) | 1458 isinstance(device, device_utils.DeviceUtils) |
1441 and serial == str(device), | 1459 and serial == str(device), |
1442 'Expected a DeviceUtils object with serial %s' % serial) | 1460 'Expected a DeviceUtils object with serial %s' % serial) |
1443 | 1461 |
1444 | 1462 |
1445 if __name__ == '__main__': | 1463 if __name__ == '__main__': |
1446 logging.getLogger().setLevel(logging.DEBUG) | 1464 logging.getLogger().setLevel(logging.DEBUG) |
1447 unittest.main(verbosity=2) | 1465 unittest.main(verbosity=2) |
1448 | 1466 |
OLD | NEW |