OLD | NEW |
| (Empty) |
1 <!-- | |
2 Copyright (C) 2009 Apple Computer, Inc. All rights reserved. | |
3 | |
4 Redistribution and use in source and binary forms, with or without | |
5 modification, are permitted provided that the following conditions | |
6 are met: | |
7 1. Redistributions of source code must retain the above copyright | |
8 notice, this list of conditions and the following disclaimer. | |
9 2. Redistributions in binary form must reproduce the above copyright | |
10 notice, this list of conditions and the following disclaimer in the | |
11 documentation and/or other materials provided with the distribution. | |
12 | |
13 THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | |
14 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
15 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
16 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
17 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
18 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
19 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
20 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
21 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
23 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 --> | |
25 <html> | |
26 <head> | |
27 <link rel="stylesheet" href="../resources/js-test-style.css"/> | |
28 <script src="../resources/js-test-pre.js"></script> | |
29 <script src="resources/webgl-test.js"></script> | |
30 <script src="resources/webgl-test-utils.js"></script> | |
31 </head> | |
32 <body> | |
33 <div id="description"></div> | |
34 <div id="console"></div> | |
35 | |
36 <script> | |
37 var wtu = WebGLTestUtils; | |
38 description("Tests calling WebGL APIs without providing the necessary objects"); | |
39 | |
40 var context = wtu.create3DContext(); | |
41 var program = wtu.loadStandardProgram(context); | |
42 var shader = wtu.loadStandardVertexShader(context); | |
43 var shouldGenerateGLError = wtu.shouldGenerateGLError; | |
44 | |
45 assertMsg(program != null, "Program Compiled"); | |
46 assertMsg(shader != null, "Shader Compiled"); | |
47 shouldGenerateGLError(context, context.INVALID_VALUE, "context.compileShader(und
efined)"); | |
48 shouldGenerateGLError(context, context.INVALID_VALUE, "context.linkProgram(undef
ined)"); | |
49 shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(unde
fined, undefined)"); | |
50 shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(prog
ram, undefined)"); | |
51 shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(unde
fined, shader)"); | |
52 shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(prog
ram, undefined)"); | |
53 shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(unde
fined, shader)"); | |
54 shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(unde
fined, undefined)"); | |
55 shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(unde
fined, 'foo')"); | |
56 shouldGenerateGLError(context, context.INVALID_VALUE, "context.bindAttribLocatio
n(undefined, 0, 'foo')"); | |
57 shouldThrow("context.bindBuffer(context.ARRAY_BUFFER, 0)"); | |
58 shouldThrow("context.bindFramebuffer(context.FRAMEBUFFER, 0)"); | |
59 shouldThrow("context.bindRenderbuffer(context.RENDERBUFFER, 0)"); | |
60 shouldThrow("context.bindTexture(context.TEXTURE_2D, 0)"); | |
61 shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARR
AY_BUFFER, null)"); | |
62 shouldGenerateGLError(context, context.NO_ERROR, "context.bindFramebuffer(contex
t.FRAMEBUFFER, null)"); | |
63 shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(conte
xt.RENDERBUFFER, null)"); | |
64 shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TE
XTURE_2D, null)"); | |
65 shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARR
AY_BUFFER, undefined)"); | |
66 shouldGenerateGLError(context, context.NO_ERROR, "context.bindFramebuffer(contex
t.FRAMEBUFFER, undefined)"); | |
67 shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(conte
xt.RENDERBUFFER, undefined)"); | |
68 shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TE
XTURE_2D, undefined)"); | |
69 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferRe
nderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER,
null)"); | |
70 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferTe
xture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, null
, 0)"); | |
71 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramParamet
er(undefined, 0)"); | |
72 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramInfoLog
(undefined, 0)"); | |
73 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderParamete
r(undefined, 0)"); | |
74 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderInfoLog(
undefined, 0)"); | |
75 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderSource(u
ndefined)"); | |
76 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniform(undefi
ned, null)"); | |
77 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniformLocatio
n(undefined, 'foo')"); | |
78 | |
79 debug(""); | |
80 debug("check with bindings"); | |
81 context.bindBuffer(context.ARRAY_BUFFER, context.createBuffer()); | |
82 context.bindTexture(context.TEXTURE_2D, context.createTexture()); | |
83 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARR
AY_BUFFER, 1, context.STATIC_DRAW)"); | |
84 shouldGenerateGLError(context, context.NO_ERROR, "context.getBufferParameter(con
text.ARRAY_BUFFER, context.BUFFER_SIZE)"); | |
85 shouldGenerateGLError(context, context.NO_ERROR, "context.texImage2D(context.TEX
TURE_2D, 0, context.RGBA, 1, 1, 0, context.RGBA, context.UNSIGNED_BYTE, new Uint
8Array([0,0,0,0]))"); | |
86 shouldGenerateGLError(context, context.NO_ERROR, "context.texParameteri(context.
TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST)"); | |
87 shouldGenerateGLError(context, context.NO_ERROR, "context.getTexParameter(contex
t.TEXTURE_2D, context.TEXTURE_MIN_FILTER)"); | |
88 | |
89 debug(""); | |
90 debug("check without bindings"); | |
91 context.bindBuffer(context.ARRAY_BUFFER, null); | |
92 context.bindTexture(context.TEXTURE_2D, null); | |
93 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.bufferData(co
ntext.ARRAY_BUFFER, 1, context.STATIC_DRAW)"); | |
94 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.getBufferPara
meter(context.ARRAY_BUFFER, context.BUFFER_SIZE)"); | |
95 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.texImage2D(co
ntext.TEXTURE_2D, 0, context.RGBA, 1, 1, 0, context.RGBA, context.UNSIGNED_BYTE,
new Uint8Array([0,0,0,0]))"); | |
96 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.texParameteri
(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST)"); | |
97 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.getTexParamet
er(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER)"); | |
98 | |
99 | |
100 successfullyParsed = true; | |
101 </script> | |
102 | |
103 <script src="../resources/js-test-post.js"></script> | |
104 </body> | |
105 </html> | |
OLD | NEW |