browser/devtools/tilt/test/browser_tilt_gl03.js

Wed, 31 Dec 2014 06:55:46 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:46 +0100
changeset 1
ca08bd8f51b2
permissions
-rw-r--r--

Added tag TORBROWSER_REPLICA for changeset 6474c204b198

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3 "use strict";
michael@0 4
michael@0 5 let isWebGLAvailable;
michael@0 6
michael@0 7 function onWebGLFail() {
michael@0 8 isWebGLAvailable = false;
michael@0 9 }
michael@0 10
michael@0 11 function onWebGLSuccess() {
michael@0 12 isWebGLAvailable = true;
michael@0 13 }
michael@0 14
michael@0 15 function test() {
michael@0 16 if (!isWebGLSupported()) {
michael@0 17 info("Skipping tilt_gl03 because WebGL isn't supported on this hardware.");
michael@0 18 return;
michael@0 19 }
michael@0 20
michael@0 21 let canvas = createCanvas();
michael@0 22
michael@0 23 let renderer = new TiltGL.Renderer(canvas, onWebGLFail, onWebGLSuccess);
michael@0 24 let gl = renderer.context;
michael@0 25
michael@0 26 if (!isWebGLAvailable) {
michael@0 27 return;
michael@0 28 }
michael@0 29
michael@0 30
michael@0 31 renderer.defaults();
michael@0 32 is(gl.getParameter(gl.DEPTH_TEST), true,
michael@0 33 "The depth test wasn't set to the correct default value.");
michael@0 34 is(gl.getParameter(gl.STENCIL_TEST), false,
michael@0 35 "The stencil test wasn't set to the correct default value.");
michael@0 36 is(gl.getParameter(gl.CULL_FACE), false,
michael@0 37 "The cull face wasn't set to the correct default value.");
michael@0 38 is(gl.getParameter(gl.FRONT_FACE), gl.CCW,
michael@0 39 "The front face wasn't set to the correct default value.");
michael@0 40 is(gl.getParameter(gl.BLEND), true,
michael@0 41 "The blend mode wasn't set to the correct default value.");
michael@0 42 is(gl.getParameter(gl.BLEND_SRC_ALPHA), gl.SRC_ALPHA,
michael@0 43 "The soruce blend func wasn't set to the correct default value.");
michael@0 44 is(gl.getParameter(gl.BLEND_DST_ALPHA), gl.ONE_MINUS_SRC_ALPHA,
michael@0 45 "The destination blend func wasn't set to the correct default value.");
michael@0 46
michael@0 47
michael@0 48 ok(isApproxVec(renderer._fillColor, [1, 1, 1, 1]),
michael@0 49 "The fill color wasn't set to the correct default value.");
michael@0 50 ok(isApproxVec(renderer._strokeColor, [0, 0, 0, 1]),
michael@0 51 "The stroke color wasn't set to the correct default value.");
michael@0 52 is(renderer._strokeWeightValue, 1,
michael@0 53 "The stroke weight wasn't set to the correct default value.");
michael@0 54 is(gl.getParameter(gl.LINE_WIDTH), 1,
michael@0 55 "The stroke weight wasn't applied with the correct default value.");
michael@0 56
michael@0 57
michael@0 58 ok(isApproxVec(renderer.projMatrix, [
michael@0 59 1.2071068286895752, 0, 0, 0, 0, -2.4142136573791504, 0, 0, 0, 0,
michael@0 60 -1.0202020406723022, -1, -181.06602478027344, 181.06602478027344,
michael@0 61 148.14492797851562, 181.06602478027344
michael@0 62 ]), "The default perspective projection matrix wasn't set correctly.");
michael@0 63
michael@0 64 ok(isApproxVec(renderer.mvMatrix, [
michael@0 65 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
michael@0 66 ]), "The default model view matrix wasn't set correctly.");
michael@0 67 }

mercurial