| 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 import optparse | 5 import optparse |
| 6 import cloud_storage_test_base | 6 import cloud_storage_test_base |
| 7 | 7 |
| 8 test_harness_script = r""" | 8 test_harness_script = r""" |
| 9 var domAutomationController = {}; | 9 var domAutomationController = {}; |
| 10 domAutomationController._succeeded = false; | 10 domAutomationController._succeeded = false; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 if not tab.screenshot_supported: | 43 if not tab.screenshot_supported: |
| 44 raise page_test.Failure('Browser does not support screenshot capture') | 44 raise page_test.Failure('Browser does not support screenshot capture') |
| 45 | 45 |
| 46 screenshot = tab.Screenshot() | 46 screenshot = tab.Screenshot() |
| 47 if not screenshot: | 47 if not screenshot: |
| 48 raise page_test.Failure('Could not capture screenshot') | 48 raise page_test.Failure('Could not capture screenshot') |
| 49 | 49 |
| 50 device_pixel_ratio = tab.EvaluateJavaScript('window.devicePixelRatio') | 50 device_pixel_ratio = tab.EvaluateJavaScript('window.devicePixelRatio') |
| 51 if hasattr(page, 'test_rect'): | 51 if hasattr(page, 'test_rect'): |
| 52 test_rect = [x * device_pixel_ratio for x in page.test_rect] | 52 test_rect = [int(x * device_pixel_ratio) for x in page.test_rect] |
| 53 screenshot = screenshot.Crop( | 53 screenshot = screenshot.Crop( |
| 54 test_rect[0], test_rect[1], | 54 test_rect[0], test_rect[1], |
| 55 test_rect[2], test_rect[3]) | 55 test_rect[2], test_rect[3]) |
| 56 | 56 |
| 57 self._ValidateScreenshotSamples( | 57 self._ValidateScreenshotSamples( |
| 58 page.display_name, | 58 page.display_name, |
| 59 screenshot, | 59 screenshot, |
| 60 page.expectations, | 60 page.expectations, |
| 61 device_pixel_ratio) | 61 device_pixel_ratio) |
| 62 | 62 |
| 63 | 63 |
| 64 class GpuRasterization(cloud_storage_test_base.TestBase): | 64 class GpuRasterization(cloud_storage_test_base.TestBase): |
| 65 """Tests that GPU rasterization produces valid content""" | 65 """Tests that GPU rasterization produces valid content""" |
| 66 test = _GpuRasterizationValidator | 66 test = _GpuRasterizationValidator |
| 67 page_set = 'page_sets/gpu_rasterization_tests.py' | 67 page_set = 'page_sets/gpu_rasterization_tests.py' |
| 68 | 68 |
| 69 def CreatePageSet(self, options): | 69 def CreatePageSet(self, options): |
| 70 page_set = super(GpuRasterization, self).CreatePageSet(options) | 70 page_set = super(GpuRasterization, self).CreatePageSet(options) |
| 71 for page in page_set.pages: | 71 for page in page_set.pages: |
| 72 page.script_to_evaluate_on_commit = test_harness_script | 72 page.script_to_evaluate_on_commit = test_harness_script |
| 73 return page_set | 73 return page_set |
| OLD | NEW |