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

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

Issue 2539973004: Update reference to page_test module to use legacy_page_test module (Closed)
Patch Set: update Created 4 years 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
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 py_utils import cloud_storage 13 from py_utils import cloud_storage
14 from telemetry.page import page_test 14 from telemetry.page import legacy_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
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 location = expectation["location"] 60 location = expectation["location"]
61 size = expectation["size"] 61 size = expectation["size"]
62 x0 = int(location[0] * device_pixel_ratio) 62 x0 = int(location[0] * device_pixel_ratio)
63 x1 = int((location[0] + size[0]) * device_pixel_ratio) 63 x1 = int((location[0] + size[0]) * device_pixel_ratio)
64 y0 = int(location[1] * device_pixel_ratio) 64 y0 = int(location[1] * device_pixel_ratio)
65 y1 = int((location[1] + size[1]) * device_pixel_ratio) 65 y1 = int((location[1] + size[1]) * device_pixel_ratio)
66 for x in range(x0, x1): 66 for x in range(x0, x1):
67 for y in range(y0, y1): 67 for y in range(y0, y1):
68 if (x < 0 or y < 0 or x >= image_util.Width(screenshot) or 68 if (x < 0 or y < 0 or x >= image_util.Width(screenshot) or
69 y >= image_util.Height(screenshot)): 69 y >= image_util.Height(screenshot)):
70 raise page_test.Failure( 70 raise legacy_page_test.Failure(
71 ('Expected pixel location [%d, %d] is out of range on ' + 71 ('Expected pixel location [%d, %d] is out of range on ' +
72 '[%d, %d] image') % 72 '[%d, %d] image') %
73 (x, y, image_util.Width(screenshot), 73 (x, y, image_util.Width(screenshot),
74 image_util.Height(screenshot))) 74 image_util.Height(screenshot)))
75 75
76 actual_color = image_util.GetPixelColor(screenshot, x, y) 76 actual_color = image_util.GetPixelColor(screenshot, x, y)
77 expected_color = rgba_color.RgbaColor( 77 expected_color = rgba_color.RgbaColor(
78 expectation["color"][0], 78 expectation["color"][0],
79 expectation["color"][1], 79 expectation["color"][1],
80 expectation["color"][2]) 80 expectation["color"][2])
81 if not actual_color.IsEqual(expected_color, expectation["tolerance"]): 81 if not actual_color.IsEqual(expected_color, expectation["tolerance"]):
82 raise page_test.Failure('Expected pixel at ' + str(location) + 82 raise legacy_page_test.Failure('Expected pixel at ' + str(location) +
83 ' (actual pixel (' + str(x) + ', ' + str(y) + ')) ' + 83 ' (actual pixel (' + str(x) + ', ' + str(y) + ')) ' +
84 ' to be ' + 84 ' to be ' +
85 str(expectation["color"]) + " but got [" + 85 str(expectation["color"]) + " but got [" +
86 str(actual_color.r) + ", " + 86 str(actual_color.r) + ", " +
87 str(actual_color.g) + ", " + 87 str(actual_color.g) + ", " +
88 str(actual_color.b) + "]") 88 str(actual_color.b) + "]")
89 89
90 class ValidatorBase(gpu_test_base.ValidatorBase): 90 class ValidatorBase(gpu_test_base.ValidatorBase):
91 def __init__(self): 91 def __init__(self):
92 super(ValidatorBase, self).__init__() 92 super(ValidatorBase, self).__init__()
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 screenshot, expectations, device_pixel_ratio): 255 screenshot, expectations, device_pixel_ratio):
256 """Samples the given screenshot and verifies pixel color values. 256 """Samples the given screenshot and verifies pixel color values.
257 The sample locations and expected color values are given in expectations. 257 The sample locations and expected color values are given in expectations.
258 In case any of the samples do not match the expected color, it raises 258 In case any of the samples do not match the expected color, it raises
259 a Failure and dumps the screenshot locally or cloud storage depending on 259 a Failure and dumps the screenshot locally or cloud storage depending on
260 what machine the test is being run.""" 260 what machine the test is being run."""
261 try: 261 try:
262 _CompareScreenshotSamples(tab, screenshot, expectations, 262 _CompareScreenshotSamples(tab, screenshot, expectations,
263 device_pixel_ratio, 263 device_pixel_ratio,
264 self.options.test_machine_name) 264 self.options.test_machine_name)
265 except page_test.Failure: 265 except legacy_page_test.Failure:
266 image_name = self._UrlToImageName(url) 266 image_name = self._UrlToImageName(url)
267 if self.options.test_machine_name: 267 if self.options.test_machine_name:
268 self._UploadErrorImagesToCloudStorage(image_name, screenshot, None) 268 self._UploadErrorImagesToCloudStorage(image_name, screenshot, None)
269 else: 269 else:
270 self._WriteErrorImages(self.options.generated_dir, image_name, 270 self._WriteErrorImages(self.options.generated_dir, image_name,
271 screenshot, None) 271 screenshot, None)
272 raise 272 raise
273 273
274 274
275 class CloudStorageTestBase(gpu_test_base.TestBase): 275 class CloudStorageTestBase(gpu_test_base.TestBase):
(...skipping 24 matching lines...) Expand all
300 default='') 300 default='')
301 group.add_option('--test-machine-name', 301 group.add_option('--test-machine-name',
302 help='Name of the test machine. Specifying this argument causes this ' 302 help='Name of the test machine. Specifying this argument causes this '
303 'script to upload failure images and diffs to cloud storage directly, ' 303 'script to upload failure images and diffs to cloud storage directly, '
304 'instead of relying on the archive_gpu_pixel_test_results.py script.', 304 'instead of relying on the archive_gpu_pixel_test_results.py script.',
305 default='') 305 default='')
306 group.add_option('--generated-dir', 306 group.add_option('--generated-dir',
307 help='Overrides the default on-disk location for generated test images ' 307 help='Overrides the default on-disk location for generated test images '
308 '(only used for local testing without a cloud storage account)', 308 '(only used for local testing without a cloud storage account)',
309 default=default_generated_data_dir) 309 default=default_generated_data_dir)
OLDNEW
« no previous file with comments | « chrome/test/media_router/telemetry/benchmarks/media_router_measurements.py ('k') | content/test/gpu/gpu_tests/gpu_process.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698