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

Unified Diff: build/android/pylib/local/device/local_device_instrumentation_test_run.py

Issue 2854823007: Move screenshot capture to Java-side. (Closed)
Patch Set: Move screenshot capture to Java-side. Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: build/android/pylib/local/device/local_device_instrumentation_test_run.py
diff --git a/build/android/pylib/local/device/local_device_instrumentation_test_run.py b/build/android/pylib/local/device/local_device_instrumentation_test_run.py
index c95fe6d6e9bf81d10465469fd425d253e45a56a7..44ea4f01f3dbebafc765d7c89d5591fded52eec0 100644
--- a/build/android/pylib/local/device/local_device_instrumentation_test_run.py
+++ b/build/android/pylib/local/device/local_device_instrumentation_test_run.py
@@ -132,7 +132,7 @@ class LocalDeviceInstrumentationTestRun(
logging.error("Couldn't set debug app: no package defined")
else:
dev.RunShellCommand(['am', 'set-debug-app', '--persistent',
- self._test_instance.package_info.package],
+ self._test_instance.package_info.package],
check_return=True)
@trace_event.traced
def edit_shared_prefs():
@@ -386,22 +386,35 @@ class LocalDeviceInstrumentationTestRun(
self._test_instance.gs_results_bucket) as screenshot_host_dir:
screenshot_host_dir = (
self._test_instance.screenshot_dir or screenshot_host_dir)
+
if screenshot_host_dir:
- file_name = '%s-%s.png' % (
- test_display_name,
- time.strftime('%Y%m%dT%H%M%S-UTC', time.gmtime()))
- screenshot_file = device.TakeScreenshot(
- os.path.join(screenshot_host_dir, file_name))
- logging.info(
- 'Saved screenshot for %s to %s.',
- test_display_name, screenshot_file)
- if self._test_instance.gs_results_bucket:
- link = google_storage_helper.upload(
- google_storage_helper.unique_name('screenshot', device=device),
- screenshot_file,
- bucket=self._test_instance.gs_results_bucket + '/screenshots')
- for result in results:
- result.SetLink('post_test_screenshot', link)
+ screenshot_device_file = posixpath.join(
+ device.GetExternalStoragePath(),
+ 'chromium_tests_output_root',
+ instrumentation_test_instance.FAILURE_SCREENSHOT_FILE)
+ screenshot_host_file = os.path.join(
+ screenshot_host_dir,
+ '%s-%s.png' % (
+ test_display_name,
+ time.strftime('%Y%m%dT%H%M%S-UTC', time.gmtime())))
+ if device.FileExists(screenshot_device_file):
+ try:
+ device.PullFile(screenshot_device_file, screenshot_host_file)
+ finally:
+ device.RemovePath(screenshot_device_file)
+
+ logging.info(
+ 'Saved screenshot for %s to %s.',
+ test_display_name, screenshot_host_file)
+ if self._test_instance.gs_results_bucket:
+ link = google_storage_helper.upload(
+ google_storage_helper.unique_name(
+ 'screenshot', device=device),
+ screenshot_host_file,
+ bucket=('%s/screenshots' %
+ self._test_instance.gs_results_bucket))
+ for result in results:
+ result.SetLink('post_test_screenshot', link)
logging.info('detected failure in %s. raw output:', test_display_name)
for l in output:

Powered by Google App Engine
This is Rietveld 408576698