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

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

Issue 8342021: Add webgl conformance tests r15841. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/webgl/sdk/tests/
Patch Set: Created 9 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
+ LF
OLDNEW
(Empty)
1 // ArgGenerators contains argument generators for WebGL functions.
2 // The argument generators are used for running random tests against the WebGL
3 // functions.
4 //
5 // ArgGenerators is an object consisting of functionName : argGen -properties.
6 //
7 // functionName is a WebGL context function name and the argGen is an argument
8 // generator object that encapsulates the requirements to run
9 // randomly generated tests on the WebGL function.
10 //
11 // An argGen object has the following methods:
12 // - setup -- set up state for testing the GL function, returns values
13 // that need cleanup in teardown. Run once before entering a
14 // test loop.
15 // - teardown -- do cleanup on setup's return values after testing is complete
16 // - generate -- generate a valid set of random arguments for the GL function
17 // - returnValueCleanup -- do cleanup on value returned by the tested GL funct ion
18 // - cleanup -- do cleanup on generated arguments from generate
19 // - checkArgValidity -- check if passed args are valid. Has a call signature
20 // that matches generate's return value. Returns true
21 // if args are valid, false if not.
22 //
23 // Example test loop that demonstrates how the function args and return
24 // values flow together:
25 //
26 // var setupArgs = argGen.setup();
27 // for (var i=0; i<numberOfTests; i++) {
28 // var generatedArgs = argGen.generate.apply(argGen, setupArgs);
29 // var validArgs = argGen.checkArgValidity.apply(argGen, generatedArgs);
30 // var rv = call the GL function with generatedArgs;
31 // argGen.returnValueCleanup(rv);
32 // argGen.cleanup.apply(argGen, generatedArgs);
33 // }
34 // argGen.teardown.apply(argGen, setupArgs);
35 //
36 ArgGenerators = {
37
38 // GL functions in alphabetical order
39
40 // B-2
41
42 bindBuffer : {
43 generate : function(buf) {
44 return [bufferTarget.random(), GL.createBuffer()];
45 },
46 checkArgValidity : function(target, buf) {
47 if (!bufferTarget.has(target))
48 return false;
49 GL.bindBuffer(target, buf);
50 return GL.isBuffer(buf);
51 },
52 cleanup : function(t, buf, m) {
53 GL.deleteBuffer(buf);
54 }
55 },
56 bindFramebuffer : {
57 generate : function() {
58 return [GL.FRAMEBUFFER, Math.random() > 0.5 ? null : GL.createFramebuffer( )];
59 },
60 checkArgValidity : function(target, fbo) {
61 if (target != GL.FRAMEBUFFER)
62 return false;
63 if (fbo != null)
64 GL.bindFramebuffer(target, fbo);
65 return (fbo == null || GL.isFramebuffer(fbo));
66 },
67 cleanup : function(target, fbo) {
68 GL.bindFramebuffer(target, null);
69 if (fbo)
70 GL.deleteFramebuffer(fbo);
71 }
72 },
73 bindRenderbuffer : {
74 generate : function() {
75 return [GL.RENDERBUFFER, Math.random() > 0.5 ? null : GL.createRenderbuffe r()];
76 },
77 checkArgValidity : function(target, rbo) {
78 if (target != GL.RENDERBUFFER)
79 return false;
80 if (rbo != null)
81 GL.bindRenderbuffer(target, rbo);
82 return (rbo == null || GL.isRenderbuffer(rbo));
83 },
84 cleanup : function(target, rbo) {
85 GL.bindRenderbuffer(target, null);
86 if (rbo)
87 GL.deleteRenderbuffer(rbo);
88 }
89 },
90 bindTexture : {
91 generate : function() {
92 return [bindTextureTarget.random(), Math.random() > 0.5 ? null : GL.create Texture()];
93 },
94 checkArgValidity : function(target, o) {
95 if (!bindTextureTarget.has(target))
96 return false;
97 if (o != null)
98 GL.bindTexture(target, o);
99 return (o == null || GL.isTexture(o));
100 },
101 cleanup : function(target, o) {
102 GL.bindTexture(target, null);
103 if (o)
104 GL.deleteTexture(o);
105 }
106 },
107 blendColor : {
108 generate : function() { return randomColor(); },
109 teardown : function() { GL.blendColor(0,0,0,0); }
110 },
111 blendEquation : {
112 generate : function() { return [blendEquationMode.random()]; },
113 checkArgValidity : function(o) { return blendEquationMode.has(o); },
114 teardown : function() { GL.blendEquation(GL.FUNC_ADD); }
115 },
116 blendEquationSeparate : {
117 generate : function() {
118 return [blendEquationMode.random(), blendEquationMode.random()];
119 },
120 checkArgValidity : function(o,p) {
121 return blendEquationMode.has(o) && blendEquationMode.has(p);
122 },
123 teardown : function() { GL.blendEquationSeparate(GL.FUNC_ADD, GL.FUNC_ADD); }
124 },
125 blendFunc : {
126 generate : function() {
127 return [blendFuncSfactor.random(), blendFuncDfactor.random()];
128 },
129 checkArgValidity : function(s,d) {
130 return blendFuncSfactor.has(s) && blendFuncDfactor.has(d);
131 },
132 teardown : function() { GL.blendFunc(GL.ONE, GL.ZERO); }
133 },
134 blendFuncSeparate : {
135 generate : function() {
136 return [blendFuncSfactor.random(), blendFuncDfactor.random(),
137 blendFuncSfactor.random(), blendFuncDfactor.random()];
138 },
139 checkArgValidity : function(s,d,as,ad) {
140 return blendFuncSfactor.has(s) && blendFuncDfactor.has(d) &&
141 blendFuncSfactor.has(as) && blendFuncDfactor.has(ad) ;
142 },
143 teardown : function() {
144 GL.blendFuncSeparate(GL.ONE, GL.ZERO, GL.ONE, GL.ZERO);
145 }
146 }
147
148 };
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