1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/webgl-conformance/conformance/programs/get-active-test.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,135 @@ 1.4 +<!-- 1.5 +Copyright (C) 2011 Apple Computer, Inc. All rights reserved. 1.6 + 1.7 +Redistribution and use in source and binary forms, with or without 1.8 +modification, are permitted provided that the following conditions 1.9 +are met: 1.10 +1. Redistributions of source code must retain the above copyright 1.11 + notice, this list of conditions and the following disclaimer. 1.12 +2. Redistributions in binary form must reproduce the above copyright 1.13 + notice, this list of conditions and the following disclaimer in the 1.14 + documentation and/or other materials provided with the distribution. 1.15 + 1.16 +THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 1.17 +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1.18 +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 1.19 +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 1.20 +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 1.21 +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 1.22 +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 1.23 +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 1.24 +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.25 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.26 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.27 +--> 1.28 +<!DOCTYPE html> 1.29 +<html> 1.30 +<head> 1.31 +<meta charset="utf-8"> 1.32 +<link rel="stylesheet" href="../../resources/js-test-style.css"/> 1.33 +<script src="../../resources/js-test-pre.js"></script> 1.34 +<script src="../resources/webgl-test.js"></script> 1.35 +</head> 1.36 +<body> 1.37 +<div id="description"></div> 1.38 +<div id="console"></div> 1.39 + 1.40 +<script> 1.41 +description("Test of getActiveAttrib and getActiveUniform"); 1.42 + 1.43 +var context = create3DContext(); 1.44 +var context2 = create3DContext(); 1.45 +var program = loadStandardProgram(context); 1.46 +var program2 = loadProgram(context2, 1.47 + "../resources/intArrayUniformShader.vert", 1.48 + "../resources/noopUniformShader.frag"); 1.49 + 1.50 +glErrorShouldBe(context, context.NO_ERROR); 1.51 +shouldBe("context.getActiveUniform(program, 0).name", "'u_modelViewProjMatrix'"); 1.52 +shouldBe("context.getActiveUniform(program, 0).type", "context.FLOAT_MAT4"); 1.53 +shouldBe("context.getActiveUniform(program, 0).size", "1"); 1.54 +shouldBeNull("context.getActiveUniform(program, 1)"); 1.55 +glErrorShouldBe(context, context.INVALID_VALUE); 1.56 +shouldBeNull("context.getActiveUniform(program, -1)"); 1.57 +glErrorShouldBe(context, context.INVALID_VALUE); 1.58 +shouldBeNull("context.getActiveUniform(null, 0)"); 1.59 +glErrorShouldBe(context, context.INVALID_VALUE); 1.60 + 1.61 +// we don't know the order the attribs will appear. 1.62 +var info = [ 1.63 + context.getActiveAttrib(program, 0), 1.64 + context.getActiveAttrib(program, 1) 1.65 +]; 1.66 +for (var ii = 0; ii < info.length; ++ii) 1.67 + shouldBeNonNull("info[ii]"); 1.68 + 1.69 +var expected = [ 1.70 + { name: 'a_normal', type: context.FLOAT_VEC3, size: 1 }, 1.71 + { name: 'a_vertex', type: context.FLOAT_VEC4, size: 1 } 1.72 +]; 1.73 + 1.74 +if (info[0].name != expected[0].name) { 1.75 + t = info[0]; 1.76 + info[0] = info[1]; 1.77 + info[1] = t; 1.78 +} 1.79 + 1.80 +for (var ii = 0; ii < info.length; ++ii) { 1.81 + shouldBe("info[ii].name", "expected[ii].name"); 1.82 + shouldBe("info[ii].type", "expected[ii].type"); 1.83 + shouldBe("info[ii].size", "expected[ii].size"); 1.84 +} 1.85 + 1.86 +// we don't know the order the uniforms will appear. 1.87 +var info2 = [ 1.88 + context2.getActiveUniform(program2, 0), 1.89 + context2.getActiveUniform(program2, 1) 1.90 +]; 1.91 +for (var ii = 0; ii < info2.length; ++ii) 1.92 + shouldBeNonNull("info2[ii]"); 1.93 + 1.94 +var expected2 = [ 1.95 + { name: 'ival', type: context2.INT, size: 1 }, 1.96 + { name: 'ival2[0]', type: context2.INT, size: 2 } 1.97 +]; 1.98 + 1.99 +if (info2[0].name != expected2[0].name) { 1.100 + t = info2[0]; 1.101 + info2[0] = info2[1]; 1.102 + info2[1] = t; 1.103 +} 1.104 + 1.105 +for (var ii = 0; ii < info2.length; ++ii) { 1.106 + shouldBe("info2[ii].name", "expected2[ii].name"); 1.107 + shouldBe("info2[ii].type", "expected2[ii].type"); 1.108 + shouldBe("info2[ii].size", "expected2[ii].size"); 1.109 +} 1.110 + 1.111 +shouldBeNull("context.getActiveAttrib(program, 2)"); 1.112 +glErrorShouldBe(context, context.INVALID_VALUE); 1.113 +shouldBeNull("context.getActiveAttrib(program, -1)"); 1.114 +glErrorShouldBe(context, context.INVALID_VALUE); 1.115 +shouldBeNull("context.getActiveAttrib(null, 0)"); 1.116 +glErrorShouldBe(context, context.INVALID_VALUE); 1.117 + 1.118 +glErrorShouldBe(context2, context.NO_ERROR); 1.119 + 1.120 +debug("Check trying to get attribs from different context"); 1.121 +shouldBeNull("context2.getActiveAttrib(program, 0)"); 1.122 +glErrorShouldBe(context2, context2.INVALID_OPERATION); 1.123 +shouldBeNull("context2.getActiveUniform(program, 0)"); 1.124 +glErrorShouldBe(context2, context2.INVALID_OPERATION); 1.125 + 1.126 +debug("Check trying to get attribs from deleted program"); 1.127 +context.deleteProgram(program); 1.128 +shouldBeNull("context.getActiveUniform(program, 0)"); 1.129 +glErrorShouldBe(context, context.INVALID_VALUE); 1.130 +shouldBeNull("context.getActiveAttrib(program, 0)"); 1.131 +glErrorShouldBe(context, context.INVALID_VALUE); 1.132 + 1.133 +successfullyParsed = true; 1.134 +</script> 1.135 + 1.136 +<script>finishTest();</script> 1.137 +</body> 1.138 +</html>