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 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 def testForceStop(self): | 923 def testForceStop(self): |
924 with self.assertCall( | 924 with self.assertCall( |
925 self.call.adb.Shell('am force-stop this.is.a.test.package'), | 925 self.call.adb.Shell('am force-stop this.is.a.test.package'), |
926 ''): | 926 ''): |
927 self.device.ForceStop('this.is.a.test.package') | 927 self.device.ForceStop('this.is.a.test.package') |
928 | 928 |
929 | 929 |
930 class DeviceUtilsClearApplicationStateTest(DeviceUtilsNewImplTest): | 930 class DeviceUtilsClearApplicationStateTest(DeviceUtilsNewImplTest): |
931 | 931 |
932 def testClearApplicationState_packageDoesntExist(self): | 932 def testClearApplicationState_packageDoesntExist(self): |
933 with self.assertCall( | 933 with self.assertCalls( |
934 self.call.device.GetApplicationPath('this.package.does.not.exist'), | 934 (self.call.adb.Shell('getprop ro.build.version.sdk'), '17\n'), |
935 None): | 935 (self.call.device.GetApplicationPath('this.package.does.not.exist'), |
| 936 None)): |
| 937 self.device.ClearApplicationState('this.package.does.not.exist') |
| 938 |
| 939 def testClearApplicationState_packageDoesntExistOnAndroidJBMR2OrAbove(self): |
| 940 with self.assertCalls( |
| 941 (self.call.adb.Shell('getprop ro.build.version.sdk'), '18\n'), |
| 942 (self.call.adb.Shell('pm clear this.package.does.not.exist'), |
| 943 'Failed\r\n')): |
936 self.device.ClearApplicationState('this.package.does.not.exist') | 944 self.device.ClearApplicationState('this.package.does.not.exist') |
937 | 945 |
938 def testClearApplicationState_packageExists(self): | 946 def testClearApplicationState_packageExists(self): |
939 with self.assertCalls( | 947 with self.assertCalls( |
| 948 (self.call.adb.Shell('getprop ro.build.version.sdk'), '17\n'), |
940 (self.call.device.GetApplicationPath('this.package.exists'), | 949 (self.call.device.GetApplicationPath('this.package.exists'), |
941 '/data/app/this.package.exists.apk'), | 950 '/data/app/this.package.exists.apk'), |
942 (self.call.adb.Shell('pm clear this.package.exists'), | 951 (self.call.adb.Shell('pm clear this.package.exists'), |
943 'Success\r\n')): | 952 'Success\r\n')): |
944 self.device.ClearApplicationState('this.package.exists') | 953 self.device.ClearApplicationState('this.package.exists') |
945 | 954 |
| 955 def testClearApplicationState_packageExistsOnAndroidJBMR2OrAbove(self): |
| 956 with self.assertCalls( |
| 957 (self.call.adb.Shell('getprop ro.build.version.sdk'), '18\n'), |
| 958 (self.call.adb.Shell('pm clear this.package.exists'), |
| 959 'Success\r\n')): |
| 960 self.device.ClearApplicationState('this.package.exists') |
| 961 |
946 | 962 |
947 class DeviceUtilsSendKeyEventTest(DeviceUtilsNewImplTest): | 963 class DeviceUtilsSendKeyEventTest(DeviceUtilsNewImplTest): |
948 | 964 |
949 def testSendKeyEvent(self): | 965 def testSendKeyEvent(self): |
950 with self.assertCall(self.call.adb.Shell('input keyevent 66'), ''): | 966 with self.assertCall(self.call.adb.Shell('input keyevent 66'), ''): |
951 self.device.SendKeyEvent(66) | 967 self.device.SendKeyEvent(66) |
952 | 968 |
953 | 969 |
954 class DeviceUtilsPushChangedFilesIndividuallyTest(DeviceUtilsNewImplTest): | 970 class DeviceUtilsPushChangedFilesIndividuallyTest(DeviceUtilsNewImplTest): |
955 | 971 |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1465 self.assertTrue( | 1481 self.assertTrue( |
1466 isinstance(device, device_utils.DeviceUtils) | 1482 isinstance(device, device_utils.DeviceUtils) |
1467 and serial == str(device), | 1483 and serial == str(device), |
1468 'Expected a DeviceUtils object with serial %s' % serial) | 1484 'Expected a DeviceUtils object with serial %s' % serial) |
1469 | 1485 |
1470 | 1486 |
1471 if __name__ == '__main__': | 1487 if __name__ == '__main__': |
1472 logging.getLogger().setLevel(logging.DEBUG) | 1488 logging.getLogger().setLevel(logging.DEBUG) |
1473 unittest.main(verbosity=2) | 1489 unittest.main(verbosity=2) |
1474 | 1490 |
OLD | NEW |