OLD | NEW |
| (Empty) |
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
2 "http://www.w3.org/TR/html4/loose.dtd"> | |
3 <html> | |
4 <head> | |
5 <title> | |
6 WebGL Conformance Test Runner. | |
7 </title> | |
8 <style> | |
9 html, body { | |
10 border: 0; | |
11 margin: 0; | |
12 height: 100%; | |
13 height: 100%; | |
14 text-align: center; | |
15 font-family: monospace; | |
16 } | |
17 table { | |
18 width: 100%; | |
19 height: 100%; | |
20 } | |
21 .timeout { } | |
22 .success { } | |
23 .fail { } | |
24 .testpage { border: 1px solid black; background-color: #ccc; } | |
25 .testpagesuccess { border: 1px solid black; background-color: #8F8; } | |
26 .testpagefail { border: 1px solid black; background-color: #F88; } | |
27 .testpagetimeout { border: 1px solid black; background-color: #FC8; } | |
28 .nowebgl { font-weight: bold; color: red; } | |
29 </style> | |
30 <script type="text/javascript" src="resources/webgl-test-harness.js"></script> | |
31 <script> | |
32 var CONFORMANCE_TEST_VERSION = "1.0.0"; | |
33 | |
34 function start() { | |
35 | |
36 function create3DContext(canvas) | |
37 { | |
38 if (!canvas) { | |
39 canvas = document.createElement("canvas"); | |
40 } | |
41 var context = null; | |
42 try { | |
43 context = canvas.getContext("webgl"); | |
44 } catch(e) { | |
45 } | |
46 if (!context) { | |
47 try { | |
48 context = canvas.getContext("experimental-webgl"); | |
49 } catch(e) { | |
50 } | |
51 } | |
52 return context; | |
53 } | |
54 | |
55 var reportType = WebGLTestHarnessModule.TestHarness.reportType; | |
56 | |
57 var Page = function(reporter, url) { | |
58 this.reporter = reporter; | |
59 this.url = url; | |
60 this.totalTests = 0; | |
61 this.totalSuccessful = 0; | |
62 this.totalTimeouts = 0; | |
63 | |
64 var li = reporter.localDoc.createElement('li'); | |
65 var div = reporter.localDoc.createElement('div'); | |
66 var check = reporter.localDoc.createElement('input'); | |
67 check.type = 'checkbox'; | |
68 check.checked = true; | |
69 div.appendChild(check); | |
70 var button = reporter.localDoc.createElement('input'); | |
71 button.type = 'button'; | |
72 button.value = 'run'; | |
73 button.onclick = function() { | |
74 reporter.runTest(url); | |
75 }; | |
76 if (reporter.noWebGL) { | |
77 button.disabled = true; | |
78 } | |
79 div.appendChild(button); | |
80 var a = reporter.localDoc.createElement('a'); | |
81 a.href = url; | |
82 var node = reporter.localDoc.createTextNode(url); | |
83 a.appendChild(node); | |
84 div.appendChild(a); | |
85 li.setAttribute('class', 'testpage'); | |
86 li.appendChild(div); | |
87 var ul = reporter.localDoc.createElement('ul'); | |
88 var node = reporter.localDoc.createTextNode(''); | |
89 li.appendChild(ul); | |
90 div.appendChild(node); | |
91 this.totalsElem = node; | |
92 this.resultElem = ul; | |
93 this.elem = li; | |
94 this.check = check; | |
95 }; | |
96 | |
97 Page.prototype.addResult = function(msg, success) { | |
98 ++this.totalTests; | |
99 if (success === undefined) { | |
100 ++this.totalTimeouts; | |
101 var result = "timeout"; | |
102 var css = "timeout"; | |
103 } else if (success) { | |
104 ++this.totalSuccessful; | |
105 var result = "success"; | |
106 var css = "success"; | |
107 // don't report success. | |
108 return; | |
109 } else { | |
110 var result = "failed"; | |
111 var css = "fail"; | |
112 } | |
113 | |
114 var node = this.reporter.localDoc.createTextNode(result + ': ' + msg); | |
115 var li = this.reporter.localDoc.createElement('li'); | |
116 li.appendChild(node); | |
117 li.setAttribute('class', css); | |
118 this.resultElem.appendChild(li); | |
119 }; | |
120 | |
121 Page.prototype.startPage = function() { | |
122 this.totalTests = 0; | |
123 this.totalSuccessful = 0; | |
124 this.totalTimeouts = 0; | |
125 // remove previous results. | |
126 while (this.resultElem.hasChildNodes()) { | |
127 this.resultElem.removeChild(this.resultElem.childNodes[0]); | |
128 } | |
129 this.totalsElem.textContent = ''; | |
130 return this.check.checked; | |
131 }; | |
132 | |
133 Page.prototype.finishPage = function(success) { | |
134 var msg = ' (' + this.totalSuccessful + ' of ' + | |
135 this.totalTests + ' passed)'; | |
136 if (success === undefined) { | |
137 var css = 'testpagetimeout'; | |
138 msg = '(*timeout*)'; | |
139 ++this.totalTests; | |
140 ++this.totalTimeouts; | |
141 } else if (this.totalSuccessful != this.totalTests) { | |
142 var css = 'testpagefail'; | |
143 } else { | |
144 var css = 'testpagesuccess'; | |
145 } | |
146 this.elem.setAttribute('class', css); | |
147 this.totalsElem.textContent = msg; | |
148 }; | |
149 | |
150 var Reporter = function() { | |
151 this.localDoc = document; | |
152 this.resultElem = document.getElementById("results"); | |
153 this.fullResultsElem = document.getElementById("fullresults"); | |
154 var node = this.localDoc.createTextNode(''); | |
155 this.fullResultsElem.appendChild(node); | |
156 this.fullResultsNode = node; | |
157 this.iframe = document.getElementById("testframe"); | |
158 this.currentPageElem = null; | |
159 this.totalPages = 0; | |
160 this.pagesByURL = {}; | |
161 var canvas = document.getElementById("webglcheck"); | |
162 var ctx = create3DContext(canvas); | |
163 this.noWebGL = !ctx; | |
164 this.contextInfo = {}; | |
165 | |
166 if (ctx) { | |
167 this.contextInfo["VENDOR"] = ctx.getParameter(ctx.VENDOR); | |
168 this.contextInfo["VERSION"] = ctx.getParameter(ctx.VERSION); | |
169 this.contextInfo["RENDERER"] = ctx.getParameter(ctx.RENDERER); | |
170 this.contextInfo["RED_BITS"] = ctx.getParameter(ctx.RED_BITS); | |
171 this.contextInfo["GREEN_BITS"] = ctx.getParameter(ctx.GREEN_BITS); | |
172 this.contextInfo["BLUE_BITS"] = ctx.getParameter(ctx.BLUE_BITS); | |
173 this.contextInfo["ALPHA_BITS"] = ctx.getParameter(ctx.ALPHA_BITS); | |
174 this.contextInfo["DEPTH_BITS"] = ctx.getParameter(ctx.DEPTH_BITS); | |
175 this.contextInfo["STENCIL_BITS"] = ctx.getParameter(ctx.STENCIL_BITS); | |
176 } | |
177 }; | |
178 | |
179 Reporter.prototype.runTest = function(url) { | |
180 var page = this.pagesByURL[url]; | |
181 page.startPage(); | |
182 this.currentPage = page; | |
183 this.iframe.src = url; | |
184 }; | |
185 | |
186 Reporter.prototype.addPage = function(url) { | |
187 var page = new Page(this, url, this.resultElem); | |
188 this.resultElem.appendChild(page.elem); | |
189 ++this.totalPages; | |
190 this.pagesByURL[url] = page; | |
191 }; | |
192 | |
193 Reporter.prototype.startPage = function(url) { | |
194 var page = this.pagesByURL[url]; | |
195 this.currentPage = page; | |
196 return page.startPage(); | |
197 }; | |
198 | |
199 Reporter.prototype.addResult = function(msg, success) { | |
200 if (this.currentPage != null) { | |
201 this.currentPage.addResult(msg, success); | |
202 } | |
203 }; | |
204 | |
205 Reporter.prototype.finishPage = function(success) { | |
206 if (this.currentPage != null) { | |
207 this.currentPage.finishPage(success); | |
208 this.currentPage = null; | |
209 } | |
210 }; | |
211 | |
212 Reporter.prototype.displayFinalResults = function() { | |
213 var totalTests = 0; | |
214 var totalSuccessful = 0; | |
215 var totalTimeouts = 0; | |
216 for (var url in this.pagesByURL) { | |
217 var page = this.pagesByURL[url]; | |
218 totalTests += page.totalTests; | |
219 totalSuccessful += page.totalSuccessful; | |
220 totalTimeouts += page.totalTimeouts; | |
221 } | |
222 var timeout = ''; | |
223 if (totalTimeouts > 0) { | |
224 timeout = ', ' + totalTimeouts + ' timed out'; | |
225 } | |
226 var msg = ' (' + totalSuccessful + ' of ' + | |
227 totalTests + ' passed' + timeout + ')'; | |
228 this.fullResultsNode.textContent = msg; | |
229 | |
230 | |
231 // generate a text summary | |
232 var tx = ""; | |
233 tx += "WebGL Conformance Test Results\n"; | |
234 tx += "Version " + CONFORMANCE_TEST_VERSION + "\n"; | |
235 tx += "\n"; | |
236 tx += "-------------------\n\n"; | |
237 tx += "User Agent: " + (navigator.userAgent ? navigator.userAgent : "(naviga
tor.userAgent is null)") + "\n"; | |
238 tx += "WebGL VENDOR: " + this.contextInfo["VENDOR"] + "\n"; | |
239 tx += "WebGL VERSION: " + this.contextInfo["VERSION"] + "\n"; | |
240 tx += "WebGL RENDERER: " + this.contextInfo["RENDERER"] + "\n"; | |
241 tx += "WebGL R/G/B/A/Depth/Stencil bits (default config): " + this.contextIn
fo["RED_BITS"] + "/" + this.contextInfo["GREEN_BITS"] + "/" + this.contextInfo["
BLUE_BITS"] + "/" + this.contextInfo["ALPHA_BITS"] + "/" + this.contextInfo["DEP
TH_BITS"] + "/" + this.contextInfo["STENCIL_BITS"] + "\n"; | |
242 tx += "\n"; | |
243 tx += "-------------------\n\n"; | |
244 tx += "Test Summary (" + totalTests + " total tests):\n"; | |
245 tx += "Tests PASSED: " + totalSuccessful + "\n"; | |
246 tx += "Tests FAILED: " + (totalTests - totalSuccessful) + "\n"; | |
247 tx += "Tests TIMED OUT: " + totalTimeouts + "\n"; | |
248 tx += "\n"; | |
249 tx += "-------------------\n\n"; | |
250 tx += "Individual Test Results (pass / total / timeout):\n\n"; | |
251 for (var url in this.pagesByURL) { | |
252 var page = this.pagesByURL[url]; | |
253 if (!(page.totalTests == 0 && page.totalTimeouts == 0)) { | |
254 tx += url + ": " + page.totalSuccessful + " / " + page.totalTests + " /
" + page.totalTimeouts + "\n"; | |
255 } | |
256 } | |
257 tx += "\n"; | |
258 tx += "-------------------\n\n"; | |
259 tx += "Generated on: " + (new Date()).toString() + "\n"; | |
260 | |
261 var r = document.getElementById("testResultsAsText"); | |
262 while (r.firstChild) r.removeChild(r.firstChild); | |
263 r.appendChild(document.createTextNode(tx)); | |
264 document.getElementById("showTextSummary").style.visibility = "visible"; | |
265 }; | |
266 | |
267 Reporter.prototype.reportFunc = function(type, msg, success) { | |
268 switch (type) { | |
269 case reportType.ADD_PAGE: | |
270 return this.addPage(msg); | |
271 case reportType.START_PAGE: | |
272 return this.startPage(msg); | |
273 case reportType.TEST_RESULT: | |
274 return this.addResult(msg, success); | |
275 case reportType.FINISH_PAGE: | |
276 return this.finishPage(success); | |
277 case reportType.FINISHED_ALL_TESTS: | |
278 return this.displayFinalResults(); | |
279 default: | |
280 throw 'unhandled'; | |
281 break; | |
282 }; | |
283 }; | |
284 | |
285 document.getElementById("testVersion").innerHTML = CONFORMANCE_TEST_VERSION; | |
286 | |
287 var reporter = new Reporter(); | |
288 var iframe = document.getElementById("testframe"); | |
289 var testHarness = new WebGLTestHarnessModule.TestHarness( | |
290 iframe, | |
291 '00_test_list.txt', | |
292 function(type, msg, success) { | |
293 return reporter.reportFunc(type, msg, success); | |
294 }); | |
295 window.webglTestHarness = testHarness; | |
296 var button = document.getElementById("runTestsButton"); | |
297 button.onclick = function() { | |
298 testHarness.runTests(); | |
299 }; | |
300 var textbutton = document.getElementById("showTextSummary"); | |
301 textbutton.onclick = function() { | |
302 console.log("click"); | |
303 var htmldiv = document.getElementById("testResultsHTML"); | |
304 var textdiv = document.getElementById("testResultsText"); | |
305 if (textdiv.style.display == "none") { | |
306 textdiv.style.display = "block"; | |
307 htmldiv.style.display = "none"; | |
308 textbutton.setAttribute("value", "display html summary"); | |
309 } else { | |
310 textdiv.style.display = "none"; | |
311 htmldiv.style.display = "block"; | |
312 textbutton.setAttribute("value", "display text summary"); | |
313 } | |
314 }; | |
315 if (reporter.noWebGL) { | |
316 button.disabled = true; | |
317 var elem = document.getElementById("nowebgl"); | |
318 elem.style.display = ""; | |
319 } | |
320 } | |
321 </script> | |
322 </head> | |
323 <body onload="start()"> | |
324 <table border="2"> | |
325 <tr style="height: 300px;"> | |
326 <td> | |
327 <table> | |
328 <tr><td><img src="http://www.khronos.org/img/api_logos/webgl-logo.png" /><br />W
ebGL Conformance Test Runner<br/>Version <span id="testVersion"></span><br/><inp
ut type="button" value="run tests" id="runTestsButton"/><br/><input type="button
" style="visibility: hidden;" value="display text summary" id="showTextSummary"/
> | |
329 <div id="nowebgl" class="nowebgl" style="display: none;">This browser does not a
ppear to support WebGL</div></td></tr> | |
330 <tr><td><div style="border: 1px">Results: <span id="fullresults"></span></div> | |
331 <canvas id="webglcheck" style="display: none;"></canvas></td></tr> | |
332 </table> | |
333 </td> | |
334 <td> | |
335 <iframe id="testframe" scrolling="yes" width="100%" height="100%"></iframe> | |
336 </td> | |
337 </tr> | |
338 <tr> | |
339 <td colspan="2"> | |
340 <div style="text-align: left; width: 100%; height: 100%; overflow: auto;"> | |
341 <div id="testResultsHTML"><ul id="results"></ul></div> | |
342 <div style="display: none;" id="testResultsText"><pre id="testResultsAsText"></p
re></div> | |
343 </div> | |
344 </td> | |
345 </tr> | |
346 </table> | |
347 </body> | |
348 </html> | |
OLD | NEW |