| 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 | 4 |
| 5 import logging | 5 import logging |
| 6 import os | 6 import os |
| 7 import sys | 7 import sys |
| 8 | 8 |
| 9 from gpu_tests import gpu_integration_test | 9 from gpu_tests import gpu_integration_test |
| 10 from gpu_tests import path_util | 10 from gpu_tests import path_util |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 # This indirection allows these tests to trampoline through | 200 # This indirection allows these tests to trampoline through |
| 201 # _RunGpuTest. | 201 # _RunGpuTest. |
| 202 test_name = args[0] | 202 test_name = args[0] |
| 203 getattr(self, test_name)(test_path, *args[1:]) | 203 getattr(self, test_name)(test_path, *args[1:]) |
| 204 | 204 |
| 205 def _NavigateTo(self, test_path, harness_script): | 205 def _NavigateTo(self, test_path, harness_script): |
| 206 url = self.UrlOfStaticFilePath(test_path) | 206 url = self.UrlOfStaticFilePath(test_path) |
| 207 self.tab.Navigate(url, script_to_evaluate_on_commit=harness_script) | 207 self.tab.Navigate(url, script_to_evaluate_on_commit=harness_script) |
| 208 | 208 |
| 209 def _CheckTestCompletion(self): | 209 def _CheckTestCompletion(self): |
| 210 self.tab.action_runner.WaitForJavaScriptCondition( | 210 self.tab.action_runner.WaitForJavaScriptCondition2( |
| 211 'webglTestHarness._finished', timeout_in_seconds=300) | 211 'webglTestHarness._finished', timeout=300) |
| 212 if not self._DidWebGLTestSucceed(self.tab): | 212 if not self._DidWebGLTestSucceed(self.tab): |
| 213 self.fail(self._WebGLTestMessages(self.tab)) | 213 self.fail(self._WebGLTestMessages(self.tab)) |
| 214 | 214 |
| 215 def _RunConformanceTest(self, test_path, *args): | 215 def _RunConformanceTest(self, test_path, *args): |
| 216 self._NavigateTo(test_path, conformance_harness_script) | 216 self._NavigateTo(test_path, conformance_harness_script) |
| 217 self._CheckTestCompletion() | 217 self._CheckTestCompletion() |
| 218 | 218 |
| 219 | 219 |
| 220 def _GetExtensionHarnessScript(self): | 220 def _GetExtensionHarnessScript(self): |
| 221 return conformance_harness_script + extension_harness_additional_script | 221 return conformance_harness_script + extension_harness_additional_script |
| 222 | 222 |
| 223 def _RunExtensionCoverageTest(self, test_path, *args): | 223 def _RunExtensionCoverageTest(self, test_path, *args): |
| 224 self._NavigateTo(test_path, self._GetExtensionHarnessScript()) | 224 self._NavigateTo(test_path, self._GetExtensionHarnessScript()) |
| 225 self.tab.action_runner.WaitForJavaScriptCondition( | 225 self.tab.action_runner.WaitForJavaScriptCondition2( |
| 226 'window._loaded', timeout_in_seconds=300) | 226 'window._loaded', timeout=300) |
| 227 extension_list = args[0] | 227 extension_list = args[0] |
| 228 webgl_version = args[1] | 228 webgl_version = args[1] |
| 229 context_type = "webgl2" if webgl_version == 2 else "webgl" | 229 context_type = "webgl2" if webgl_version == 2 else "webgl" |
| 230 extension_list_string = "[" | 230 extension_list_string = "[" |
| 231 for extension in extension_list: | 231 for extension in extension_list: |
| 232 extension_list_string = extension_list_string + extension + ", " | 232 extension_list_string = extension_list_string + extension + ", " |
| 233 extension_list_string = extension_list_string + "]" | 233 extension_list_string = extension_list_string + "]" |
| 234 self.tab.action_runner.EvaluateJavaScript( | 234 self.tab.action_runner.EvaluateJavaScript2( |
| 235 'checkSupportedExtensions("%s", "%s")' % ( | 235 'checkSupportedExtensions({{ extensions_string }}, {{context_type}})', |
| 236 extension_list_string, context_type)) | 236 extensions_string=extension_list_string, context_type=context_type) |
| 237 self._CheckTestCompletion() | 237 self._CheckTestCompletion() |
| 238 | 238 |
| 239 def _RunExtensionTest(self, test_path, *args): | 239 def _RunExtensionTest(self, test_path, *args): |
| 240 self._NavigateTo(test_path, self._GetExtensionHarnessScript()) | 240 self._NavigateTo(test_path, self._GetExtensionHarnessScript()) |
| 241 self.tab.action_runner.WaitForJavaScriptCondition( | 241 self.tab.action_runner.WaitForJavaScriptCondition2( |
| 242 'window._loaded', timeout_in_seconds=300) | 242 'window._loaded', timeout=300) |
| 243 extension = args[0] | 243 extension = args[0] |
| 244 webgl_version = args[1] | 244 webgl_version = args[1] |
| 245 context_type = "webgl2" if webgl_version == 2 else "webgl" | 245 context_type = "webgl2" if webgl_version == 2 else "webgl" |
| 246 self.tab.action_runner.EvaluateJavaScript( | 246 self.tab.action_runner.EvaluateJavaScript2( |
| 247 'checkExtension("%s", "%s")' % (extension, context_type)) | 247 'checkExtension({{ extension }}, {{ context_type }})', |
| 248 extension=extension, context_type=context_type) |
| 248 self._CheckTestCompletion() | 249 self._CheckTestCompletion() |
| 249 | 250 |
| 250 @classmethod | 251 @classmethod |
| 251 def CustomizeOptions(cls): | 252 def CustomizeOptions(cls): |
| 252 assert cls._webgl_version == 1 or cls._webgl_version == 2 | 253 assert cls._webgl_version == 1 or cls._webgl_version == 2 |
| 253 browser_options = cls._finder_options.browser_options | 254 browser_options = cls._finder_options.browser_options |
| 254 # --test-type=gpu is used only to suppress the "Google API Keys are missing" | 255 # --test-type=gpu is used only to suppress the "Google API Keys are missing" |
| 255 # infobar, which causes flakiness in tests. | 256 # infobar, which causes flakiness in tests. |
| 256 browser_options.AppendExtraBrowserArgs([ | 257 browser_options.AppendExtraBrowserArgs([ |
| 257 '--disable-gesture-requirement-for-media-playback', | 258 '--disable-gesture-requirement-for-media-playback', |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 # implicitly becomes the common base directory, i.e., the Chromium | 322 # implicitly becomes the common base directory, i.e., the Chromium |
| 322 # src dir, and all URLs have to be specified relative to that. | 323 # src dir, and all URLs have to be specified relative to that. |
| 323 cls.SetStaticServerDirs([ | 324 cls.SetStaticServerDirs([ |
| 324 os.path.join(path_util.GetChromiumSrcDir(), conformance_relpath), | 325 os.path.join(path_util.GetChromiumSrcDir(), conformance_relpath), |
| 325 os.path.join(path_util.GetChromiumSrcDir(), extensions_relpath)]) | 326 os.path.join(path_util.GetChromiumSrcDir(), extensions_relpath)]) |
| 326 | 327 |
| 327 # Helper functions. | 328 # Helper functions. |
| 328 | 329 |
| 329 @staticmethod | 330 @staticmethod |
| 330 def _DidWebGLTestSucceed(tab): | 331 def _DidWebGLTestSucceed(tab): |
| 331 return tab.EvaluateJavaScript('webglTestHarness._allTestSucceeded') | 332 return tab.EvaluateJavaScript2('webglTestHarness._allTestSucceeded') |
| 332 | 333 |
| 333 @staticmethod | 334 @staticmethod |
| 334 def _WebGLTestMessages(tab): | 335 def _WebGLTestMessages(tab): |
| 335 return tab.EvaluateJavaScript('webglTestHarness._messages') | 336 return tab.EvaluateJavaScript2('webglTestHarness._messages') |
| 336 | 337 |
| 337 @classmethod | 338 @classmethod |
| 338 def _ParseTests(cls, path, version, webgl2_only, folder_min_version): | 339 def _ParseTests(cls, path, version, webgl2_only, folder_min_version): |
| 339 test_paths = [] | 340 test_paths = [] |
| 340 current_dir = os.path.dirname(path) | 341 current_dir = os.path.dirname(path) |
| 341 full_path = os.path.normpath(os.path.join(conformance_path, path)) | 342 full_path = os.path.normpath(os.path.join(conformance_path, path)) |
| 342 webgl_version = int(version.split('.')[0]) | 343 webgl_version = int(version.split('.')[0]) |
| 343 | 344 |
| 344 if not os.path.exists(full_path): | 345 if not os.path.exists(full_path): |
| 345 raise Exception('The WebGL conformance test path specified ' + | 346 raise Exception('The WebGL conformance test path specified ' + |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 test = os.path.join(current_dir, test_name) | 395 test = os.path.join(current_dir, test_name) |
| 395 if webgl_version > 1: | 396 if webgl_version > 1: |
| 396 test += '?webglVersion=' + str(webgl_version) | 397 test += '?webglVersion=' + str(webgl_version) |
| 397 test_paths.append(test) | 398 test_paths.append(test) |
| 398 | 399 |
| 399 return test_paths | 400 return test_paths |
| 400 | 401 |
| 401 def load_tests(loader, tests, pattern): | 402 def load_tests(loader, tests, pattern): |
| 402 del loader, tests, pattern # Unused. | 403 del loader, tests, pattern # Unused. |
| 403 return gpu_integration_test.LoadAllTestsInModule(sys.modules[__name__]) | 404 return gpu_integration_test.LoadAllTestsInModule(sys.modules[__name__]) |
| OLD | NEW |