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

Side by Side Diff: build/android/pylib/instrumentation/test_runner.py

Issue 115473002: [Android] Don't rely on INJECT_EVENTS exception for dismissing dialogs. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 """Class for running instrumentation tests on a single device.""" 5 """Class for running instrumentation tests on a single device."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import re 9 import re
10 import sys 10 import sys
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 timeout=(self._GetIndividualTestTimeoutSecs(test) * 333 timeout=(self._GetIndividualTestTimeoutSecs(test) *
334 self._GetIndividualTestTimeoutScale(test) * 334 self._GetIndividualTestTimeoutScale(test) *
335 self.tool.GetTimeoutScale()) 335 self.tool.GetTimeoutScale())
336 try: 336 try:
337 self.TestSetup(test) 337 self.TestSetup(test)
338 start_date_ms = int(time.time()) * 1000 338 start_date_ms = int(time.time()) * 1000
339 raw_result = self._RunTest(test, timeout) 339 raw_result = self._RunTest(test, timeout)
340 duration_ms = int(time.time()) * 1000 - start_date_ms 340 duration_ms = int(time.time()) * 1000 - start_date_ms
341 status_code = raw_result.GetStatusCode() 341 status_code = raw_result.GetStatusCode()
342 if status_code: 342 if status_code:
343 result_type = base_test_result.ResultType.FAIL
344 if self.options.screenshot_failures: 343 if self.options.screenshot_failures:
345 self._TakeScreenshot(test) 344 self._TakeScreenshot(test)
346 log = raw_result.GetFailureReason() 345 log = raw_result.GetFailureReason()
347 if not log: 346 if not log:
348 log = 'No information.' 347 log = 'No information.'
349 elif log.find('INJECT_EVENTS perm') >= 0: 348 result_type = base_test_result.ResultType.FAIL
350 package = self.adb.DismissCrashDialogIfNeeded() 349 package = self.adb.DismissCrashDialogIfNeeded()
351 # Assume test package convention of ".test" suffix 350 # Assume test package convention of ".test" suffix
352 if package and package in self.test_pkg.GetPackageName(): 351 if package and package in self.test_pkg.GetPackageName():
353 result_type = base_test_result.ResultType.CRASH 352 result_type = base_test_result.ResultType.CRASH
354 result = test_result.InstrumentationTestResult( 353 result = test_result.InstrumentationTestResult(
355 test, result_type, start_date_ms, duration_ms, log=log) 354 test, result_type, start_date_ms, duration_ms, log=log)
356 else: 355 else:
357 result = test_result.InstrumentationTestResult( 356 result = test_result.InstrumentationTestResult(
358 test, base_test_result.ResultType.PASS, start_date_ms, duration_ms) 357 test, base_test_result.ResultType.PASS, start_date_ms, duration_ms)
359 results.AddResult(result) 358 results.AddResult(result)
360 # Catch exceptions thrown by StartInstrumentation(). 359 # Catch exceptions thrown by StartInstrumentation().
361 # See ../../third_party/android/testrunner/adb_interface.py 360 # See ../../third_party/android/testrunner/adb_interface.py
362 except (android_commands.errors.WaitForResponseTimedOutError, 361 except (android_commands.errors.WaitForResponseTimedOutError,
363 android_commands.errors.DeviceUnresponsiveError, 362 android_commands.errors.DeviceUnresponsiveError,
364 android_commands.errors.InstrumentationError), e: 363 android_commands.errors.InstrumentationError), e:
365 if start_date_ms: 364 if start_date_ms:
366 duration_ms = int(time.time()) * 1000 - start_date_ms 365 duration_ms = int(time.time()) * 1000 - start_date_ms
367 else: 366 else:
368 start_date_ms = int(time.time()) * 1000 367 start_date_ms = int(time.time()) * 1000
369 duration_ms = 0 368 duration_ms = 0
370 message = str(e) 369 message = str(e)
371 if not message: 370 if not message:
372 message = 'No information.' 371 message = 'No information.'
373 results.AddResult(test_result.InstrumentationTestResult( 372 results.AddResult(test_result.InstrumentationTestResult(
374 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, 373 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms,
375 log=message)) 374 log=message))
376 raw_result = None 375 raw_result = None
377 self.TestTeardown(test, raw_result) 376 self.TestTeardown(test, raw_result)
378 return (results, None if results.DidRunPass() else test) 377 return (results, None if results.DidRunPass() else test)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698