| 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 cloud_storage_test_base | 5 import cloud_storage_test_base |
| 6 import optparse | 6 import optparse |
| 7 import page_sets | 7 import page_sets |
| 8 | 8 |
| 9 from telemetry.image_processing import image_util |
| 10 |
| 9 | 11 |
| 10 test_harness_script = r""" | 12 test_harness_script = r""" |
| 11 var domAutomationController = {}; | 13 var domAutomationController = {}; |
| 12 domAutomationController._succeeded = false; | 14 domAutomationController._succeeded = false; |
| 13 domAutomationController._finished = false; | 15 domAutomationController._finished = false; |
| 14 | 16 |
| 15 domAutomationController.setAutomationId = function(id) {} | 17 domAutomationController.setAutomationId = function(id) {} |
| 16 domAutomationController.send = function(msg) { | 18 domAutomationController.send = function(msg) { |
| 17 domAutomationController._finished = true; | 19 domAutomationController._finished = true; |
| 18 if (msg.toLowerCase() == "success") | 20 if (msg.toLowerCase() == "success") |
| (...skipping 19 matching lines...) Expand all Loading... |
| 38 if not _DidTestSucceed(tab): | 40 if not _DidTestSucceed(tab): |
| 39 raise page_test.Failure('Page indicated a failure') | 41 raise page_test.Failure('Page indicated a failure') |
| 40 | 42 |
| 41 if not hasattr(page, 'expectations') or not page.expectations: | 43 if not hasattr(page, 'expectations') or not page.expectations: |
| 42 raise page_test.Failure('Expectations not specified') | 44 raise page_test.Failure('Expectations not specified') |
| 43 | 45 |
| 44 if not tab.screenshot_supported: | 46 if not tab.screenshot_supported: |
| 45 raise page_test.Failure('Browser does not support screenshot capture') | 47 raise page_test.Failure('Browser does not support screenshot capture') |
| 46 | 48 |
| 47 screenshot = tab.Screenshot() | 49 screenshot = tab.Screenshot() |
| 48 if not screenshot: | 50 if screenshot is None: |
| 49 raise page_test.Failure('Could not capture screenshot') | 51 raise page_test.Failure('Could not capture screenshot') |
| 50 | 52 |
| 51 device_pixel_ratio = tab.EvaluateJavaScript('window.devicePixelRatio') | 53 device_pixel_ratio = tab.EvaluateJavaScript('window.devicePixelRatio') |
| 52 if hasattr(page, 'test_rect'): | 54 if hasattr(page, 'test_rect'): |
| 53 test_rect = [int(x * device_pixel_ratio) for x in page.test_rect] | 55 test_rect = [int(x * device_pixel_ratio) for x in page.test_rect] |
| 54 screenshot = screenshot.Crop( | 56 screenshot = image_util.Crop(screenshot, test_rect[0], test_rect[1], |
| 55 test_rect[0], test_rect[1], | 57 test_rect[2], test_rect[3]) |
| 56 test_rect[2], test_rect[3]) | |
| 57 | 58 |
| 58 self._ValidateScreenshotSamples( | 59 self._ValidateScreenshotSamples( |
| 59 page.display_name, | 60 page.display_name, |
| 60 screenshot, | 61 screenshot, |
| 61 page.expectations, | 62 page.expectations, |
| 62 device_pixel_ratio) | 63 device_pixel_ratio) |
| 63 | 64 |
| 64 | 65 |
| 65 class GpuRasterization(cloud_storage_test_base.TestBase): | 66 class GpuRasterization(cloud_storage_test_base.TestBase): |
| 66 """Tests that GPU rasterization produces valid content""" | 67 """Tests that GPU rasterization produces valid content""" |
| 67 test = _GpuRasterizationValidator | 68 test = _GpuRasterizationValidator |
| 68 | 69 |
| 69 def CreatePageSet(self, options): | 70 def CreatePageSet(self, options): |
| 70 page_set = page_sets.GpuRasterizationTestsPageSet() | 71 page_set = page_sets.GpuRasterizationTestsPageSet() |
| 71 for page in page_set.pages: | 72 for page in page_set.pages: |
| 72 page.script_to_evaluate_on_commit = test_harness_script | 73 page.script_to_evaluate_on_commit = test_harness_script |
| 73 return page_set | 74 return page_set |
| OLD | NEW |