browser/devtools/tilt/test/browser_tilt_picking_delete.js

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     3 "use strict";
     5 let nodeDeleted = false;
     6 let presenter;
     8 function test() {
     9   if (!isTiltEnabled()) {
    10     info("Skipping picking delete test because Tilt isn't enabled.");
    11     return;
    12   }
    13   if (!isWebGLSupported()) {
    14     info("Skipping picking delete test because WebGL isn't supported.");
    15     return;
    16   }
    18   waitForExplicitFinish();
    20   createTab(function() {
    21     createTilt({
    22       onTiltOpen: function(instance)
    23       {
    24         presenter = instance.presenter;
    25         Services.obs.addObserver(whenNodeRemoved, NODE_REMOVED, false);
    27         presenter._onSetupMesh = function() {
    28           let p = getPickablePoint(presenter);
    30           presenter.highlightNodeAt(p[0], p[1], {
    31             onpick: function()
    32             {
    33               ok(presenter._currentSelection > 0,
    34                 "Highlighting a node didn't work properly.");
    35               ok(!presenter._highlight.disabled,
    36                 "After highlighting a node, it should be highlighted. D'oh.");
    38               nodeDeleted = true;
    39               presenter.deleteNode();
    40             }
    41           });
    42         };
    43       }
    44     }, false, function suddenDeath()
    45     {
    46       info("Tilt could not be initialized properly.");
    47       cleanup();
    48     });
    49   });
    50 }
    52 function whenNodeRemoved() {
    53   ok(presenter._currentSelection > 0,
    54     "Deleting a node shouldn't change the current selection.");
    55   ok(presenter._highlight.disabled,
    56     "After deleting a node, it shouldn't be highlighted.");
    58   let nodeIndex = presenter._currentSelection;
    59   let vertices = presenter._meshStacks[0].vertices.components;
    61   for (let i = 0, k = 36 * nodeIndex; i < 36; i++) {
    62     is(vertices[i + k], 0,
    63       "The stack vertices weren't degenerated properly.");
    64   }
    66   executeSoon(function() {
    67     Services.obs.addObserver(cleanup, DESTROYED, false);
    68     Tilt.destroy(Tilt.currentWindowId);
    69   });
    70 }
    72 function cleanup() {
    73   if (nodeDeleted) { Services.obs.removeObserver(cleanup, DESTROYED); }
    74   gBrowser.removeCurrentTab();
    75   finish();
    76 }

mercurial