Commit 2bdbab82 authored by John Budorick's avatar John Budorick Committed by Commit Bot

[android] Use datatype as MIME type for archived test files.

Bug: 799921
Change-Id: Ie1a0773bc7ae23c141b170611ecc1d44acfcf45a
Reviewed-on: https://chromium-review.googlesource.com/966861Reviewed-by: default avatarBenjamin Pastene <bpastene@chromium.org>
Commit-Queue: John Budorick <jbudorick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543804}
parent 6fb0fe3f
...@@ -11,10 +11,10 @@ from devil.utils import reraiser_thread ...@@ -11,10 +11,10 @@ from devil.utils import reraiser_thread
class Datatype(object): class Datatype(object):
HTML = 'html' HTML = 'text/html'
IMAGE = 'image' JSON = 'application/json'
TEXT = 'text' PNG = 'image/png'
JSON = 'json' TEXT = 'text/plain'
class OutputManager(object): class OutputManager(object):
......
...@@ -538,7 +538,7 @@ class LocalDeviceInstrumentationTestRun( ...@@ -538,7 +538,7 @@ class LocalDeviceInstrumentationTestRun(
json_data = json.loads(device.ReadFile(json_path)) json_data = json.loads(device.ReadFile(json_path))
image_file_path = posixpath.join(source_dir, json_data['location']) image_file_path = posixpath.join(source_dir, json_data['location'])
with self._env.output_manager.ArchivedTempfile( with self._env.output_manager.ArchivedTempfile(
json_data['location'], 'ui_capture', output_manager.Datatype.IMAGE json_data['location'], 'ui_capture', output_manager.Datatype.PNG
) as image_archive: ) as image_archive:
device.PullFile(image_file_path, image_archive.name) device.PullFile(image_file_path, image_archive.name)
json_data['image_link'] = image_archive.Link() json_data['image_link'] = image_archive.Link()
...@@ -764,7 +764,7 @@ class LocalDeviceInstrumentationTestRun( ...@@ -764,7 +764,7 @@ class LocalDeviceInstrumentationTestRun(
if device.FileExists(screenshot_device_file.name): if device.FileExists(screenshot_device_file.name):
with self._env.output_manager.ArchivedTempfile( with self._env.output_manager.ArchivedTempfile(
screenshot_filename, 'screenshot', screenshot_filename, 'screenshot',
output_manager.Datatype.IMAGE) as screenshot_host_file: output_manager.Datatype.PNG) as screenshot_host_file:
try: try:
device.PullFile(screenshot_device_file.name, device.PullFile(screenshot_device_file.name,
screenshot_host_file.name) screenshot_host_file.name)
...@@ -791,7 +791,7 @@ class LocalDeviceInstrumentationTestRun( ...@@ -791,7 +791,7 @@ class LocalDeviceInstrumentationTestRun(
with self._env.output_manager.ArchivedTempfile( with self._env.output_manager.ArchivedTempfile(
'fail_%s' % failure_filename, 'render_tests', 'fail_%s' % failure_filename, 'render_tests',
output_manager.Datatype.IMAGE) as failure_image_host_file: output_manager.Datatype.PNG) as failure_image_host_file:
device.PullFile( device.PullFile(
posixpath.join(failure_images_device_dir, failure_filename), posixpath.join(failure_images_device_dir, failure_filename),
failure_image_host_file.name) failure_image_host_file.name)
...@@ -802,7 +802,7 @@ class LocalDeviceInstrumentationTestRun( ...@@ -802,7 +802,7 @@ class LocalDeviceInstrumentationTestRun(
if device.PathExists(golden_image_device_file): if device.PathExists(golden_image_device_file):
with self._env.output_manager.ArchivedTempfile( with self._env.output_manager.ArchivedTempfile(
'golden_%s' % failure_filename, 'render_tests', 'golden_%s' % failure_filename, 'render_tests',
output_manager.Datatype.IMAGE) as golden_image_host_file: output_manager.Datatype.PNG) as golden_image_host_file:
device.PullFile( device.PullFile(
golden_image_device_file, golden_image_host_file.name) golden_image_device_file, golden_image_host_file.name)
golden_link = golden_image_host_file.Link() golden_link = golden_image_host_file.Link()
...@@ -814,7 +814,7 @@ class LocalDeviceInstrumentationTestRun( ...@@ -814,7 +814,7 @@ class LocalDeviceInstrumentationTestRun(
if device.PathExists(diff_image_device_file): if device.PathExists(diff_image_device_file):
with self._env.output_manager.ArchivedTempfile( with self._env.output_manager.ArchivedTempfile(
'diff_%s' % failure_filename, 'render_tests', 'diff_%s' % failure_filename, 'render_tests',
output_manager.Datatype.IMAGE) as diff_image_host_file: output_manager.Datatype.PNG) as diff_image_host_file:
device.PullFile( device.PullFile(
diff_image_device_file, diff_image_host_file.name) diff_image_device_file, diff_image_host_file.name)
diff_link = diff_image_host_file.Link() diff_link = diff_image_host_file.Link()
......
...@@ -66,7 +66,7 @@ class GoogleStorageArchivedFile(output_manager.ArchivedFile): ...@@ -66,7 +66,7 @@ class GoogleStorageArchivedFile(output_manager.ArchivedFile):
def _PrepareArchive(self): def _PrepareArchive(self):
self._content_addressed = (self._datatype in ( self._content_addressed = (self._datatype in (
output_manager.Datatype.HTML, output_manager.Datatype.HTML,
output_manager.Datatype.IMAGE, output_manager.Datatype.PNG,
output_manager.Datatype.JSON)) output_manager.Datatype.JSON))
if self._content_addressed: if self._content_addressed:
sha1 = hashlib.sha1() sha1 = hashlib.sha1()
...@@ -85,10 +85,5 @@ class GoogleStorageArchivedFile(output_manager.ArchivedFile): ...@@ -85,10 +85,5 @@ class GoogleStorageArchivedFile(output_manager.ArchivedFile):
google_storage_helper.exists(self._upload_path, self._bucket)): google_storage_helper.exists(self._upload_path, self._bucket)):
return return
content_type = None
if self._datatype == output_manager.Datatype.HTML:
content_type = 'text/html'
elif self._datatype == output_manager.Datatype.JSON:
content_type = 'application/json'
google_storage_helper.upload( google_storage_helper.upload(
self._upload_path, self.name, self._bucket, content_type=content_type) self._upload_path, self.name, self._bucket, content_type=self._datatype)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment