OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import os | 4 import os |
5 import random | 5 import random |
6 | 6 |
7 import gpu_test_base | 7 import gpu_test_base |
8 import path_util | 8 import path_util |
9 import screenshot_sync_expectations as expectations | 9 import screenshot_sync_expectations as expectations |
10 | 10 |
11 from telemetry import benchmark | 11 from telemetry import benchmark |
12 from telemetry.page import page_test | 12 from telemetry.page import page_test |
13 from telemetry.story import story_set as story_set_module | 13 from telemetry.story import story_set as story_set_module |
14 from telemetry.util import image_util | 14 from telemetry.util import image_util |
15 | 15 |
16 data_path = os.path.join( | 16 data_path = os.path.join( |
17 path_util.GetChromiumSrcDir(), 'content', 'test', 'data', 'gpu') | 17 path_util.GetChromiumSrcDir(), 'content', 'test', 'data', 'gpu') |
18 | 18 |
19 class ScreenshotSyncValidator(gpu_test_base.ValidatorBase): | 19 class ScreenshotSyncValidator(gpu_test_base.ValidatorBase): |
20 def CustomizeBrowserOptions(self, options): | 20 def CustomizeBrowserOptions(self, options): |
21 options.AppendExtraBrowserArgs('--force-gpu-rasterization') | 21 # --test-type=gpu is used only to suppress the "Google API Keys are missing" |
| 22 # infobar, which causes flakiness in tests. |
| 23 options.AppendExtraBrowserArgs(['--force-gpu-rasterization', |
| 24 '--test-type=gpu']) |
22 | 25 |
23 def ValidateAndMeasurePage(self, page, tab, results): | 26 def ValidateAndMeasurePage(self, page, tab, results): |
24 if not tab.screenshot_supported: | 27 if not tab.screenshot_supported: |
25 raise page_test.Failure('Browser does not support screenshot capture') | 28 raise page_test.Failure('Browser does not support screenshot capture') |
26 | 29 |
27 def CheckColorMatch(canvasRGB, screenshotRGB): | 30 def CheckColorMatch(canvasRGB, screenshotRGB): |
28 for i in range(0, 3): | 31 for i in range(0, 3): |
29 if abs(canvasRGB[i] - screenshotRGB[i]) > 1: | 32 if abs(canvasRGB[i] - screenshotRGB[i]) > 1: |
30 raise page_test.Failure('Color mismatch in component #%d: %d vs %d' % | 33 raise page_test.Failure('Color mismatch in component #%d: %d vs %d' % |
31 (i, canvasRGB[i], screenshotRGB[i])) | 34 (i, canvasRGB[i], screenshotRGB[i])) |
(...skipping 30 matching lines...) Expand all Loading... |
62 def Name(cls): | 65 def Name(cls): |
63 return 'screenshot_sync' | 66 return 'screenshot_sync' |
64 | 67 |
65 def _CreateExpectations(self): | 68 def _CreateExpectations(self): |
66 return expectations.ScreenshotSyncExpectations() | 69 return expectations.ScreenshotSyncExpectations() |
67 | 70 |
68 def CreateStorySet(self, options): | 71 def CreateStorySet(self, options): |
69 ps = story_set_module.StorySet(base_dir=data_path, serving_dirs=['']) | 72 ps = story_set_module.StorySet(base_dir=data_path, serving_dirs=['']) |
70 ps.AddStory(ScreenshotSyncPage(ps, ps.base_dir, self.GetExpectations())) | 73 ps.AddStory(ScreenshotSyncPage(ps, ps.base_dir, self.GetExpectations())) |
71 return ps | 74 return ps |
OLD | NEW |