| 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 import glob | 4 import glob |
| 5 import logging | 5 import logging |
| 6 import os | 6 import os |
| 7 import re | 7 import re |
| 8 import sys | 8 import sys |
| 9 | 9 |
| 10 from gpu_tests import gpu_integration_test | 10 from gpu_tests import gpu_integration_test |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 def RunActualGpuTest(self, test_path, *args): | 124 def RunActualGpuTest(self, test_path, *args): |
| 125 page = args[0] | 125 page = args[0] |
| 126 # Some pixel tests require non-standard browser arguments. Need to | 126 # Some pixel tests require non-standard browser arguments. Need to |
| 127 # check before running each page that it can run in the current | 127 # check before running each page that it can run in the current |
| 128 # browser instance. | 128 # browser instance. |
| 129 self.RestartBrowserIfNecessaryWithArgs(page.browser_args) | 129 self.RestartBrowserIfNecessaryWithArgs(page.browser_args) |
| 130 url = self.UrlOfStaticFilePath(test_path) | 130 url = self.UrlOfStaticFilePath(test_path) |
| 131 # This property actually comes off the class, not 'self'. | 131 # This property actually comes off the class, not 'self'. |
| 132 tab = self.tab | 132 tab = self.tab |
| 133 tab.Navigate(url, script_to_evaluate_on_commit=test_harness_script) | 133 tab.Navigate(url, script_to_evaluate_on_commit=test_harness_script) |
| 134 tab.action_runner.WaitForJavaScriptCondition( | 134 tab.action_runner.WaitForJavaScriptCondition2( |
| 135 'domAutomationController._finished', timeout_in_seconds=300) | 135 'domAutomationController._finished', timeout=300) |
| 136 if not tab.EvaluateJavaScript('domAutomationController._succeeded'): | 136 if not tab.EvaluateJavaScript2('domAutomationController._succeeded'): |
| 137 self.fail('page indicated test failure') | 137 self.fail('page indicated test failure') |
| 138 if not tab.screenshot_supported: | 138 if not tab.screenshot_supported: |
| 139 self.fail('Browser does not support screenshot capture') | 139 self.fail('Browser does not support screenshot capture') |
| 140 screenshot = tab.Screenshot(5) | 140 screenshot = tab.Screenshot(5) |
| 141 if screenshot is None: | 141 if screenshot is None: |
| 142 self.fail('Could not capture screenshot') | 142 self.fail('Could not capture screenshot') |
| 143 dpr = tab.EvaluateJavaScript('window.devicePixelRatio') | 143 dpr = tab.EvaluateJavaScript2('window.devicePixelRatio') |
| 144 if page.test_rect: | 144 if page.test_rect: |
| 145 screenshot = image_util.Crop( | 145 screenshot = image_util.Crop( |
| 146 screenshot, page.test_rect[0] * dpr, page.test_rect[1] * dpr, | 146 screenshot, page.test_rect[0] * dpr, page.test_rect[1] * dpr, |
| 147 page.test_rect[2] * dpr, page.test_rect[3] * dpr) | 147 page.test_rect[2] * dpr, page.test_rect[3] * dpr) |
| 148 if page.expected_colors: | 148 if page.expected_colors: |
| 149 # Use expected colors instead of ref images for validation. | 149 # Use expected colors instead of ref images for validation. |
| 150 self._ValidateScreenshotSamples( | 150 self._ValidateScreenshotSamples( |
| 151 tab, page.name, screenshot, page.expected_colors, dpr) | 151 tab, page.name, screenshot, page.expected_colors, dpr) |
| 152 return | 152 return |
| 153 image_name = self._UrlToImageName(page.name) | 153 image_name = self._UrlToImageName(page.name) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 224 |
| 225 print ('Reference image not found. Writing tab contents as reference to: ' + | 225 print ('Reference image not found. Writing tab contents as reference to: ' + |
| 226 image_path) | 226 image_path) |
| 227 | 227 |
| 228 self._WriteImage(image_path, screenshot) | 228 self._WriteImage(image_path, screenshot) |
| 229 return screenshot | 229 return screenshot |
| 230 | 230 |
| 231 def load_tests(loader, tests, pattern): | 231 def load_tests(loader, tests, pattern): |
| 232 del loader, tests, pattern # Unused. | 232 del loader, tests, pattern # Unused. |
| 233 return gpu_integration_test.LoadAllTestsInModule(sys.modules[__name__]) | 233 return gpu_integration_test.LoadAllTestsInModule(sys.modules[__name__]) |
| OLD | NEW |