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

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

Issue 13496004: [Android] Set flags for uiautomator based on annotations not test name. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « build/android/pylib/constants.py ('k') | build/android/pylib/utils/test_options_parser.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 (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 """Runs the Java tests. See more information on run_instrumentation_tests.py.""" 5 """Runs the Java tests. See more information on run_instrumentation_tests.py."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import re 9 import re
10 import shutil 10 import shutil
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 if 'Manual' in annotations: 366 if 'Manual' in annotations:
367 return 600 * 60 367 return 600 * 60
368 if 'External' in annotations: 368 if 'External' in annotations:
369 return 10 * 60 369 return 10 * 60
370 if 'LargeTest' in annotations or _PERF_TEST_ANNOTATION in annotations: 370 if 'LargeTest' in annotations or _PERF_TEST_ANNOTATION in annotations:
371 return 5 * 60 371 return 5 * 60
372 if 'MediumTest' in annotations: 372 if 'MediumTest' in annotations:
373 return 3 * 60 373 return 3 * 60
374 return 1 * 60 374 return 1 * 60
375 375
376 def _RunUIAutomatorTest(self, test, timeout):
377 """Runs a single uiautomator test.
378
379 Args:
380 test: Test class/method.
381 timeout: Timeout time in seconds.
382
383 Returns:
384 An instance of am_instrument_parser.TestResult object.
385 """
386 self.adb.ClearApplicationState(self.package_name)
387 if 'Feature:FirstRunExperience' in self.test_pkg.GetTestAnnotations(test):
388 self.flags.RemoveFlags(['--disable-fre'])
389 else:
390 self.flags.AddFlags(['--disable-fre'])
391 return self.adb.RunUIAutomatorTest(
392 test, self.test_pkg.GetPackageName(), timeout)
393
376 #override. 394 #override.
377 def RunTest(self, test): 395 def RunTest(self, test):
378 raw_result = None 396 raw_result = None
379 start_date_ms = None 397 start_date_ms = None
380 results = base_test_result.TestRunResults() 398 results = base_test_result.TestRunResults()
381 timeout=(self._GetIndividualTestTimeoutSecs(test) * 399 timeout=(self._GetIndividualTestTimeoutSecs(test) *
382 self._GetIndividualTestTimeoutScale(test) * 400 self._GetIndividualTestTimeoutScale(test) *
383 self.tool.GetTimeoutScale()) 401 self.tool.GetTimeoutScale())
384 try: 402 try:
385 self.TestSetup(test) 403 self.TestSetup(test)
386 start_date_ms = int(time.time()) * 1000 404 start_date_ms = int(time.time()) * 1000
387 405
388 if self.is_uiautomator_test: 406 if self.is_uiautomator_test:
389 self.adb.ClearApplicationState(self.package_name) 407 raw_result = self._RunUIAutomatorTest(test, timeout)
390 # TODO(frankf): Stop-gap solution. Should use annotations.
391 if 'FirstRun' in test:
392 self.flags.RemoveFlags(['--disable-fre'])
393 else:
394 self.flags.AddFlags(['--disable-fre'])
395 raw_result = self.adb.RunUIAutomatorTest(
396 test, self.test_pkg.GetPackageName(), timeout)
397 else: 408 else:
398 raw_result = self.adb.RunInstrumentationTest( 409 raw_result = self.adb.RunInstrumentationTest(
399 test, self.test_pkg.GetPackageName(), 410 test, self.test_pkg.GetPackageName(),
400 self._GetInstrumentationArgs(), timeout) 411 self._GetInstrumentationArgs(), timeout)
401 412
402 duration_ms = int(time.time()) * 1000 - start_date_ms 413 duration_ms = int(time.time()) * 1000 - start_date_ms
403 status_code = raw_result.GetStatusCode() 414 status_code = raw_result.GetStatusCode()
404 if status_code: 415 if status_code:
405 log = raw_result.GetFailureReason() 416 log = raw_result.GetFailureReason()
406 if not log: 417 if not log:
(...skipping 19 matching lines...) Expand all
426 duration_ms = 0 437 duration_ms = 0
427 message = str(e) 438 message = str(e)
428 if not message: 439 if not message:
429 message = 'No information.' 440 message = 'No information.'
430 results.AddResult(test_result.InstrumentationTestResult( 441 results.AddResult(test_result.InstrumentationTestResult(
431 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, 442 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms,
432 log=message)) 443 log=message))
433 raw_result = None 444 raw_result = None
434 self.TestTeardown(test, raw_result) 445 self.TestTeardown(test, raw_result)
435 return (results, None if results.DidRunPass() else test) 446 return (results, None if results.DidRunPass() else test)
OLDNEW
« no previous file with comments | « build/android/pylib/constants.py ('k') | build/android/pylib/utils/test_options_parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698