| 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 os | |
| 6 | |
| 7 from gpu_tests import gpu_integration_test | 5 from gpu_tests import gpu_integration_test |
| 8 from gpu_tests import path_util | |
| 9 from gpu_tests import webgl_conformance | 6 from gpu_tests import webgl_conformance |
| 10 from gpu_tests import webgl_conformance_expectations | 7 from gpu_tests import webgl_conformance_expectations |
| 11 from gpu_tests import webgl2_conformance_expectations | 8 from gpu_tests import webgl2_conformance_expectations |
| 12 | 9 |
| 13 conformance_relcomps = ( | |
| 14 'third_party', 'webgl', 'src', 'sdk', 'tests') | |
| 15 | |
| 16 extensions_relcomps = ( | |
| 17 'content', 'test', 'data', 'gpu') | |
| 18 | |
| 19 conformance_relpath = os.path.join(*conformance_relcomps) | |
| 20 extensions_relpath = os.path.join(*extensions_relcomps) | |
| 21 | |
| 22 # These URL prefixes are needed because having more than one static | |
| 23 # server dir is causing the base server directory to be moved up the | |
| 24 # directory hierarchy. | |
| 25 url_prefixes_to_trim = [ | |
| 26 '/'.join(conformance_relcomps) + '/', | |
| 27 '/'.join(extensions_relcomps) + '/' | |
| 28 ] | |
| 29 | |
| 30 extension_harness_additional_script = r""" | |
| 31 window.onload = function() { window._loaded = true; } | |
| 32 """ | |
| 33 | 10 |
| 34 class WebGLConformanceIntegrationTest(gpu_integration_test.GpuIntegrationTest): | 11 class WebGLConformanceIntegrationTest(gpu_integration_test.GpuIntegrationTest): |
| 35 | 12 |
| 36 _webgl_version = None | 13 _webgl_version = None |
| 37 | 14 |
| 38 @classmethod | 15 @classmethod |
| 39 def Name(cls): | 16 def Name(cls): |
| 40 return 'webgl_conformance' | 17 return 'webgl_conformance' |
| 41 | 18 |
| 42 @classmethod | 19 @classmethod |
| 43 def AddCommandlineArgs(cls, parser): | 20 def AddCommandlineArgs(cls, parser): |
| 44 parser.add_option('--webgl-conformance-version', | 21 parser.add_option('--webgl-conformance-version', |
| 45 help='Version of the WebGL conformance tests to run.', | 22 help='Version of the WebGL conformance tests to run.', |
| 46 default='1.0.4') | 23 default='1.0.4') |
| 47 parser.add_option('--webgl2-only', | 24 parser.add_option('--webgl2-only', |
| 48 help='Whether we include webgl 1 tests if version is 2.0.0 or above.', | 25 help='Whether we include webgl 1 tests if version is 2.0.0 or above.', |
| 49 default='false') | 26 default='false') |
| 50 | 27 |
| 51 @classmethod | 28 @classmethod |
| 52 def GenerateGpuTests(cls, options): | 29 def GenerateGpuTests(cls, options): |
| 53 # | |
| 54 # Conformance tests | |
| 55 # | |
| 56 test_paths = webgl_conformance.WebglConformance._ParseTests( | 30 test_paths = webgl_conformance.WebglConformance._ParseTests( |
| 57 '00_test_list.txt', | 31 '00_test_list.txt', |
| 58 options.webgl_conformance_version, | 32 options.webgl_conformance_version, |
| 59 (options.webgl2_only == 'true'), | 33 (options.webgl2_only == 'true'), |
| 60 None) | 34 None) |
| 61 cls._webgl_version = [ | 35 cls._webgl_version = [ |
| 62 int(x) for x in options.webgl_conformance_version.split('.')][0] | 36 int(x) for x in options.webgl_conformance_version.split('.')][0] |
| 63 for test_path in test_paths: | 37 for test_path in test_paths: |
| 64 # generated test name cannot contain '.' | 38 # generated test name cannot contain '.' |
| 65 name = webgl_conformance.GenerateTestNameFromTestPath(test_path).replace( | 39 name = webgl_conformance.GenerateTestNameFromTestPath(test_path).replace( |
| 66 '.', '_') | 40 '.', '_') |
| 67 yield (name, | 41 yield (name, test_path, ()) |
| 68 os.path.join(conformance_relpath, test_path), | |
| 69 ('_RunConformanceTest')) | |
| 70 | |
| 71 # | |
| 72 # Extension tests | |
| 73 # | |
| 74 extension_tests = cls._GetExtensionList() | |
| 75 # Coverage test. | |
| 76 yield('WebglExtension_TestCoverage', | |
| 77 os.path.join(extensions_relpath, 'webgl_extension_test.html'), | |
| 78 ('_RunExtensionCoverageTest', | |
| 79 extension_tests, | |
| 80 cls._webgl_version)) | |
| 81 # Individual extension tests. | |
| 82 for extension in extension_tests: | |
| 83 yield('WebglExtension_%s' % extension, | |
| 84 os.path.join(extensions_relpath, 'webgl_extension_test.html'), | |
| 85 ('_RunExtensionTest', | |
| 86 extension, | |
| 87 cls._webgl_version)) | |
| 88 | |
| 89 @classmethod | |
| 90 def _GetExtensionList(cls): | |
| 91 if cls._webgl_version == 1: | |
| 92 return [ | |
| 93 'ANGLE_instanced_arrays', | |
| 94 'EXT_blend_minmax', | |
| 95 'EXT_disjoint_timer_query', | |
| 96 'EXT_frag_depth', | |
| 97 'EXT_shader_texture_lod', | |
| 98 'EXT_sRGB', | |
| 99 'EXT_texture_filter_anisotropic', | |
| 100 'OES_element_index_uint', | |
| 101 'OES_standard_derivatives', | |
| 102 'OES_texture_float', | |
| 103 'OES_texture_float_linear', | |
| 104 'OES_texture_half_float', | |
| 105 'OES_texture_half_float_linear', | |
| 106 'OES_vertex_array_object', | |
| 107 'WEBGL_compressed_texture_astc', | |
| 108 'WEBGL_compressed_texture_atc', | |
| 109 'WEBGL_compressed_texture_etc1', | |
| 110 'WEBGL_compressed_texture_pvrtc', | |
| 111 'WEBGL_compressed_texture_s3tc', | |
| 112 'WEBGL_compressed_texture_s3tc_srgb', | |
| 113 'WEBGL_debug_renderer_info', | |
| 114 'WEBGL_debug_shaders', | |
| 115 'WEBGL_depth_texture', | |
| 116 'WEBGL_draw_buffers', | |
| 117 'WEBGL_lose_context', | |
| 118 ] | |
| 119 else: | |
| 120 return [ | |
| 121 'EXT_color_buffer_float', | |
| 122 'EXT_disjoint_timer_query', | |
| 123 'EXT_texture_filter_anisotropic', | |
| 124 'OES_texture_float_linear', | |
| 125 'WEBGL_compressed_texture_astc', | |
| 126 'WEBGL_compressed_texture_atc', | |
| 127 'WEBGL_compressed_texture_es3_0', | |
| 128 'WEBGL_compressed_texture_etc1', | |
| 129 'WEBGL_compressed_texture_pvrtc', | |
| 130 'WEBGL_compressed_texture_s3tc', | |
| 131 'WEBGL_compressed_texture_s3tc_srgb', | |
| 132 'WEBGL_debug_renderer_info', | |
| 133 'WEBGL_debug_shaders', | |
| 134 'WEBGL_lose_context', | |
| 135 ] | |
| 136 | 42 |
| 137 def RunActualGpuTest(self, test_path, *args): | 43 def RunActualGpuTest(self, test_path, *args): |
| 138 # This indirection allows these tests to trampoline through | |
| 139 # _RunGpuTest. | |
| 140 test_name = args[0] | |
| 141 getattr(self, test_name)(test_path, *args[1:]) | |
| 142 | |
| 143 def _NavigateTo(self, test_path, harness_script): | |
| 144 url = self.UrlOfStaticFilePath(test_path) | 44 url = self.UrlOfStaticFilePath(test_path) |
| 45 harness_script = webgl_conformance.conformance_harness_script |
| 145 self.tab.Navigate(url, script_to_evaluate_on_commit=harness_script) | 46 self.tab.Navigate(url, script_to_evaluate_on_commit=harness_script) |
| 146 | |
| 147 def _CheckTestCompletion(self): | |
| 148 self.tab.action_runner.WaitForJavaScriptCondition( | 47 self.tab.action_runner.WaitForJavaScriptCondition( |
| 149 'webglTestHarness._finished', timeout_in_seconds=300) | 48 'webglTestHarness._finished', timeout_in_seconds=300) |
| 150 if not webgl_conformance._DidWebGLTestSucceed(self.tab): | 49 if not webgl_conformance._DidWebGLTestSucceed(self.tab): |
| 151 self.fail(webgl_conformance._WebGLTestMessages(self.tab)) | 50 self.fail(webgl_conformance._WebGLTestMessages(self.tab)) |
| 152 | 51 |
| 153 def _RunConformanceTest(self, test_path, *args): | |
| 154 self._NavigateTo(test_path, webgl_conformance.conformance_harness_script) | |
| 155 self._CheckTestCompletion() | |
| 156 | |
| 157 | |
| 158 def _GetExtensionHarnessScript(self): | |
| 159 return (webgl_conformance.conformance_harness_script + | |
| 160 extension_harness_additional_script) | |
| 161 | |
| 162 def _RunExtensionCoverageTest(self, test_path, *args): | |
| 163 self._NavigateTo(test_path, self._GetExtensionHarnessScript()) | |
| 164 self.tab.action_runner.WaitForJavaScriptCondition( | |
| 165 'window._loaded', timeout_in_seconds=300) | |
| 166 extension_list = args[0] | |
| 167 webgl_version = args[1] | |
| 168 context_type = "webgl2" if webgl_version == 2 else "webgl" | |
| 169 extension_list_string = "[" | |
| 170 for extension in extension_list: | |
| 171 extension_list_string = extension_list_string + extension + ", " | |
| 172 extension_list_string = extension_list_string + "]" | |
| 173 self.tab.action_runner.EvaluateJavaScript( | |
| 174 'checkSupportedExtensions("%s", "%s")' % ( | |
| 175 extension_list_string, context_type)) | |
| 176 self._CheckTestCompletion() | |
| 177 | |
| 178 def _RunExtensionTest(self, test_path, *args): | |
| 179 self._NavigateTo(test_path, self._GetExtensionHarnessScript()) | |
| 180 self.tab.action_runner.WaitForJavaScriptCondition( | |
| 181 'window._loaded', timeout_in_seconds=300) | |
| 182 extension = args[0] | |
| 183 webgl_version = args[1] | |
| 184 context_type = "webgl2" if webgl_version == 2 else "webgl" | |
| 185 self.tab.action_runner.EvaluateJavaScript( | |
| 186 'checkExtension("%s", "%s")' % (extension, context_type)) | |
| 187 self._CheckTestCompletion() | |
| 188 | |
| 189 @classmethod | 52 @classmethod |
| 190 def CustomizeOptions(cls): | 53 def CustomizeOptions(cls): |
| 191 assert cls._webgl_version == 1 or cls._webgl_version == 2 | 54 assert cls._webgl_version == 1 or cls._webgl_version == 2 |
| 192 validator = None | 55 validator = None |
| 193 if cls._webgl_version == 1: | 56 if cls._webgl_version == 1: |
| 194 validator = webgl_conformance.WebglConformanceValidator() | 57 validator = webgl_conformance.WebglConformanceValidator() |
| 195 else: | 58 else: |
| 196 validator = webgl_conformance.Webgl2ConformanceValidator() | 59 validator = webgl_conformance.Webgl2ConformanceValidator() |
| 197 validator.CustomizeBrowserOptions(cls._finder_options.browser_options) | 60 validator.CustomizeBrowserOptions(cls._finder_options.browser_options) |
| 198 | 61 |
| 199 @classmethod | 62 @classmethod |
| 200 def _CreateExpectations(cls): | 63 def _CreateExpectations(cls): |
| 201 assert cls._webgl_version == 1 or cls._webgl_version == 2 | 64 assert cls._webgl_version == 1 or cls._webgl_version == 2 |
| 202 if cls._webgl_version == 1: | 65 if cls._webgl_version == 1: |
| 203 return webgl_conformance_expectations.WebGLConformanceExpectations( | 66 return webgl_conformance_expectations.WebGLConformanceExpectations( |
| 204 webgl_conformance.conformance_path, url_prefixes=url_prefixes_to_trim) | 67 webgl_conformance.conformance_path) |
| 205 else: | 68 else: |
| 206 return webgl2_conformance_expectations.WebGL2ConformanceExpectations( | 69 return webgl2_conformance_expectations.WebGL2ConformanceExpectations( |
| 207 webgl_conformance.conformance_path, url_prefixes=url_prefixes_to_trim) | 70 webgl_conformance.conformance_path) |
| 208 | 71 |
| 209 @classmethod | 72 @classmethod |
| 210 def setUpClass(cls): | 73 def setUpClass(cls): |
| 211 super(cls, WebGLConformanceIntegrationTest).setUpClass() | 74 super(cls, WebGLConformanceIntegrationTest).setUpClass() |
| 212 cls.CustomizeOptions() | 75 cls.CustomizeOptions() |
| 213 cls.SetBrowserOptions(cls._finder_options) | 76 cls.SetBrowserOptions(cls._finder_options) |
| 214 cls.StartBrowser() | 77 cls.StartBrowser() |
| 215 # By setting multiple server directories, the root of the server | 78 cls.SetStaticServerDirs([webgl_conformance.conformance_path]) |
| 216 # implicitly becomes the common base directory, i.e., the Chromium | |
| 217 # src dir, and all URLs have to be specified relative to that. | |
| 218 cls.SetStaticServerDirs([ | |
| 219 os.path.join(path_util.GetChromiumSrcDir(), conformance_relpath), | |
| 220 os.path.join(path_util.GetChromiumSrcDir(), extensions_relpath)]) | |
| OLD | NEW |