1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/tilt/test/browser_tilt_gl03.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 +"use strict"; 1.7 + 1.8 +let isWebGLAvailable; 1.9 + 1.10 +function onWebGLFail() { 1.11 + isWebGLAvailable = false; 1.12 +} 1.13 + 1.14 +function onWebGLSuccess() { 1.15 + isWebGLAvailable = true; 1.16 +} 1.17 + 1.18 +function test() { 1.19 + if (!isWebGLSupported()) { 1.20 + info("Skipping tilt_gl03 because WebGL isn't supported on this hardware."); 1.21 + return; 1.22 + } 1.23 + 1.24 + let canvas = createCanvas(); 1.25 + 1.26 + let renderer = new TiltGL.Renderer(canvas, onWebGLFail, onWebGLSuccess); 1.27 + let gl = renderer.context; 1.28 + 1.29 + if (!isWebGLAvailable) { 1.30 + return; 1.31 + } 1.32 + 1.33 + 1.34 + renderer.defaults(); 1.35 + is(gl.getParameter(gl.DEPTH_TEST), true, 1.36 + "The depth test wasn't set to the correct default value."); 1.37 + is(gl.getParameter(gl.STENCIL_TEST), false, 1.38 + "The stencil test wasn't set to the correct default value."); 1.39 + is(gl.getParameter(gl.CULL_FACE), false, 1.40 + "The cull face wasn't set to the correct default value."); 1.41 + is(gl.getParameter(gl.FRONT_FACE), gl.CCW, 1.42 + "The front face wasn't set to the correct default value."); 1.43 + is(gl.getParameter(gl.BLEND), true, 1.44 + "The blend mode wasn't set to the correct default value."); 1.45 + is(gl.getParameter(gl.BLEND_SRC_ALPHA), gl.SRC_ALPHA, 1.46 + "The soruce blend func wasn't set to the correct default value."); 1.47 + is(gl.getParameter(gl.BLEND_DST_ALPHA), gl.ONE_MINUS_SRC_ALPHA, 1.48 + "The destination blend func wasn't set to the correct default value."); 1.49 + 1.50 + 1.51 + ok(isApproxVec(renderer._fillColor, [1, 1, 1, 1]), 1.52 + "The fill color wasn't set to the correct default value."); 1.53 + ok(isApproxVec(renderer._strokeColor, [0, 0, 0, 1]), 1.54 + "The stroke color wasn't set to the correct default value."); 1.55 + is(renderer._strokeWeightValue, 1, 1.56 + "The stroke weight wasn't set to the correct default value."); 1.57 + is(gl.getParameter(gl.LINE_WIDTH), 1, 1.58 + "The stroke weight wasn't applied with the correct default value."); 1.59 + 1.60 + 1.61 + ok(isApproxVec(renderer.projMatrix, [ 1.62 + 1.2071068286895752, 0, 0, 0, 0, -2.4142136573791504, 0, 0, 0, 0, 1.63 + -1.0202020406723022, -1, -181.06602478027344, 181.06602478027344, 1.64 + 148.14492797851562, 181.06602478027344 1.65 + ]), "The default perspective projection matrix wasn't set correctly."); 1.66 + 1.67 + ok(isApproxVec(renderer.mvMatrix, [ 1.68 + 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 1.69 + ]), "The default model view matrix wasn't set correctly."); 1.70 +}