content/canvas/test/webgl-conformance/conformance/programs/get-active-test.html

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 <!--
michael@0 2 Copyright (C) 2011 Apple Computer, Inc. All rights reserved.
michael@0 3
michael@0 4 Redistribution and use in source and binary forms, with or without
michael@0 5 modification, are permitted provided that the following conditions
michael@0 6 are met:
michael@0 7 1. Redistributions of source code must retain the above copyright
michael@0 8 notice, this list of conditions and the following disclaimer.
michael@0 9 2. Redistributions in binary form must reproduce the above copyright
michael@0 10 notice, this list of conditions and the following disclaimer in the
michael@0 11 documentation and/or other materials provided with the distribution.
michael@0 12
michael@0 13 THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
michael@0 14 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
michael@0 15 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
michael@0 16 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
michael@0 17 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
michael@0 18 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
michael@0 19 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
michael@0 20 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
michael@0 21 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
michael@0 22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 23 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 24 -->
michael@0 25 <!DOCTYPE html>
michael@0 26 <html>
michael@0 27 <head>
michael@0 28 <meta charset="utf-8">
michael@0 29 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
michael@0 30 <script src="../../resources/js-test-pre.js"></script>
michael@0 31 <script src="../resources/webgl-test.js"></script>
michael@0 32 </head>
michael@0 33 <body>
michael@0 34 <div id="description"></div>
michael@0 35 <div id="console"></div>
michael@0 36
michael@0 37 <script>
michael@0 38 description("Test of getActiveAttrib and getActiveUniform");
michael@0 39
michael@0 40 var context = create3DContext();
michael@0 41 var context2 = create3DContext();
michael@0 42 var program = loadStandardProgram(context);
michael@0 43 var program2 = loadProgram(context2,
michael@0 44 "../resources/intArrayUniformShader.vert",
michael@0 45 "../resources/noopUniformShader.frag");
michael@0 46
michael@0 47 glErrorShouldBe(context, context.NO_ERROR);
michael@0 48 shouldBe("context.getActiveUniform(program, 0).name", "'u_modelViewProjMatrix'");
michael@0 49 shouldBe("context.getActiveUniform(program, 0).type", "context.FLOAT_MAT4");
michael@0 50 shouldBe("context.getActiveUniform(program, 0).size", "1");
michael@0 51 shouldBeNull("context.getActiveUniform(program, 1)");
michael@0 52 glErrorShouldBe(context, context.INVALID_VALUE);
michael@0 53 shouldBeNull("context.getActiveUniform(program, -1)");
michael@0 54 glErrorShouldBe(context, context.INVALID_VALUE);
michael@0 55 shouldBeNull("context.getActiveUniform(null, 0)");
michael@0 56 glErrorShouldBe(context, context.INVALID_VALUE);
michael@0 57
michael@0 58 // we don't know the order the attribs will appear.
michael@0 59 var info = [
michael@0 60 context.getActiveAttrib(program, 0),
michael@0 61 context.getActiveAttrib(program, 1)
michael@0 62 ];
michael@0 63 for (var ii = 0; ii < info.length; ++ii)
michael@0 64 shouldBeNonNull("info[ii]");
michael@0 65
michael@0 66 var expected = [
michael@0 67 { name: 'a_normal', type: context.FLOAT_VEC3, size: 1 },
michael@0 68 { name: 'a_vertex', type: context.FLOAT_VEC4, size: 1 }
michael@0 69 ];
michael@0 70
michael@0 71 if (info[0].name != expected[0].name) {
michael@0 72 t = info[0];
michael@0 73 info[0] = info[1];
michael@0 74 info[1] = t;
michael@0 75 }
michael@0 76
michael@0 77 for (var ii = 0; ii < info.length; ++ii) {
michael@0 78 shouldBe("info[ii].name", "expected[ii].name");
michael@0 79 shouldBe("info[ii].type", "expected[ii].type");
michael@0 80 shouldBe("info[ii].size", "expected[ii].size");
michael@0 81 }
michael@0 82
michael@0 83 // we don't know the order the uniforms will appear.
michael@0 84 var info2 = [
michael@0 85 context2.getActiveUniform(program2, 0),
michael@0 86 context2.getActiveUniform(program2, 1)
michael@0 87 ];
michael@0 88 for (var ii = 0; ii < info2.length; ++ii)
michael@0 89 shouldBeNonNull("info2[ii]");
michael@0 90
michael@0 91 var expected2 = [
michael@0 92 { name: 'ival', type: context2.INT, size: 1 },
michael@0 93 { name: 'ival2[0]', type: context2.INT, size: 2 }
michael@0 94 ];
michael@0 95
michael@0 96 if (info2[0].name != expected2[0].name) {
michael@0 97 t = info2[0];
michael@0 98 info2[0] = info2[1];
michael@0 99 info2[1] = t;
michael@0 100 }
michael@0 101
michael@0 102 for (var ii = 0; ii < info2.length; ++ii) {
michael@0 103 shouldBe("info2[ii].name", "expected2[ii].name");
michael@0 104 shouldBe("info2[ii].type", "expected2[ii].type");
michael@0 105 shouldBe("info2[ii].size", "expected2[ii].size");
michael@0 106 }
michael@0 107
michael@0 108 shouldBeNull("context.getActiveAttrib(program, 2)");
michael@0 109 glErrorShouldBe(context, context.INVALID_VALUE);
michael@0 110 shouldBeNull("context.getActiveAttrib(program, -1)");
michael@0 111 glErrorShouldBe(context, context.INVALID_VALUE);
michael@0 112 shouldBeNull("context.getActiveAttrib(null, 0)");
michael@0 113 glErrorShouldBe(context, context.INVALID_VALUE);
michael@0 114
michael@0 115 glErrorShouldBe(context2, context.NO_ERROR);
michael@0 116
michael@0 117 debug("Check trying to get attribs from different context");
michael@0 118 shouldBeNull("context2.getActiveAttrib(program, 0)");
michael@0 119 glErrorShouldBe(context2, context2.INVALID_OPERATION);
michael@0 120 shouldBeNull("context2.getActiveUniform(program, 0)");
michael@0 121 glErrorShouldBe(context2, context2.INVALID_OPERATION);
michael@0 122
michael@0 123 debug("Check trying to get attribs from deleted program");
michael@0 124 context.deleteProgram(program);
michael@0 125 shouldBeNull("context.getActiveUniform(program, 0)");
michael@0 126 glErrorShouldBe(context, context.INVALID_VALUE);
michael@0 127 shouldBeNull("context.getActiveAttrib(program, 0)");
michael@0 128 glErrorShouldBe(context, context.INVALID_VALUE);
michael@0 129
michael@0 130 successfullyParsed = true;
michael@0 131 </script>
michael@0 132
michael@0 133 <script>finishTest();</script>
michael@0 134 </body>
michael@0 135 </html>

mercurial