X-Git-Url: https://git-public.kairo.at/?p=mandelbrot.git;a=blobdiff_plain;f=tests%2Fbrowser_mandelbrot_basics.js;fp=tests%2Fbrowser_mandelbrot_basics.js;h=76c2f3cf9fcf02a990e8b67e4b294f0fe67cedb0;hp=0000000000000000000000000000000000000000;hb=140e460f6396972ed0e386f79a64b09c7213dbba;hpb=3fd66836e6c5fbd25dd8f90dd50914cabeb7a9a7 diff --git a/tests/browser_mandelbrot_basics.js b/tests/browser_mandelbrot_basics.js new file mode 100644 index 0000000..76c2f3c --- /dev/null +++ b/tests/browser_mandelbrot_basics.js @@ -0,0 +1,72 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +// Test some basic functionality of KaiRo-Mandelbrot. + +Components.utils.import("resource://gre/modules/Services.jsm"); + +const MBROT_LOADED = "mandelbrot-loaded"; +const TEST_DONE = "mandelbrot-test-done"; + +function test() { + gBrowser.addTab(); + // Open KaiRo-Mandelbrot, testing the menu item. + let menuitem = document.getElementById("tasksMenuMandelbrot") || + document.getElementById("menu_openMandelbrot"); + menuitem.click(); + + var testIndex = 0; + var win; + + let testObs = { + observe: function(aSubject, aTopic, aData) { + if (aTopic == MBROT_LOADED) { + Services.obs.removeObserver(testObs, MBROT_LOADED); + ok(true, "KaiRo-Mandelbrot is loaded"); + + win = content.wrappedJSObject; + Services.obs.addObserver(testObs, TEST_DONE, false); + // Trigger the first test now! + Services.obs.notifyObservers(window, TEST_DONE, null); + } + else { + // TEST_DONE triggered, run next test + info("run test #" + (testIndex + 1) + " of " + testFuncs.length + + " (" + testFuncs[testIndex].name + ")"); + setTimeout(testFuncs[testIndex++], 0, win); + + if (testIndex >= testFuncs.length) { + // Finish this up! + Services.obs.removeObserver(testObs, TEST_DONE); + Services.cookies.removeAll(); + gLocSvc.fhist.removeAllEntries(); + setTimeout(finish, 0); + } + } + } + }; + waitForExplicitFinish(); + Services.obs.addObserver(testObs, MBROT_LOADED, false); +} + +var testFuncs = [ +function test_open_state(aWin) { + is(aWin.document.documentElement.id, "mandelbrot-page", + "The active tab is KaiRo-Mandelbrot"); + is(aWin.document.getElementById("drawButton").hidden, false, + "The draw button is not hidden"); + Services.obs.notifyObservers(window, TEST_DONE, null); +}, + +function test_close(aWin) { + function dmWindowClosedListener() { + aWin.removeEventListener("unload", dmWindowClosedListener, false); + isnot(content.document.documentElement.id, "mandelbrot-page", + "The active tab is not KaiRo-Mandelbrot"); + Services.obs.notifyObservers(window, TEST_DONE, null); + } + aWin.addEventListener("unload", dmWindowClosedListener, false); + aWin.close(); +} +];