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 | 4 |
5 from gpu_tests import cloud_storage_test_base | 5 from gpu_tests import cloud_storage_test_base |
6 from gpu_tests import gpu_rasterization_expectations | 6 from gpu_tests import gpu_rasterization_expectations |
7 import page_sets | 7 import page_sets |
8 | 8 |
9 from telemetry.page import page_test | 9 from telemetry.page import legacy_page_test |
10 from telemetry.util import image_util | 10 from telemetry.util import image_util |
11 | 11 |
12 | 12 |
13 test_harness_script = r""" | 13 test_harness_script = r""" |
14 var domAutomationController = {}; | 14 var domAutomationController = {}; |
15 domAutomationController._succeeded = false; | 15 domAutomationController._succeeded = false; |
16 domAutomationController._finished = false; | 16 domAutomationController._finished = false; |
17 | 17 |
18 domAutomationController.setAutomationId = function(id) {} | 18 domAutomationController.setAutomationId = function(id) {} |
19 domAutomationController.send = function(msg) { | 19 domAutomationController.send = function(msg) { |
(...skipping 12 matching lines...) Expand all Loading... |
32 | 32 |
33 class GpuRasterizationValidator(cloud_storage_test_base.ValidatorBase): | 33 class GpuRasterizationValidator(cloud_storage_test_base.ValidatorBase): |
34 def CustomizeBrowserOptions(self, options): | 34 def CustomizeBrowserOptions(self, options): |
35 # --test-type=gpu is used only to suppress the "Google API Keys are missing" | 35 # --test-type=gpu is used only to suppress the "Google API Keys are missing" |
36 # infobar, which causes flakiness in tests. | 36 # infobar, which causes flakiness in tests. |
37 options.AppendExtraBrowserArgs(['--force-gpu-rasterization', | 37 options.AppendExtraBrowserArgs(['--force-gpu-rasterization', |
38 '--test-type=gpu']) | 38 '--test-type=gpu']) |
39 | 39 |
40 def ValidateAndMeasurePage(self, page, tab, results): | 40 def ValidateAndMeasurePage(self, page, tab, results): |
41 if not _DidTestSucceed(tab): | 41 if not _DidTestSucceed(tab): |
42 raise page_test.Failure('Page indicated a failure') | 42 raise legacy_page_test.Failure('Page indicated a failure') |
43 | 43 |
44 if not hasattr(page, 'expectations') or not page.expectations: | 44 if not hasattr(page, 'expectations') or not page.expectations: |
45 raise page_test.Failure('Expectations not specified') | 45 raise legacy_page_test.Failure('Expectations not specified') |
46 | 46 |
47 if not tab.screenshot_supported: | 47 if not tab.screenshot_supported: |
48 raise page_test.Failure('Browser does not support screenshot capture') | 48 raise legacy_page_test.Failure( |
| 49 'Browser does not support screenshot capture') |
49 | 50 |
50 screenshot = tab.Screenshot() | 51 screenshot = tab.Screenshot() |
51 if screenshot is None: | 52 if screenshot is None: |
52 raise page_test.Failure('Could not capture screenshot') | 53 raise legacy_page_test.Failure('Could not capture screenshot') |
53 | 54 |
54 device_pixel_ratio = tab.EvaluateJavaScript('window.devicePixelRatio') | 55 device_pixel_ratio = tab.EvaluateJavaScript('window.devicePixelRatio') |
55 if hasattr(page, 'test_rect'): | 56 if hasattr(page, 'test_rect'): |
56 test_rect = [int(x * device_pixel_ratio) for x in page.test_rect] | 57 test_rect = [int(x * device_pixel_ratio) for x in page.test_rect] |
57 screenshot = image_util.Crop(screenshot, test_rect[0], test_rect[1], | 58 screenshot = image_util.Crop(screenshot, test_rect[0], test_rect[1], |
58 test_rect[2], test_rect[3]) | 59 test_rect[2], test_rect[3]) |
59 | 60 |
60 self._ValidateScreenshotSamples( | 61 self._ValidateScreenshotSamples( |
61 tab, | 62 tab, |
62 page.display_name, | 63 page.display_name, |
(...skipping 14 matching lines...) Expand all Loading... |
77 return 'gpu_rasterization' | 78 return 'gpu_rasterization' |
78 | 79 |
79 def CreateStorySet(self, options): | 80 def CreateStorySet(self, options): |
80 story_set = page_sets.GpuRasterizationTestsStorySet(self.GetExpectations()) | 81 story_set = page_sets.GpuRasterizationTestsStorySet(self.GetExpectations()) |
81 for page in story_set: | 82 for page in story_set: |
82 page.script_to_evaluate_on_commit = test_harness_script | 83 page.script_to_evaluate_on_commit = test_harness_script |
83 return story_set | 84 return story_set |
84 | 85 |
85 def _CreateExpectations(self): | 86 def _CreateExpectations(self): |
86 return gpu_rasterization_expectations.GpuRasterizationExpectations() | 87 return gpu_rasterization_expectations.GpuRasterizationExpectations() |
OLD | NEW |