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 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 (self.call.device.RunShellCommand( | 1532 (self.call.device.RunShellCommand( |
1533 ['dumpsys', 'window', 'windows'], check_return=True, | 1533 ['dumpsys', 'window', 'windows'], check_return=True, |
1534 large_output=True), | 1534 large_output=True), |
1535 ['mCurrentFocus Launcher'])): | 1535 ['mCurrentFocus Launcher'])): |
1536 self.device.GoHome() | 1536 self.device.GoHome() |
1537 | 1537 |
1538 | 1538 |
1539 class DeviceUtilsForceStopTest(DeviceUtilsTest): | 1539 class DeviceUtilsForceStopTest(DeviceUtilsTest): |
1540 | 1540 |
1541 def testForceStop(self): | 1541 def testForceStop(self): |
| 1542 with self.assertCalls( |
| 1543 (self.call.device.GetPids('test.package'), {'test.package': [1111]}), |
| 1544 (self.call.device.RunShellCommand( |
| 1545 ['am', 'force-stop', 'test.package'], |
| 1546 check_return=True), |
| 1547 ['Success'])): |
| 1548 self.device.ForceStop('test.package') |
| 1549 |
| 1550 def testForceStop_NoProcessFound(self): |
1542 with self.assertCall( | 1551 with self.assertCall( |
1543 self.call.adb.Shell('p=test.package;if [[ "$(ps)" = *$p* ]]; then ' | 1552 self.call.device.GetPids('test.package'), {}): |
1544 'am force-stop $p; fi'), | |
1545 ''): | |
1546 self.device.ForceStop('test.package') | 1553 self.device.ForceStop('test.package') |
1547 | 1554 |
1548 | 1555 |
1549 class DeviceUtilsClearApplicationStateTest(DeviceUtilsTest): | 1556 class DeviceUtilsClearApplicationStateTest(DeviceUtilsTest): |
1550 | 1557 |
1551 def testClearApplicationState_setPermissions(self): | 1558 def testClearApplicationState_setPermissions(self): |
1552 with self.assertCalls( | 1559 with self.assertCalls( |
1553 (self.call.device.GetProp('ro.build.version.sdk', cache=True), '17'), | 1560 (self.call.device.GetProp('ro.build.version.sdk', cache=True), '17'), |
1554 (self.call.device._GetApplicationPathsInternal('this.package.exists'), | 1561 (self.call.device._GetApplicationPathsInternal('this.package.exists'), |
1555 ['/data/app/this.package.exists.apk']), | 1562 ['/data/app/this.package.exists.apk']), |
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2891 with self.assertCalls( | 2898 with self.assertCalls( |
2892 self.EnsureCacheInitialized()): | 2899 self.EnsureCacheInitialized()): |
2893 data = json.loads(self.device.DumpCacheData()) | 2900 data = json.loads(self.device.DumpCacheData()) |
2894 data['token'] = 'TOKEN' | 2901 data['token'] = 'TOKEN' |
2895 self.assertTrue(self.device.LoadCacheData(json.dumps(data))) | 2902 self.assertTrue(self.device.LoadCacheData(json.dumps(data))) |
2896 | 2903 |
2897 | 2904 |
2898 if __name__ == '__main__': | 2905 if __name__ == '__main__': |
2899 logging.getLogger().setLevel(logging.DEBUG) | 2906 logging.getLogger().setLevel(logging.DEBUG) |
2900 unittest.main(verbosity=2) | 2907 unittest.main(verbosity=2) |
OLD | NEW |