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

Unified Diff: build/android/pylib/android_commands.py

Issue 114563002: [Android] Dismiss crash dialogs during instrumentation test teardown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/pylib/instrumentation/test_runner.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/android_commands.py
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py
index 6bb9933655187f8bf13a05781687904f0aadd75a..29be40fbde4f00093b0f41dad74fa706e6fef9a8 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -1757,6 +1757,36 @@ class AndroidCommands(object):
'no test results... device setup correctly?')
return test_results[0]
+ def DismissCrashDialogIfNeeded(self):
+ """Dismiss the error/ANR dialog if present.
+
+ Returns: Name of the crashed package if a dialog is focused,
+ None otherwise.
+ """
+ re_focus = re.compile(
+ r'\s*mCurrentFocus.*Application (Error|Not Responding): (\S+)}')
+
+ def _FindFocusedWindow():
+ match = None
+ for line in self.RunShellCommand('dumpsys window windows'):
+ match = re.match(re_focus, line)
+ if match:
+ break
+ return match
+
+ match = _FindFocusedWindow()
+ if not match:
+ return
+ package = match.group(2)
+ logging.warning('Trying to dismiss %s dialog for %s' % match.groups())
+ self.SendKeyEvent(KEYCODE_DPAD_RIGHT)
+ self.SendKeyEvent(KEYCODE_DPAD_RIGHT)
+ self.SendKeyEvent(KEYCODE_ENTER)
+ match = _FindFocusedWindow()
+ if match:
+ logging.error('Still showing a %s dialog for %s' % match.groups())
+ return package
+
class NewLineNormalizer(object):
"""A file-like object to normalize EOLs to '\n'.
« no previous file with comments | « no previous file | build/android/pylib/instrumentation/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698