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