browser/devtools/tilt/test/browser_tilt_visualizer.js

Wed, 31 Dec 2014 07:53:36 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:53:36 +0100
branch
TOR_BUG_3246
changeset 5
4ab42b5ab56c
permissions
-rw-r--r--

Correct small whitespace inconsistency, lost while renaming variables.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     3 "use strict";
     5 function test() {
     6   if (!isTiltEnabled()) {
     7     info("Skipping notifications test because Tilt isn't enabled.");
     8     return;
     9   }
    10   if (!isWebGLSupported()) {
    11     info("Skipping visualizer test because WebGL isn't supported.");
    12     return;
    13   }
    15   let webGLError = false;
    16   let webGLLoad = false;
    18   let visualizer = new TiltVisualizer({
    19     chromeWindow: window,
    20     contentWindow: gBrowser.selectedBrowser.contentWindow,
    21     parentNode: gBrowser.selectedBrowser.parentNode,
    22     notifications: Tilt.NOTIFICATIONS,
    23     tab: gBrowser.selectedTab,
    25     onError: function onWebGLError()
    26     {
    27       webGLError = true;
    28     },
    30     onLoad: function onWebGLLoad()
    31     {
    32       webGLLoad = true;
    33     }
    34   });
    35   visualizer.init();
    37   ok(webGLError ^ webGLLoad,
    38     "The WebGL context should either be created or not.");
    40   if (webGLError) {
    41     info("Skipping visualizer test because WebGL couldn't be initialized.");
    42     return;
    43   }
    45   ok(visualizer.canvas,
    46     "Visualizer constructor should have created a child canvas object.");
    47   ok(visualizer.presenter,
    48     "Visualizer constructor should have created a child presenter object.");
    49   ok(visualizer.controller,
    50     "Visualizer constructor should have created a child controller object.");
    51   ok(visualizer.isInitialized(),
    52     "The visualizer should have been initialized properly.");
    53   ok(visualizer.presenter.isInitialized(),
    54     "The visualizer presenter should have been initialized properly.");
    55   ok(visualizer.controller.isInitialized(),
    56     "The visualizer controller should have been initialized properly.");
    58   testPresenter(visualizer.presenter);
    59   testController(visualizer.controller);
    61   visualizer.removeOverlay();
    62   is(visualizer.canvas.parentNode, null,
    63     "The visualizer canvas wasn't removed from the parent node.");
    65   visualizer.cleanup();
    66   is(visualizer.presenter, undefined,
    67     "The visualizer presenter wasn't destroyed.");
    68   is(visualizer.controller, undefined,
    69     "The visualizer controller wasn't destroyed.");
    70   is(visualizer.canvas, undefined,
    71     "The visualizer canvas wasn't destroyed.");
    72 }
    74 function testPresenter(presenter) {
    75   ok(presenter._renderer,
    76     "The presenter renderer wasn't initialized properly.");
    77   ok(presenter._visualizationProgram,
    78     "The presenter visualizationProgram wasn't initialized properly.");
    79   ok(presenter._texture,
    80     "The presenter texture wasn't initialized properly.");
    81   ok(!presenter._meshStacks,
    82     "The presenter meshStacks shouldn't be initialized yet.");
    83   ok(!presenter._meshWireframe,
    84     "The presenter meshWireframe shouldn't be initialized yet.");
    85   ok(presenter._traverseData,
    86     "The presenter nodesInformation wasn't initialized properly.");
    87   ok(presenter._highlight,
    88     "The presenter highlight wasn't initialized properly.");
    89   ok(presenter._highlight.disabled,
    90     "The presenter highlight should be initially disabled.");
    91   ok(isApproxVec(presenter._highlight.v0, [0, 0, 0]),
    92     "The presenter highlight first vertex should be initially zeroed.");
    93   ok(isApproxVec(presenter._highlight.v1, [0, 0, 0]),
    94     "The presenter highlight second vertex should be initially zeroed.");
    95   ok(isApproxVec(presenter._highlight.v2, [0, 0, 0]),
    96     "The presenter highlight third vertex should be initially zeroed.");
    97   ok(isApproxVec(presenter._highlight.v3, [0, 0, 0]),
    98     "The presenter highlight fourth vertex should be initially zeroed.");
    99   ok(presenter.transforms,
   100     "The presenter transforms wasn't initialized properly.");
   101   is(presenter.transforms.zoom, 1,
   102     "The presenter transforms zoom should be initially 1.");
   103   ok(isApproxVec(presenter.transforms.offset, [0, 0, 0]),
   104     "The presenter transforms offset should be initially zeroed.");
   105   ok(isApproxVec(presenter.transforms.translation, [0, 0, 0]),
   106     "The presenter transforms translation should be initially zeroed.");
   107   ok(isApproxVec(presenter.transforms.rotation, [0, 0, 0, 1]),
   108     "The presenter transforms rotation should be initially set to identity.");
   110   presenter.setTranslation([1, 2, 3]);
   111   presenter.setRotation([5, 6, 7, 8]);
   113   ok(isApproxVec(presenter.transforms.translation, [1, 2, 3]),
   114     "The presenter transforms translation wasn't modified as it should");
   115   ok(isApproxVec(presenter.transforms.rotation, [5, 6, 7, 8]),
   116     "The presenter transforms rotation wasn't modified as it should");
   117   ok(presenter._redraw,
   118     "The new transforms should have issued a redraw request.");
   119 }
   121 function testController(controller) {
   122   ok(controller.arcball,
   123     "The controller arcball wasn't initialized properly.");
   124   ok(!controller.coordinates,
   125     "The presenter meshWireframe shouldn't be initialized yet.");
   126 }

mercurial