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