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 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 with self.assertCalls( | 690 with self.assertCalls( |
691 self.call.adb.Uninstall('test.package', True)): | 691 self.call.adb.Uninstall('test.package', True)): |
692 self.device.Uninstall('test.package', True) | 692 self.device.Uninstall('test.package', True) |
693 | 693 |
694 | 694 |
695 class DeviceUtilsSuTest(DeviceUtilsTest): | 695 class DeviceUtilsSuTest(DeviceUtilsTest): |
696 def testSu_preM(self): | 696 def testSu_preM(self): |
697 with self.patch_call( | 697 with self.patch_call( |
698 self.call.device.build_version_sdk, | 698 self.call.device.build_version_sdk, |
699 return_value=version_codes.LOLLIPOP_MR1): | 699 return_value=version_codes.LOLLIPOP_MR1): |
700 self.assertEquals('su -c foo', self.device._Su('foo')) | 700 self.assertEquals("su -c 'foo bar'", self.device._Su('foo bar')) |
701 | 701 |
702 def testSu_mAndAbove(self): | 702 def testSu_mAndAbove(self): |
703 with self.patch_call( | 703 with self.patch_call( |
704 self.call.device.build_version_sdk, | 704 self.call.device.build_version_sdk, |
705 return_value=version_codes.MARSHMALLOW): | 705 return_value=version_codes.MARSHMALLOW): |
706 self.assertEquals('su 0 foo', self.device._Su('foo')) | 706 self.assertEquals('su 0 foo bar', self.device._Su('foo bar')) |
707 | 707 |
708 | 708 |
709 class DeviceUtilsRunShellCommandTest(DeviceUtilsTest): | 709 class DeviceUtilsRunShellCommandTest(DeviceUtilsTest): |
710 | 710 |
711 def setUp(self): | 711 def setUp(self): |
712 super(DeviceUtilsRunShellCommandTest, self).setUp() | 712 super(DeviceUtilsRunShellCommandTest, self).setUp() |
713 self.device.NeedsSU = mock.Mock(return_value=False) | 713 self.device.NeedsSU = mock.Mock(return_value=False) |
714 | 714 |
715 def testRunShellCommand_commandAsList(self): | 715 def testRunShellCommand_commandAsList(self): |
716 with self.assertCall(self.call.adb.Shell('pm list packages'), ''): | 716 with self.assertCall(self.call.adb.Shell('pm list packages'), ''): |
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2093 def testGrantPermissions_BlackList(self): | 2093 def testGrantPermissions_BlackList(self): |
2094 with self.patch_call( | 2094 with self.patch_call( |
2095 self.call.device.build_version_sdk, return_value=23): | 2095 self.call.device.build_version_sdk, return_value=23): |
2096 self.device.GrantPermissions( | 2096 self.device.GrantPermissions( |
2097 'package', ['android.permission.ACCESS_MOCK_LOCATION']) | 2097 'package', ['android.permission.ACCESS_MOCK_LOCATION']) |
2098 | 2098 |
2099 | 2099 |
2100 if __name__ == '__main__': | 2100 if __name__ == '__main__': |
2101 logging.getLogger().setLevel(logging.DEBUG) | 2101 logging.getLogger().setLevel(logging.DEBUG) |
2102 unittest.main(verbosity=2) | 2102 unittest.main(verbosity=2) |
OLD | NEW |