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

Side by Side Diff: content/test/gpu/gpu_tests/cloud_storage_test_base.py

Issue 2037933003: Prefer device type instead of machine name for scale factor overrides. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | content/test/gpu/gpu_tests/gpu_rasterization.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 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 """Base classes for a test and validator which upload results 5 """Base classes for a test and validator which upload results
6 (reference images, error images) to cloud storage.""" 6 (reference images, error images) to cloud storage."""
7 7
8 import logging 8 import logging
9 import os 9 import os
10 import re 10 import re
11 import tempfile 11 import tempfile
12 12
13 from catapult_base import cloud_storage 13 from catapult_base import cloud_storage
14 from telemetry.page import page_test 14 from telemetry.page import page_test
15 from telemetry.util import image_util 15 from telemetry.util import image_util
16 from telemetry.util import rgba_color 16 from telemetry.util import rgba_color
17 17
18 from gpu_tests import gpu_test_base 18 from gpu_tests import gpu_test_base
19 19
20 test_data_dir = os.path.abspath(os.path.join( 20 test_data_dir = os.path.abspath(os.path.join(
21 os.path.dirname(__file__), '..', '..', 'data', 'gpu')) 21 os.path.dirname(__file__), '..', '..', 'data', 'gpu'))
22 22
23 default_generated_data_dir = os.path.join(test_data_dir, 'generated') 23 default_generated_data_dir = os.path.join(test_data_dir, 'generated')
24 24
25 error_image_cloud_storage_bucket = 'chromium-browser-gpu-tests' 25 error_image_cloud_storage_bucket = 'chromium-browser-gpu-tests'
26 26
27 def _CompareScreenshotSamples(screenshot, expectations, device_pixel_ratio, 27 def _CompareScreenshotSamples(tab, screenshot, expectations, device_pixel_ratio,
28 test_machine_name): 28 test_machine_name):
29 # First scan through the expectations and see if there are any scale 29 # First scan through the expectations and see if there are any scale
30 # factor overrides that would preempt the device pixel ratio. This 30 # factor overrides that would preempt the device pixel ratio. This
31 # is mainly a workaround for complex tests like the Maps test. 31 # is mainly a workaround for complex tests like the Maps test.
32 if test_machine_name: 32 for expectation in expectations:
33 for expectation in expectations: 33 if 'scale_factor_overrides' in expectation:
34 if "scale_factor_overrides" in expectation: 34 for override in expectation['scale_factor_overrides']:
35 for override in expectation["scale_factor_overrides"]: 35 # Require exact matches to avoid confusion, because some
36 # Require exact match to avoid confusion, because some 36 # machine models and names might be subsets of others
37 # machine models and names might be subsets of others 37 # (e.g. Nexus 5 vs Nexus 5X).
38 # (e.g. Nexus 5 vs Nexus 5X). 38 if ('device_type' in override and
39 if override["machine_name"] == test_machine_name: 39 (tab.browser.platform.GetDeviceTypeName() ==
40 logging.warning('Overriding device_pixel_ratio ' + 40 override['device_type'])):
41 str(device_pixel_ratio) + ' with scale factor ' + 41 logging.warning('Overriding device_pixel_ratio ' +
42 str(override["scale_factor"])) 42 str(device_pixel_ratio) + ' with scale factor ' +
43 device_pixel_ratio = override["scale_factor"] 43 str(override['scale_factor']) + ' for device type ' +
44 break 44 override['device_type'])
45 break 45 device_pixel_ratio = override['scale_factor']
46 break
47 if (test_machine_name and 'machine_name' in override and
48 override["machine_name"] == test_machine_name):
49 logging.warning('Overriding device_pixel_ratio ' +
50 str(device_pixel_ratio) + ' with scale factor ' +
51 str(override['scale_factor']) + ' for machine name ' +
52 test_machine_name)
53 device_pixel_ratio = override['scale_factor']
54 break
55 # Only support one "scale_factor_overrides" in the expectation format.
56 break
46 for expectation in expectations: 57 for expectation in expectations:
47 if "scale_factor_overrides" in expectation: 58 if "scale_factor_overrides" in expectation:
48 continue 59 continue
49 location = expectation["location"] 60 location = expectation["location"]
50 size = expectation["size"] 61 size = expectation["size"]
51 x0 = int(location[0] * device_pixel_ratio) 62 x0 = int(location[0] * device_pixel_ratio)
52 x1 = int((location[0] + size[0]) * device_pixel_ratio) 63 x1 = int((location[0] + size[0]) * device_pixel_ratio)
53 y0 = int(location[1] * device_pixel_ratio) 64 y0 = int(location[1] * device_pixel_ratio)
54 y1 = int((location[1] + size[1]) * device_pixel_ratio) 65 y1 = int((location[1] + size[1]) * device_pixel_ratio)
55 for x in range(x0, x1): 66 for x in range(x0, x1):
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 self._UploadBitmapToCloudStorage( 237 self._UploadBitmapToCloudStorage(
227 base_bucket + '/ref', image_name_with_revision, ref_img, public=True) 238 base_bucket + '/ref', image_name_with_revision, ref_img, public=True)
228 diff_img = image_util.Diff(screenshot, ref_img) 239 diff_img = image_util.Diff(screenshot, ref_img)
229 self._UploadBitmapToCloudStorage( 240 self._UploadBitmapToCloudStorage(
230 base_bucket + '/diff', image_name_with_revision, diff_img, 241 base_bucket + '/diff', image_name_with_revision, diff_img,
231 public=True) 242 public=True)
232 print ('See http://%s.commondatastorage.googleapis.com/' 243 print ('See http://%s.commondatastorage.googleapis.com/'
233 'view_test_results.html?%s for this run\'s test results') % ( 244 'view_test_results.html?%s for this run\'s test results') % (
234 error_image_cloud_storage_bucket, upload_dir) 245 error_image_cloud_storage_bucket, upload_dir)
235 246
236 def _ValidateScreenshotSamples(self, url, 247 def _ValidateScreenshotSamples(self, tab, url,
237 screenshot, expectations, device_pixel_ratio): 248 screenshot, expectations, device_pixel_ratio):
238 """Samples the given screenshot and verifies pixel color values. 249 """Samples the given screenshot and verifies pixel color values.
239 The sample locations and expected color values are given in expectations. 250 The sample locations and expected color values are given in expectations.
240 In case any of the samples do not match the expected color, it raises 251 In case any of the samples do not match the expected color, it raises
241 a Failure and dumps the screenshot locally or cloud storage depending on 252 a Failure and dumps the screenshot locally or cloud storage depending on
242 what machine the test is being run.""" 253 what machine the test is being run."""
243 try: 254 try:
244 _CompareScreenshotSamples(screenshot, expectations, device_pixel_ratio, 255 _CompareScreenshotSamples(tab, screenshot, expectations,
256 device_pixel_ratio,
245 self.options.test_machine_name) 257 self.options.test_machine_name)
246 except page_test.Failure: 258 except page_test.Failure:
247 image_name = self._UrlToImageName(url) 259 image_name = self._UrlToImageName(url)
248 if self.options.test_machine_name: 260 if self.options.test_machine_name:
249 self._UploadErrorImagesToCloudStorage(image_name, screenshot, None) 261 self._UploadErrorImagesToCloudStorage(image_name, screenshot, None)
250 else: 262 else:
251 self._WriteErrorImages(self.options.generated_dir, image_name, 263 self._WriteErrorImages(self.options.generated_dir, image_name,
252 screenshot, None) 264 screenshot, None)
253 raise 265 raise
254 266
(...skipping 26 matching lines...) Expand all
281 default='') 293 default='')
282 group.add_option('--test-machine-name', 294 group.add_option('--test-machine-name',
283 help='Name of the test machine. Specifying this argument causes this ' 295 help='Name of the test machine. Specifying this argument causes this '
284 'script to upload failure images and diffs to cloud storage directly, ' 296 'script to upload failure images and diffs to cloud storage directly, '
285 'instead of relying on the archive_gpu_pixel_test_results.py script.', 297 'instead of relying on the archive_gpu_pixel_test_results.py script.',
286 default='') 298 default='')
287 group.add_option('--generated-dir', 299 group.add_option('--generated-dir',
288 help='Overrides the default on-disk location for generated test images ' 300 help='Overrides the default on-disk location for generated test images '
289 '(only used for local testing without a cloud storage account)', 301 '(only used for local testing without a cloud storage account)',
290 default=default_generated_data_dir) 302 default=default_generated_data_dir)
OLDNEW
« no previous file with comments | « no previous file | content/test/gpu/gpu_tests/gpu_rasterization.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698