Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(371)

Side by Side Diff: devil/devil/android/device_utils_test.py

Issue 2815573003: Fix force stop using wrong "ps" cmd. (Closed)
Patch Set: Fix force stop using wrong "ps" cmd. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « devil/devil/android/device_utils.py ('k') | devil/devil/android/sdk/adb_wrapper.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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)
OLDNEW
« no previous file with comments | « devil/devil/android/device_utils.py ('k') | devil/devil/android/sdk/adb_wrapper.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698