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

Side by Side Diff: conformance/more/conformance/argGenerators-B2.js

Issue 41503006: Add ToT WebGL conformance tests : part 8 (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
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 // ArgGenerators contains argument generators for WebGL functions.
25 // The argument generators are used for running random tests against the WebGL
26 // functions.
27 //
28 // ArgGenerators is an object consisting of functionName : argGen -properties.
29 //
30 // functionName is a WebGL context function name and the argGen is an argument
31 // generator object that encapsulates the requirements to run
32 // randomly generated tests on the WebGL function.
33 //
34 // An argGen object has the following methods:
35 // - setup -- set up state for testing the GL function, returns values
36 // that need cleanup in teardown. Run once before entering a
37 // test loop.
38 // - teardown -- do cleanup on setup's return values after testing is complete
39 // - generate -- generate a valid set of random arguments for the GL function
40 // - returnValueCleanup -- do cleanup on value returned by the tested GL funct ion
41 // - cleanup -- do cleanup on generated arguments from generate
42 // - checkArgValidity -- check if passed args are valid. Has a call signature
43 // that matches generate's return value. Returns true
44 // if args are valid, false if not.
45 //
46 // Example test loop that demonstrates how the function args and return
47 // values flow together:
48 //
49 // var setupArgs = argGen.setup();
50 // for (var i=0; i<numberOfTests; i++) {
51 // var generatedArgs = argGen.generate.apply(argGen, setupArgs);
52 // var validArgs = argGen.checkArgValidity.apply(argGen, generatedArgs);
53 // var rv = call the GL function with generatedArgs;
54 // argGen.returnValueCleanup(rv);
55 // argGen.cleanup.apply(argGen, generatedArgs);
56 // }
57 // argGen.teardown.apply(argGen, setupArgs);
58 //
59 ArgGenerators = {
60
61 // GL functions in alphabetical order
62
63 // B-2
64
65 bindBuffer : {
66 generate : function(buf) {
67 return [bufferTarget.random(), GL.createBuffer()];
68 },
69 checkArgValidity : function(target, buf) {
70 if (!bufferTarget.has(target))
71 return false;
72 GL.bindBuffer(target, buf);
73 return GL.isBuffer(buf);
74 },
75 cleanup : function(t, buf, m) {
76 GL.deleteBuffer(buf);
77 }
78 },
79 bindFramebuffer : {
80 generate : function() {
81 return [GL.FRAMEBUFFER, Math.random() > 0.5 ? null : GL.createFramebuffer( )];
82 },
83 checkArgValidity : function(target, fbo) {
84 if (target != GL.FRAMEBUFFER)
85 return false;
86 if (fbo != null)
87 GL.bindFramebuffer(target, fbo);
88 return (fbo == null || GL.isFramebuffer(fbo));
89 },
90 cleanup : function(target, fbo) {
91 GL.bindFramebuffer(target, null);
92 if (fbo)
93 GL.deleteFramebuffer(fbo);
94 }
95 },
96 bindRenderbuffer : {
97 generate : function() {
98 return [GL.RENDERBUFFER, Math.random() > 0.5 ? null : GL.createRenderbuffe r()];
99 },
100 checkArgValidity : function(target, rbo) {
101 if (target != GL.RENDERBUFFER)
102 return false;
103 if (rbo != null)
104 GL.bindRenderbuffer(target, rbo);
105 return (rbo == null || GL.isRenderbuffer(rbo));
106 },
107 cleanup : function(target, rbo) {
108 GL.bindRenderbuffer(target, null);
109 if (rbo)
110 GL.deleteRenderbuffer(rbo);
111 }
112 },
113 bindTexture : {
114 generate : function() {
115 return [bindTextureTarget.random(), Math.random() > 0.5 ? null : GL.create Texture()];
116 },
117 checkArgValidity : function(target, o) {
118 if (!bindTextureTarget.has(target))
119 return false;
120 if (o != null)
121 GL.bindTexture(target, o);
122 return (o == null || GL.isTexture(o));
123 },
124 cleanup : function(target, o) {
125 GL.bindTexture(target, null);
126 if (o)
127 GL.deleteTexture(o);
128 }
129 },
130 blendColor : {
131 generate : function() { return randomColor(); },
132 teardown : function() { GL.blendColor(0,0,0,0); }
133 },
134 blendEquation : {
135 generate : function() { return [blendEquationMode.random()]; },
136 checkArgValidity : function(o) { return blendEquationMode.has(o); },
137 teardown : function() { GL.blendEquation(GL.FUNC_ADD); }
138 },
139 blendEquationSeparate : {
140 generate : function() {
141 return [blendEquationMode.random(), blendEquationMode.random()];
142 },
143 checkArgValidity : function(o,p) {
144 return blendEquationMode.has(o) && blendEquationMode.has(p);
145 },
146 teardown : function() { GL.blendEquationSeparate(GL.FUNC_ADD, GL.FUNC_ADD); }
147 },
148 blendFunc : {
149 generate : function() {
150 return [blendFuncSfactor.random(), blendFuncDfactor.random()];
151 },
152 checkArgValidity : function(s,d) {
153 return blendFuncSfactor.has(s) && blendFuncDfactor.has(d);
154 },
155 teardown : function() { GL.blendFunc(GL.ONE, GL.ZERO); }
156 },
157 blendFuncSeparate : {
158 generate : function() {
159 return [blendFuncSfactor.random(), blendFuncDfactor.random(),
160 blendFuncSfactor.random(), blendFuncDfactor.random()];
161 },
162 checkArgValidity : function(s,d,as,ad) {
163 return blendFuncSfactor.has(s) && blendFuncDfactor.has(d) &&
164 blendFuncSfactor.has(as) && blendFuncDfactor.has(ad) ;
165 },
166 teardown : function() {
167 GL.blendFuncSeparate(GL.ONE, GL.ZERO, GL.ONE, GL.ZERO);
168 }
169 }
170
171 };
OLDNEW
« no previous file with comments | « conformance/more/conformance/argGenerators-B1.js ('k') | conformance/more/conformance/argGenerators-B3.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698