OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 class PixelTestPage(object): | 5 class PixelTestPage(object): |
6 """A wrapper class mimicking the functionality of the PixelTestsStorySet | 6 """A wrapper class mimicking the functionality of the PixelTestsStorySet |
7 from the old-style GPU tests. | 7 from the old-style GPU tests. |
8 """ | 8 """ |
9 def __init__(self, url, name, test_rect, revision, | 9 def __init__(self, url, name, test_rect, revision, |
10 expected_colors=None, tolerance=2, browser_args=None): | 10 tolerance=2, browser_args=None, expected_colors=None): |
11 super(PixelTestPage, self).__init__() | 11 super(PixelTestPage, self).__init__() |
12 self.url = url | 12 self.url = url |
13 self.name = name | 13 self.name = name |
14 self.test_rect = test_rect | 14 self.test_rect = test_rect |
15 self.revision = revision | 15 self.revision = revision |
| 16 # The tolerance when comparing against the reference image. |
| 17 self.tolerance = tolerance |
| 18 self.browser_args = browser_args |
16 # The expected colors can be specified as a list of dictionaries, | 19 # The expected colors can be specified as a list of dictionaries, |
17 # in which case these specific pixels will be sampled instead of | 20 # in which case these specific pixels will be sampled instead of |
18 # comparing the entire image snapshot. The format is only defined | 21 # comparing the entire image snapshot. The format is only defined |
19 # by contract with _CompareScreenshotSamples in | 22 # by contract with _CompareScreenshotSamples in |
20 # cloud_storage_integration_test_base.py. | 23 # cloud_storage_integration_test_base.py. |
21 self.expected_colors = expected_colors | 24 self.expected_colors = expected_colors |
22 # The tolerance when comparing against the reference image. | |
23 self.tolerance = tolerance | |
24 self.browser_args = browser_args | |
25 | 25 |
26 def CopyWithNewBrowserArgsAndSuffix(self, browser_args, suffix): | 26 def CopyWithNewBrowserArgsAndSuffix(self, browser_args, suffix): |
27 return PixelTestPage( | 27 return PixelTestPage( |
28 self.url, self.name + suffix, self.test_rect, self.revision, | 28 self.url, self.name + suffix, self.test_rect, self.revision, |
29 self.expected_colors, self.tolerance, browser_args) | 29 self.tolerance, browser_args, self.expected_colors) |
30 | 30 |
31 def CopyWithNewBrowserArgsAndPrefix(self, browser_args, prefix): | 31 def CopyWithNewBrowserArgsAndPrefix(self, browser_args, prefix): |
32 # Assuming the test name is 'Pixel'. | 32 # Assuming the test name is 'Pixel'. |
33 split = self.name.split('_', 1) | 33 split = self.name.split('_', 1) |
34 return PixelTestPage( | 34 return PixelTestPage( |
35 self.url, split[0] + '_' + prefix + split[1], self.test_rect, | 35 self.url, split[0] + '_' + prefix + split[1], self.test_rect, |
36 self.revision, self.expected_colors, self.tolerance, browser_args) | 36 self.revision, self.tolerance, browser_args, self.expected_colors) |
37 | 37 |
38 | 38 |
39 def CopyPagesWithNewBrowserArgsAndSuffix(pages, browser_args, suffix): | 39 def CopyPagesWithNewBrowserArgsAndSuffix(pages, browser_args, suffix): |
40 return [ | 40 return [ |
41 p.CopyWithNewBrowserArgsAndSuffix(browser_args, suffix) for p in pages] | 41 p.CopyWithNewBrowserArgsAndSuffix(browser_args, suffix) for p in pages] |
42 | 42 |
43 | 43 |
44 def CopyPagesWithNewBrowserArgsAndPrefix(pages, browser_args, prefix): | 44 def CopyPagesWithNewBrowserArgsAndPrefix(pages, browser_args, prefix): |
45 return [ | 45 return [ |
46 p.CopyWithNewBrowserArgsAndPrefix(browser_args, prefix) for p in pages] | 46 p.CopyWithNewBrowserArgsAndPrefix(browser_args, prefix) for p in pages] |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 revision=3), | 126 revision=3), |
127 | 127 |
128 PixelTestPage( | 128 PixelTestPage( |
129 'pixel_background.html', | 129 'pixel_background.html', |
130 base_name + '_SolidColorBackground', | 130 base_name + '_SolidColorBackground', |
131 test_rect=[500, 500, 100, 100], | 131 test_rect=[500, 500, 100, 100], |
132 revision=1), | 132 revision=1), |
133 ] | 133 ] |
134 | 134 |
135 | 135 |
| 136 # Pages that should be run with GPU rasterization enabled. |
| 137 def GpuRasterizationPages(base_name): |
| 138 browser_args = ['--force-gpu-rasterization'] |
| 139 return [ |
| 140 PixelTestPage( |
| 141 'pixel_background.html', |
| 142 base_name + '_GpuRasterization_BlueBox', |
| 143 test_rect=[0, 0, 220, 220], |
| 144 revision=0, # This is not used. |
| 145 browser_args=browser_args, |
| 146 expected_colors=[ |
| 147 { |
| 148 'comment': 'body-t', |
| 149 'location': [5, 5], |
| 150 'size': [1, 1], |
| 151 'color': [0, 128, 0], |
| 152 'tolerance': 0 |
| 153 }, |
| 154 { |
| 155 'comment': 'body-r', |
| 156 'location': [215, 5], |
| 157 'size': [1, 1], |
| 158 'color': [0, 128, 0], |
| 159 'tolerance': 0 |
| 160 }, |
| 161 { |
| 162 'comment': 'body-b', |
| 163 'location': [215, 215], |
| 164 'size': [1, 1], |
| 165 'color': [0, 128, 0], |
| 166 'tolerance': 0 |
| 167 }, |
| 168 { |
| 169 'comment': 'body-l', |
| 170 'location': [5, 215], |
| 171 'size': [1, 1], |
| 172 'color': [0, 128, 0], |
| 173 'tolerance': 0 |
| 174 }, |
| 175 { |
| 176 'comment': 'background-t', |
| 177 'location': [30, 30], |
| 178 'size': [1, 1], |
| 179 'color': [0, 0, 0], |
| 180 'tolerance': 0 |
| 181 }, |
| 182 { |
| 183 'comment': 'background-r', |
| 184 'location': [170, 30], |
| 185 'size': [1, 1], |
| 186 'color': [0, 0, 0], |
| 187 'tolerance': 0 |
| 188 }, |
| 189 { |
| 190 'comment': 'background-b', |
| 191 'location': [170, 170], |
| 192 'size': [1, 1], |
| 193 'color': [0, 0, 0], |
| 194 'tolerance': 0 |
| 195 }, |
| 196 { |
| 197 'comment': 'background-l', |
| 198 'location': [30, 170], |
| 199 'size': [1, 1], |
| 200 'color': [0, 0, 0], |
| 201 'tolerance': 0 |
| 202 }, |
| 203 { |
| 204 'comment': 'box-t', |
| 205 'location': [70, 70], |
| 206 'size': [1, 1], |
| 207 'color': [0, 0, 255], |
| 208 'tolerance': 0 |
| 209 }, |
| 210 { |
| 211 'comment': 'box-r', |
| 212 'location': [140, 70], |
| 213 'size': [1, 1], |
| 214 'color': [0, 0, 255], |
| 215 'tolerance': 0 |
| 216 }, |
| 217 { |
| 218 'comment': 'box-b', |
| 219 'location': [140, 140], |
| 220 'size': [1, 1], |
| 221 'color': [0, 0, 255], |
| 222 'tolerance': 0 |
| 223 }, |
| 224 { |
| 225 'comment': 'box-l', |
| 226 'location': [70, 140], |
| 227 'size': [1, 1], |
| 228 'color': [0, 0, 255], |
| 229 'tolerance': 0 |
| 230 } |
| 231 ]), |
| 232 PixelTestPage( |
| 233 'concave_paths.html', |
| 234 base_name + '_GpuRasterization_ConcavePaths', |
| 235 test_rect=[0, 0, 100, 100], |
| 236 revision=0, # This is not used. |
| 237 browser_args=browser_args, |
| 238 expected_colors=[ |
| 239 { |
| 240 'comment': 'outside', |
| 241 'location': [80, 60], |
| 242 'size': [1, 1], |
| 243 'color': [255, 255, 255], |
| 244 'tolerance': 0 |
| 245 }, |
| 246 { |
| 247 'comment': 'outside', |
| 248 'location': [28, 20], |
| 249 'size': [1, 1], |
| 250 'color': [255, 255, 255], |
| 251 'tolerance': 0 |
| 252 }, |
| 253 { |
| 254 'comment': 'inside', |
| 255 'location': [32, 25], |
| 256 'size': [1, 1], |
| 257 'color': [255, 215, 0], |
| 258 'tolerance': 0 |
| 259 }, |
| 260 { |
| 261 'comment': 'inside', |
| 262 'location': [80, 80], |
| 263 'size': [1, 1], |
| 264 'color': [255, 215, 0], |
| 265 'tolerance': 0 |
| 266 } |
| 267 ]) |
| 268 ] |
| 269 |
| 270 |
136 # Pages that should be run with experimental canvas features. | 271 # Pages that should be run with experimental canvas features. |
137 def ExperimentalCanvasFeaturesPages(base_name): | 272 def ExperimentalCanvasFeaturesPages(base_name): |
138 browser_args = ['--enable-experimental-canvas-features'] | 273 browser_args = ['--enable-experimental-canvas-features'] |
139 unaccelerated_args = [ | 274 unaccelerated_args = [ |
140 '--disable-accelerated-2d-canvas', | 275 '--disable-accelerated-2d-canvas', |
141 '--disable-gpu-compositing'] | 276 '--disable-gpu-compositing'] |
142 | 277 |
143 return [ | 278 return [ |
144 PixelTestPage( | 279 PixelTestPage( |
145 'pixel_offscreenCanvas_transfer_after_style_resize.html', | 280 'pixel_offscreenCanvas_transfer_after_style_resize.html', |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 test_rect=[0, 0, 300, 300], | 468 test_rect=[0, 0, 300, 300], |
334 revision=4), | 469 revision=4), |
335 PixelTestPage( | 470 PixelTestPage( |
336 'filter_effects.html', | 471 'filter_effects.html', |
337 base_name + '_CSSFilterEffects_NoOverlays', | 472 base_name + '_CSSFilterEffects_NoOverlays', |
338 test_rect=[0, 0, 300, 300], | 473 test_rect=[0, 0, 300, 300], |
339 revision=4, | 474 revision=4, |
340 tolerance=10, | 475 tolerance=10, |
341 browser_args=['--disable-mac-overlays']), | 476 browser_args=['--disable-mac-overlays']), |
342 ] | 477 ] |
OLD | NEW |