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=protected-access | 10 # pylint: disable=protected-access |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 self.device.Install( | 598 self.device.Install( |
599 '/fake/test/app.apk', retries=0, permissions=['p1', 'p2']) | 599 '/fake/test/app.apk', retries=0, permissions=['p1', 'p2']) |
600 | 600 |
601 def testInstall_priorInstall(self): | 601 def testInstall_priorInstall(self): |
602 APK_PATH = '/fake/test/app.apk' | 602 APK_PATH = '/fake/test/app.apk' |
603 with self.assertCalls( | 603 with self.assertCalls( |
604 (mock.call.devil.android.apk_helper.GetPackageName(APK_PATH), | 604 (mock.call.devil.android.apk_helper.GetPackageName(APK_PATH), |
605 'test.package'), | 605 'test.package'), |
606 (self.call.device._GetApplicationPathsInternal('test.package'), | 606 (self.call.device._GetApplicationPathsInternal('test.package'), |
607 ['/fake/data/app/test.package.apk']), | 607 ['/fake/data/app/test.package.apk']), |
608 self.call.adb.Uninstall('test.package', False), | 608 self.call.device.Uninstall('test.package'), |
609 self.call.adb.Install('/fake/test/app.apk', reinstall=False)): | 609 self.call.adb.Install('/fake/test/app.apk', reinstall=False)): |
610 self.device.Install('/fake/test/app.apk', retries=0, permissions=[]) | 610 self.device.Install('/fake/test/app.apk', retries=0, permissions=[]) |
611 | 611 |
612 def testInstall_differentPriorInstall_reinstall(self): | 612 def testInstall_differentPriorInstall_reinstall(self): |
613 with self.assertCalls( | 613 with self.assertCalls( |
614 (mock.call.devil.android.apk_helper.GetPackageName( | 614 (mock.call.devil.android.apk_helper.GetPackageName( |
615 '/fake/test/app.apk'), | 615 '/fake/test/app.apk'), |
616 'test.package'), | 616 'test.package'), |
617 (self.call.device._GetApplicationPathsInternal('test.package'), | 617 (self.call.device._GetApplicationPathsInternal('test.package'), |
618 ['/fake/data/app/test.package.apk']), | 618 ['/fake/data/app/test.package.apk']), |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 ['base.apk', 'split2.apk']), | 683 ['base.apk', 'split2.apk']), |
684 (['split2.apk'], None)), | 684 (['split2.apk'], None)), |
685 (self.call.adb.InstallMultiple( | 685 (self.call.adb.InstallMultiple( |
686 ['split2.apk'], partial='test.package', reinstall=True))): | 686 ['split2.apk'], partial='test.package', reinstall=True))): |
687 self.device.InstallSplitApk('base.apk', | 687 self.device.InstallSplitApk('base.apk', |
688 ['split1.apk', 'split2.apk', 'split3.apk'], | 688 ['split1.apk', 'split2.apk', 'split3.apk'], |
689 reinstall=True, permissions=[], retries=0) | 689 reinstall=True, permissions=[], retries=0) |
690 | 690 |
691 | 691 |
692 class DeviceUtilsUninstallTest(DeviceUtilsTest): | 692 class DeviceUtilsUninstallTest(DeviceUtilsTest): |
693 | |
694 def testUninstall_callsThrough(self): | 693 def testUninstall_callsThrough(self): |
695 with self.assertCalls( | 694 with self.assertCalls( |
| 695 (self.call.device._GetApplicationPathsInternal('test.package'), |
| 696 ['/path.apk']), |
696 self.call.adb.Uninstall('test.package', True)): | 697 self.call.adb.Uninstall('test.package', True)): |
697 self.device.Uninstall('test.package', True) | 698 self.device.Uninstall('test.package', True) |
698 | 699 |
| 700 def testUninstall_noop(self): |
| 701 with self.assertCalls( |
| 702 (self.call.device._GetApplicationPathsInternal('test.package'), [])): |
| 703 self.device.Uninstall('test.package', True) |
| 704 |
699 | 705 |
700 class DeviceUtilsSuTest(DeviceUtilsTest): | 706 class DeviceUtilsSuTest(DeviceUtilsTest): |
701 def testSu_preM(self): | 707 def testSu_preM(self): |
702 with self.patch_call( | 708 with self.patch_call( |
703 self.call.device.build_version_sdk, | 709 self.call.device.build_version_sdk, |
704 return_value=version_codes.LOLLIPOP_MR1): | 710 return_value=version_codes.LOLLIPOP_MR1): |
705 self.assertEquals('su -c foo', self.device._Su('foo')) | 711 self.assertEquals('su -c foo', self.device._Su('foo')) |
706 | 712 |
707 def testSu_mAndAbove(self): | 713 def testSu_mAndAbove(self): |
708 with self.patch_call( | 714 with self.patch_call( |
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2122 def testGrantPermissions_BlackList(self): | 2128 def testGrantPermissions_BlackList(self): |
2123 with self.patch_call( | 2129 with self.patch_call( |
2124 self.call.device.build_version_sdk, return_value=23): | 2130 self.call.device.build_version_sdk, return_value=23): |
2125 self.device.GrantPermissions( | 2131 self.device.GrantPermissions( |
2126 'package', ['android.permission.ACCESS_MOCK_LOCATION']) | 2132 'package', ['android.permission.ACCESS_MOCK_LOCATION']) |
2127 | 2133 |
2128 | 2134 |
2129 if __name__ == '__main__': | 2135 if __name__ == '__main__': |
2130 logging.getLogger().setLevel(logging.DEBUG) | 2136 logging.getLogger().setLevel(logging.DEBUG) |
2131 unittest.main(verbosity=2) | 2137 unittest.main(verbosity=2) |
OLD | NEW |