Added the --screenshot-directory option for Android instrumentation tests.
--screenshot option was broken for instrumentation tests. In this cl, the option is enabled. With argument --screenshot, the device will take a screenshot whenever an instrumentation test fails. BUG=613405 Review-Url: https://codereview.chromium.org/1998383002 Cr-Original-Commit-Position: refs/heads/master@{#395662} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 35d5e3dd14ae616db29806f3052b400f2de1945a
This commit is contained in:
Родитель
d2ab5bf923
Коммит
12e9cc4d86
|
@ -389,6 +389,7 @@ class InstrumentationTestInstance(test_instance.TestInstance):
|
|||
self._driver_apk = None
|
||||
|
||||
def _initializeTestControlAttributes(self, args):
|
||||
self._screenshot_dir = args.screenshot_dir
|
||||
self._timeout_scale = args.timeout_scale or 1
|
||||
|
||||
def _initializeTestCoverageAttributes(self, args):
|
||||
|
@ -430,6 +431,10 @@ class InstrumentationTestInstance(test_instance.TestInstance):
|
|||
def package_info(self):
|
||||
return self._package_info
|
||||
|
||||
@property
|
||||
def screenshot_dir(self):
|
||||
return self._screenshot_dir
|
||||
|
||||
@property
|
||||
def suite(self):
|
||||
return self._suite
|
||||
|
|
|
@ -274,6 +274,15 @@ class LocalDeviceInstrumentationTestRun(
|
|||
if any(r.GetType() not in (base_test_result.ResultType.PASS,
|
||||
base_test_result.ResultType.SKIP)
|
||||
for r in results):
|
||||
if self._test_instance.screenshot_dir:
|
||||
file_name = '%s-%s.png' % (
|
||||
test_display_name,
|
||||
time.strftime('%Y%m%dT%H%M%S', time.localtime()))
|
||||
saved_dir = device.TakeScreenshot(
|
||||
os.path.join(self._test_instance.screenshot_dir, file_name))
|
||||
logging.info(
|
||||
'Saved screenshot for %s to %s.',
|
||||
test_display_name, saved_dir)
|
||||
logging.info('detected failure in %s. raw output:', test_display_name)
|
||||
for l in output:
|
||||
logging.info(' %s', l)
|
||||
|
|
|
@ -337,7 +337,7 @@ def AddJavaTestOptions(argument_group):
|
|||
help=('Comma-separated list of annotations. Exclude tests with these '
|
||||
'annotations.'))
|
||||
argument_group.add_argument(
|
||||
'--screenshot', dest='screenshot_failures', action='store_true',
|
||||
'--screenshot-directory', dest='screenshot_dir',
|
||||
help='Capture screenshots of test failures')
|
||||
argument_group.add_argument(
|
||||
'--save-perf-json', action='store_true',
|
||||
|
|
Загрузка…
Ссылка в новой задаче