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