browser/devtools/tilt/test/browser_tilt_gl06.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/tilt/test/browser_tilt_gl06.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,57 @@
     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_gl06 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 +  let vb = new renderer.VertexBuffer([1, 2, 3, 4, 5, 6], 3);
    1.35 +
    1.36 +  ok(vb instanceof TiltGL.VertexBuffer,
    1.37 +    "The vertex buffer object wasn't instantiated correctly.");
    1.38 +  ok(vb._ref,
    1.39 +    "The vertex buffer gl element wasn't created at initialization.");
    1.40 +  ok(vb.components,
    1.41 +    "The vertex buffer components weren't created at initialization.");
    1.42 +  is(vb.itemSize, 3,
    1.43 +    "The vertex buffer item size isn't set correctly.");
    1.44 +  is(vb.numItems, 2,
    1.45 +    "The vertex buffer number of items weren't calculated correctly.");
    1.46 +
    1.47 +
    1.48 +  let ib = new renderer.IndexBuffer([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
    1.49 +
    1.50 +  ok(ib instanceof TiltGL.IndexBuffer,
    1.51 +    "The index buffer object wasn't instantiated correctly.");
    1.52 +  ok(ib._ref,
    1.53 +    "The index buffer gl element wasn't created at initialization.");
    1.54 +  ok(ib.components,
    1.55 +    "The index buffer components weren't created at initialization.");
    1.56 +  is(ib.itemSize, 1,
    1.57 +    "The index buffer item size isn't set correctly.");
    1.58 +  is(ib.numItems, 10,
    1.59 +    "The index buffer number of items weren't calculated correctly.");
    1.60 +}

mercurial