Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(985)

Side by Side Diff: conformance/resources/webgl-test.js

Issue 42083002: Add ToT WebGL conformance tests : part 10 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/webgl/sdk/tests/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « conformance/resources/vertexShader.vert ('k') | conformance/resources/webgl-test-utils.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
OLDNEW
(Empty)
1 /*
2 ** Copyright (c) 2012 The Khronos Group Inc.
3 **
4 ** Permission is hereby granted, free of charge, to any person obtaining a
5 ** copy of this software and/or associated documentation files (the
6 ** "Materials"), to deal in the Materials without restriction, including
7 ** without limitation the rights to use, copy, modify, merge, publish,
8 ** distribute, sublicense, and/or sell copies of the Materials, and to
9 ** permit persons to whom the Materials are furnished to do so, subject to
10 ** the following conditions:
11 **
12 ** The above copyright notice and this permission notice shall be included
13 ** in all copies or substantial portions of the Materials.
14 **
15 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
22 */
23
24 function webglTestLog(msg) {
25 if (window.console && window.console.log) {
26 window.console.log(msg);
27 }
28 if (document.getElementById("console")) {
29 var log = document.getElementById("console");
30 log.innerHTML += msg + "<br>";
31 }
32 }
33
34 function getGLErrorAsString(ctx, err) {
35 if (err === ctx.NO_ERROR) {
36 return "NO_ERROR";
37 }
38 for (var name in ctx) {
39 if (ctx[name] === err) {
40 return name;
41 }
42 }
43 return "0x" + err.toString(16);
44 }
45
46 // Pass undefined for glError to test that it at least throws some error
47 function shouldGenerateGLError(ctx, glErrors, evalStr) {
48 if (!glErrors.length) {
49 glErrors = [glErrors];
50 }
51 var exception;
52 try {
53 eval(evalStr);
54 } catch (e) {
55 exception = e;
56 }
57 if (exception) {
58 testFailed(evalStr + " threw exception " + exception);
59 } else {
60 var err = ctx.getError();
61 var errStrs = [];
62 for (var ii = 0; ii < glErrors.length; ++ii) {
63 errStrs.push(getGLErrorAsString(ctx, glErrors[ii]));
64 }
65 var expected = errStrs.join(" or ");
66 if (glErrors.indexOf(err) < 0) {
67 testFailed(evalStr + " expected: " + expected + ". Was " + getGLErrorAsStr ing(ctx, err) + ".");
68 } else {
69 var msg = (glErrors.length == 1) ? " generated expected GL error: " :
70 " generated one of expected GL errors: ";
71 testPassed(evalStr + msg + expected + ".");
72 }
73 }
74 }
75
76 /**
77 * Tests that the first error GL returns is the specified error.
78 * @param {!WebGLContext} gl The WebGLContext to use.
79 * @param {number|!Array.<number>} glError The expected gl
80 * error. Multiple errors can be passed in using an
81 * array.
82 * @param {string} opt_msg Optional additional message.
83 */
84 function glErrorShouldBe(gl, glErrors, opt_msg) {
85 if (!glErrors.length) {
86 glErrors = [glErrors];
87 }
88 opt_msg = opt_msg || "";
89 var err = gl.getError();
90 var ndx = glErrors.indexOf(err);
91 var errStrs = [];
92 for (var ii = 0; ii < glErrors.length; ++ii) {
93 errStrs.push(getGLErrorAsString(gl, glErrors[ii]));
94 }
95 var expected = errStrs.join(" or ");
96 if (ndx < 0) {
97 var msg = "getError expected" + ((glErrors.length > 1) ? " one of: " : ": ") ;
98 testFailed(msg + expected + ". Was " + getGLErrorAsString(gl, err) + " : " + opt_msg);
99 } else {
100 var msg = "getError was " + ((glErrors.length > 1) ? "one of: " : "expected value: ");
101 testPassed(msg + expected + " : " + opt_msg);
102 }
103 };
104
105
106
OLDNEW
« no previous file with comments | « conformance/resources/vertexShader.vert ('k') | conformance/resources/webgl-test-utils.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698