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

Side by Side Diff: build/android/pylib/local/device/local_device_instrumentation_test_run.py

Issue 1092703002: [Android] More old_interface conversions in build/android/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: perezju comments Created 5 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 | « build/android/pylib/forwarder.py ('k') | build/android/pylib/monkey/test_runner.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 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 import logging 5 import logging
6 import re
6 import time 7 import time
7 8
8 from pylib import flag_changer 9 from pylib import flag_changer
9 from pylib.base import base_test_result 10 from pylib.base import base_test_result
10 from pylib.base import test_run 11 from pylib.base import test_run
12 from pylib.constants import keyevent
13 from pylib.device import device_errors
11 from pylib.local.device import local_device_test_run 14 from pylib.local.device import local_device_test_run
12 15
13 16
14 TIMEOUT_ANNOTATIONS = [ 17 TIMEOUT_ANNOTATIONS = [
15 ('Manual', 10 * 60 * 60), 18 ('Manual', 10 * 60 * 60),
16 ('IntegrationTest', 30 * 60), 19 ('IntegrationTest', 30 * 60),
17 ('External', 10 * 60), 20 ('External', 10 * 60),
18 ('EnormousTest', 10 * 60), 21 ('EnormousTest', 10 * 60),
19 ('LargeTest', 5 * 60), 22 ('LargeTest', 5 * 60),
20 ('MediumTest', 3 * 60), 23 ('MediumTest', 3 * 60),
21 ('SmallTest', 1 * 60), 24 ('SmallTest', 1 * 60),
22 ] 25 ]
23 26
24 27
25 # TODO(jbudorick): Make this private once the instrumentation test_runner is 28 # TODO(jbudorick): Make this private once the instrumentation test_runner is
26 # deprecated. 29 # deprecated.
27 def DidPackageCrashOnDevice(package_name, device): 30 def DidPackageCrashOnDevice(package_name, device):
28 # Dismiss any error dialogs. Limit the number in case we have an error 31 # Dismiss any error dialogs. Limit the number in case we have an error
29 # loop or we are failing to dismiss. 32 # loop or we are failing to dismiss.
30 for _ in xrange(10): 33 try:
31 package = device.old_interface.DismissCrashDialogIfNeeded() 34 for _ in xrange(10):
32 if not package: 35 package = _DismissCrashDialog(device)
33 return False 36 if not package:
34 # Assume test package convention of ".test" suffix 37 return False
35 if package in package_name: 38 # Assume test package convention of ".test" suffix
36 return True 39 if package in package_name:
40 return True
41 except device_errors.CommandFailedError:
42 logging.exception('Error while attempting to dismiss crash dialog.')
37 return False 43 return False
38 44
39 45
46 _CURRENT_FOCUS_CRASH_RE = re.compile(
47 r'\s*mCurrentFocus.*Application (Error|Not Responding): (\S+)}')
48
49
50 def _DismissCrashDialog(device):
51 for l in device.RunShellCommand(
52 ['dumpsys', 'window', 'windows'], check_return=True):
53 m = re.match(_CURRENT_FOCUS_CRASH_RE, l)
54 if m:
55 device.SendKeyEvent(keyevent.KEYCODE_DPAD_RIGHT)
56 device.SendKeyEvent(keyevent.KEYCODE_DPAD_RIGHT)
57 device.SendKeyEvent(keyevent.KEYCODE_ENTER)
58 return m.group(2)
59
60 return None
61
62
40 class LocalDeviceInstrumentationTestRun( 63 class LocalDeviceInstrumentationTestRun(
41 local_device_test_run.LocalDeviceTestRun): 64 local_device_test_run.LocalDeviceTestRun):
42 def __init__(self, env, test_instance): 65 def __init__(self, env, test_instance):
43 super(LocalDeviceInstrumentationTestRun, self).__init__(env, test_instance) 66 super(LocalDeviceInstrumentationTestRun, self).__init__(env, test_instance)
44 self._flag_changers = {} 67 self._flag_changers = {}
45 68
46 def TestPackage(self): 69 def TestPackage(self):
47 return None 70 return None
48 71
49 def SetUp(self): 72 def SetUp(self):
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 176
154 try: 177 try:
155 scale = int(annotations.get('TimeoutScale', 1)) 178 scale = int(annotations.get('TimeoutScale', 1))
156 except ValueError as e: 179 except ValueError as e:
157 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e)) 180 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e))
158 scale = 1 181 scale = 1
159 timeout *= scale 182 timeout *= scale
160 183
161 return timeout 184 return timeout
162 185
OLDNEW
« no previous file with comments | « build/android/pylib/forwarder.py ('k') | build/android/pylib/monkey/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698