Commit 030567f4 authored by kbr's avatar kbr Committed by Commit bot

Prefer device type instead of machine name for scale factor overrides.

This will make the Maps test work on Android bots on the commit queue.

BUG=616297
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_optional_gpu_tests_rel;tryserver.chromium.mac:mac_optional_gpu_tests_rel;tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2037933003
Cr-Commit-Position: refs/heads/master@{#397868}
parent 11f37c67
......@@ -24,25 +24,36 @@ default_generated_data_dir = os.path.join(test_data_dir, 'generated')
error_image_cloud_storage_bucket = 'chromium-browser-gpu-tests'
def _CompareScreenshotSamples(screenshot, expectations, device_pixel_ratio,
def _CompareScreenshotSamples(tab, screenshot, expectations, device_pixel_ratio,
test_machine_name):
# First scan through the expectations and see if there are any scale
# factor overrides that would preempt the device pixel ratio. This
# is mainly a workaround for complex tests like the Maps test.
if test_machine_name:
for expectation in expectations:
if "scale_factor_overrides" in expectation:
for override in expectation["scale_factor_overrides"]:
# Require exact match to avoid confusion, because some
# machine models and names might be subsets of others
# (e.g. Nexus 5 vs Nexus 5X).
if override["machine_name"] == test_machine_name:
logging.warning('Overriding device_pixel_ratio ' +
str(device_pixel_ratio) + ' with scale factor ' +
str(override["scale_factor"]))
device_pixel_ratio = override["scale_factor"]
break
break
for expectation in expectations:
if 'scale_factor_overrides' in expectation:
for override in expectation['scale_factor_overrides']:
# Require exact matches to avoid confusion, because some
# machine models and names might be subsets of others
# (e.g. Nexus 5 vs Nexus 5X).
if ('device_type' in override and
(tab.browser.platform.GetDeviceTypeName() ==
override['device_type'])):
logging.warning('Overriding device_pixel_ratio ' +
str(device_pixel_ratio) + ' with scale factor ' +
str(override['scale_factor']) + ' for device type ' +
override['device_type'])
device_pixel_ratio = override['scale_factor']
break
if (test_machine_name and 'machine_name' in override and
override["machine_name"] == test_machine_name):
logging.warning('Overriding device_pixel_ratio ' +
str(device_pixel_ratio) + ' with scale factor ' +
str(override['scale_factor']) + ' for machine name ' +
test_machine_name)
device_pixel_ratio = override['scale_factor']
break
# Only support one "scale_factor_overrides" in the expectation format.
break
for expectation in expectations:
if "scale_factor_overrides" in expectation:
continue
......@@ -233,7 +244,7 @@ class ValidatorBase(gpu_test_base.ValidatorBase):
'view_test_results.html?%s for this run\'s test results') % (
error_image_cloud_storage_bucket, upload_dir)
def _ValidateScreenshotSamples(self, url,
def _ValidateScreenshotSamples(self, tab, url,
screenshot, expectations, device_pixel_ratio):
"""Samples the given screenshot and verifies pixel color values.
The sample locations and expected color values are given in expectations.
......@@ -241,7 +252,8 @@ class ValidatorBase(gpu_test_base.ValidatorBase):
a Failure and dumps the screenshot locally or cloud storage depending on
what machine the test is being run."""
try:
_CompareScreenshotSamples(screenshot, expectations, device_pixel_ratio,
_CompareScreenshotSamples(tab, screenshot, expectations,
device_pixel_ratio,
self.options.test_machine_name)
except page_test.Failure:
image_name = self._UrlToImageName(url)
......
......@@ -61,6 +61,7 @@ class GpuRasterizationValidator(cloud_storage_test_base.ValidatorBase):
test_rect[2], test_rect[3])
self._ValidateScreenshotSamples(
tab,
page.display_name,
screenshot,
page.expectations,
......
......@@ -54,7 +54,7 @@ class MapsValidator(cloud_storage_test_base.ValidatorBase):
# line.
expected = self._ReadPixelExpectations(page)
self._ValidateScreenshotSamples(
page.display_name, screenshot, expected, dpr)
tab, page.display_name, screenshot, expected, dpr)
@staticmethod
def SpinWaitOnRAF(tab, iterations, timeout=60):
......
......@@ -79,7 +79,7 @@ class PixelValidator(cloud_storage_test_base.ValidatorBase):
os.path.dirname(__file__), page.expected_colors))
expected_colors = self._ReadPixelExpectations(expected_colors_file)
self._ValidateScreenshotSamples(
page.display_name, screenshot, expected_colors, dpr)
tab, page.display_name, screenshot, expected_colors, dpr)
return
image_name = self._UrlToImageName(page.display_name)
......
......@@ -3,19 +3,19 @@
"comment": "scale factor overrides",
"scale_factor_overrides": [
{
"machine_name": "Android Debug (Nexus 5)",
"device_type": "Nexus 5",
"scale_factor": 1.105
},
{
"machine_name": "Android Debug (Nexus 5X)",
"device_type": "Nexus 5X",
"scale_factor": 1.105
},
{
"machine_name": "Android Debug (Nexus 6)",
"device_type": "Nexus 6",
"scale_factor": 1.47436
},
{
"machine_name": "Android Debug (Nexus 9)",
"device_type": "Nexus 9",
"scale_factor": 1.566
}
]
......
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