diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2014-05-21 11:38:25 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2014-05-21 11:38:25 +0200 |
commit | d25ba7d760b017b038e5aa6c0a605b4a330eb68d (patch) | |
tree | 16ec27edc7d5f83986f16236d3a36a2682a0f37e /browser/devtools/tilt/test/browser_tilt_picking_delete.js | |
parent | a942906574671868daf122284a9c4689e6924f74 (diff) | |
download | palemoon-gre-d25ba7d760b017b038e5aa6c0a605b4a330eb68d.tar.gz |
Recommit working copy to repo with proper line endings.
Diffstat (limited to 'browser/devtools/tilt/test/browser_tilt_picking_delete.js')
-rw-r--r-- | browser/devtools/tilt/test/browser_tilt_picking_delete.js | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/browser/devtools/tilt/test/browser_tilt_picking_delete.js b/browser/devtools/tilt/test/browser_tilt_picking_delete.js new file mode 100644 index 000000000..c45d44b03 --- /dev/null +++ b/browser/devtools/tilt/test/browser_tilt_picking_delete.js @@ -0,0 +1,76 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + +let nodeDeleted = false; +let presenter; + +function test() { + if (!isTiltEnabled()) { + info("Skipping picking delete test because Tilt isn't enabled."); + return; + } + if (!isWebGLSupported()) { + info("Skipping picking delete test because WebGL isn't supported."); + return; + } + + waitForExplicitFinish(); + + createTab(function() { + createTilt({ + onTiltOpen: function(instance) + { + presenter = instance.presenter; + Services.obs.addObserver(whenNodeRemoved, NODE_REMOVED, false); + + presenter._onSetupMesh = function() { + let p = getPickablePoint(presenter); + + presenter.highlightNodeAt(p[0], p[1], { + onpick: function() + { + ok(presenter._currentSelection > 0, + "Highlighting a node didn't work properly."); + ok(!presenter._highlight.disabled, + "After highlighting a node, it should be highlighted. D'oh."); + + nodeDeleted = true; + presenter.deleteNode(); + } + }); + }; + } + }, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); + }); + }); +} + +function whenNodeRemoved() { + ok(presenter._currentSelection > 0, + "Deleting a node shouldn't change the current selection."); + ok(presenter._highlight.disabled, + "After deleting a node, it shouldn't be highlighted."); + + let nodeIndex = presenter._currentSelection; + let vertices = presenter._meshStacks[0].vertices.components; + + for (let i = 0, k = 36 * nodeIndex; i < 36; i++) { + is(vertices[i + k], 0, + "The stack vertices weren't degenerated properly."); + } + + executeSoon(function() { + Services.obs.addObserver(cleanup, DESTROYED, false); + Tilt.destroy(Tilt.currentWindowId); + }); +} + +function cleanup() { + if (nodeDeleted) { Services.obs.removeObserver(cleanup, DESTROYED); } + gBrowser.removeCurrentTab(); + finish(); +} |