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

Side by Side Diff: build/android/pylib/device/device_utils.py

Issue 839893004: Refactor test scripts for android to improve performance (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename a parameter Created 5 years, 11 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
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Provides a variety of device interactions based on adb. 5 """Provides a variety of device interactions based on adb.
6 6
7 Eventually, this will be based on adb_wrapper. 7 Eventually, this will be based on adb_wrapper.
8 """ 8 """
9 # pylint: disable=W0613 9 # pylint: disable=W0613
10 10
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 timeout: timeout in seconds 615 timeout: timeout in seconds
616 retries: number of retries 616 retries: number of retries
617 617
618 Raises: 618 Raises:
619 CommandTimeoutError on timeout. 619 CommandTimeoutError on timeout.
620 DeviceUnreachableError on missing device. 620 DeviceUnreachableError on missing device.
621 """ 621 """
622 self.RunShellCommand(['am', 'force-stop', package], check_return=True) 622 self.RunShellCommand(['am', 'force-stop', package], check_return=True)
623 623
624 @decorators.WithTimeoutAndRetriesFromInstance() 624 @decorators.WithTimeoutAndRetriesFromInstance()
625 def ClearApplicationState(self, package, timeout=None, retries=None): 625 def ClearApplicationState(self, package, timeout=None, retries=None,
626 package_check_needed=True):
jbudorick 2015/01/16 14:21:41 timeout and retries should be the last 2 parameter
Jaekyun Seok (inactive) 2015/01/18 23:01:18 Done.
626 """Clear all state for the given package. 627 """Clear all state for the given package.
627 628
628 Args: 629 Args:
629 package: A string containing the name of the package to stop. 630 package: A string containing the name of the package to stop.
630 timeout: timeout in seconds 631 timeout: timeout in seconds
631 retries: number of retries 632 retries: number of retries
633 package_check_needed: Whether the package existence should be checked or
634 not
632 635
633 Raises: 636 Raises:
634 CommandTimeoutError on timeout. 637 CommandTimeoutError on timeout.
635 DeviceUnreachableError on missing device. 638 DeviceUnreachableError on missing device.
636 """ 639 """
637 # Check that the package exists before clearing it. Necessary because 640 # Check that the package exists before clearing it. Necessary because
638 # calling pm clear on a package that doesn't exist may never return. 641 # calling pm clear on a package that doesn't exist may never return.
639 if self.GetApplicationPath(package): 642 if (not package_check_needed) or self.GetApplicationPath(package):
jbudorick 2015/01/16 14:21:41 I'm extremely wary about adding more somewhat supe
Jaekyun Seok (inactive) 2015/01/18 23:01:18 I agree with your concern, but each call to self.G
jbudorick 2015/01/20 14:11:23 That's reasonable; I'm just not sure that the clie
Jaekyun Seok (inactive) 2015/01/20 22:00:23 Caching device status seems dangerous because we c
jbudorick 2015/01/20 22:04:04 What do you mean by "we can't track all the status
Jaekyun Seok (inactive) 2015/01/20 22:11:17 For example, a package could be uninstalled by dev
jbudorick 2015/01/20 22:22:43 I think that case is less risky than the current i
Jaekyun Seok (inactive) 2015/01/20 23:20:35 I see. I will add cache to store application paths
jbudorick 2015/01/20 23:34:24 This could probably be integrated into the existin
perezju 2015/01/21 10:28:52 Yeah, I also dislike the idea of adding this optio
jbudorick 2015/01/21 14:57:00 My concern in this case is that AdbWrapper handles
jbudorick 2015/01/21 15:03:14 If this last part _does_ work on versions starting
640 self.RunShellCommand(['pm', 'clear', package], check_return=True) 643 self.RunShellCommand(['pm', 'clear', package], check_return=True)
641 644
642 @decorators.WithTimeoutAndRetriesFromInstance() 645 @decorators.WithTimeoutAndRetriesFromInstance()
643 def SendKeyEvent(self, keycode, timeout=None, retries=None): 646 def SendKeyEvent(self, keycode, timeout=None, retries=None):
644 """Sends a keycode to the device. 647 """Sends a keycode to the device.
645 648
646 See: http://developer.android.com/reference/android/view/KeyEvent.html 649 See: http://developer.android.com/reference/android/view/KeyEvent.html
647 650
648 Args: 651 Args:
649 keycode: A integer keycode to send to the device. 652 keycode: A integer keycode to send to the device.
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 Returns: 1288 Returns:
1286 A Parallelizer operating over |devices|. 1289 A Parallelizer operating over |devices|.
1287 """ 1290 """
1288 if not devices: 1291 if not devices:
1289 devices = adb_wrapper.AdbWrapper.GetDevices() 1292 devices = adb_wrapper.AdbWrapper.GetDevices()
1290 devices = [d if isinstance(d, cls) else cls(d) for d in devices] 1293 devices = [d if isinstance(d, cls) else cls(d) for d in devices]
1291 if async: 1294 if async:
1292 return parallelizer.Parallelizer(devices) 1295 return parallelizer.Parallelizer(devices)
1293 else: 1296 else:
1294 return parallelizer.SyncParallelizer(devices) 1297 return parallelizer.SyncParallelizer(devices)
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/gtest/test_package_apk.py » ('j') | build/android/pylib/gtest/test_package_apk.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698