OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <!-- |
| 5 |
| 6 /* |
| 7 ** Copyright (c) 2012 The Khronos Group Inc. |
| 8 ** |
| 9 ** Permission is hereby granted, free of charge, to any person obtaining a |
| 10 ** copy of this software and/or associated documentation files (the |
| 11 ** "Materials"), to deal in the Materials without restriction, including |
| 12 ** without limitation the rights to use, copy, modify, merge, publish, |
| 13 ** distribute, sublicense, and/or sell copies of the Materials, and to |
| 14 ** permit persons to whom the Materials are furnished to do so, subject to |
| 15 ** the following conditions: |
| 16 ** |
| 17 ** The above copyright notice and this permission notice shall be included |
| 18 ** in all copies or substantial portions of the Materials. |
| 19 ** |
| 20 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 21 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 22 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 23 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 24 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 25 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 26 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
| 27 */ |
| 28 |
| 29 --> |
| 30 <meta charset="utf-8"> |
| 31 <link rel="stylesheet" type="text/css" href="../unit.css" /> |
| 32 <script type="application/x-javascript" src="../unit.js"></script> |
| 33 <script type="application/x-javascript" src="../util.js"></script> |
| 34 <script type="application/x-javascript"> |
| 35 |
| 36 Tests.startUnit = function () { |
| 37 var canvas = document.getElementById('gl'); |
| 38 var gl = wrapGLContext(getGLContext(canvas)); |
| 39 var tex = gl.createTexture(); |
| 40 gl.bindTexture(gl.TEXTURE_2D, tex); |
| 41 return [gl, tex]; |
| 42 } |
| 43 |
| 44 Tests.testTexImage2D = function(gl) { |
| 45 var b = document.createElement('b'); |
| 46 var div = document.createElement('div'); |
| 47 var c = document.getElementById('c'); |
| 48 assertFail("bad element b", |
| 49 function() {gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNE
D_BYTE, b); }); |
| 50 assertFail("bad element div", |
| 51 function() {gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNE
D_BYTE, div); }); |
| 52 assertFail("no element", |
| 53 function() {gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNE
D_BYTE, 0); }); |
| 54 assertFail("string as data", |
| 55 function() {gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNE
D_BYTE, "foo"); }); |
| 56 assertOk("canvas as data", |
| 57 function() {gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGN
ED_BYTE, c); }); |
| 58 assertFail("bad target", |
| 59 function() {gl.texImage2D(gl.FLOAT, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYT
E, c); }); |
| 60 } |
| 61 |
| 62 Tests.endUnit = function(gl, tex) { |
| 63 gl.bindTexture(gl.TEXTURE_2D, null); |
| 64 gl.deleteTexture(tex); |
| 65 } |
| 66 |
| 67 </script> |
| 68 <style>canvas{ position:absolute; }</style> |
| 69 </head><body> |
| 70 <canvas id="gl" width="16" height="16"></canvas> |
| 71 <canvas id="c" width="16" height="16"></canvas> |
| 72 </body></html> |
OLD | NEW |