From e44a7e37b6c7b5961adaffc62b9042b8d442938e Mon Sep 17 00:00:00 2001 From: mensonge Date: Thu, 13 Nov 2008 09:49:11 +0000 Subject: New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f --- includes/js/dojox/flash/tests/TestFlash.as | 36 ++++++ includes/js/dojox/flash/tests/TestFlash.swf | Bin 0 -> 1863 bytes includes/js/dojox/flash/tests/buildFlashTest.sh | 4 + includes/js/dojox/flash/tests/test_flash.html | 15 +++ includes/js/dojox/flash/tests/test_flash.js | 155 ++++++++++++++++++++++++ 5 files changed, 210 insertions(+) create mode 100644 includes/js/dojox/flash/tests/TestFlash.as create mode 100644 includes/js/dojox/flash/tests/TestFlash.swf create mode 100644 includes/js/dojox/flash/tests/buildFlashTest.sh create mode 100644 includes/js/dojox/flash/tests/test_flash.html create mode 100644 includes/js/dojox/flash/tests/test_flash.js (limited to 'includes/js/dojox/flash/tests') diff --git a/includes/js/dojox/flash/tests/TestFlash.as b/includes/js/dojox/flash/tests/TestFlash.as new file mode 100644 index 0000000..d7be64f --- /dev/null +++ b/includes/js/dojox/flash/tests/TestFlash.as @@ -0,0 +1,36 @@ +import DojoExternalInterface; +import ExpressInstall; + +class TestFlash{ + private var message:String; + + public function TestFlash(){ + } + + public static function main(){ + //getURL("javascript:alert('main')"); + trace("main"); + DojoExternalInterface.initialize(); + + var test = new TestFlash(); + DojoExternalInterface.addCallback("setMessage", test, test.setMessage); + DojoExternalInterface.addCallback("getMessage", test, test.getMessage); + DojoExternalInterface.addCallback("multipleValues", + test, test.multipleValues); + + DojoExternalInterface.done(); + } + + public function setMessage(message:String):Void{ + this.message = message; + } + + public function getMessage():String{ + return this.message; + } + + public function multipleValues(key:String, value:String, + namespace:String):String{ + return namespace + key + value; + } +} \ No newline at end of file diff --git a/includes/js/dojox/flash/tests/TestFlash.swf b/includes/js/dojox/flash/tests/TestFlash.swf new file mode 100644 index 0000000..cfd3f8d Binary files /dev/null and b/includes/js/dojox/flash/tests/TestFlash.swf differ diff --git a/includes/js/dojox/flash/tests/buildFlashTest.sh b/includes/js/dojox/flash/tests/buildFlashTest.sh new file mode 100644 index 0000000..a73d20c --- /dev/null +++ b/includes/js/dojox/flash/tests/buildFlashTest.sh @@ -0,0 +1,4 @@ +#!/bin/sh +# TODO: FIXME: Get rid of this and hook it into Dojo's general build script +# You must have mtasc to run this +mtasc -trace DojoExternalInterface.trace -main -cp .. -swf TestFlash.swf -version 8 -header 215:138:10 TestFlash.as \ No newline at end of file diff --git a/includes/js/dojox/flash/tests/test_flash.html b/includes/js/dojox/flash/tests/test_flash.html new file mode 100644 index 0000000..5e09f45 --- /dev/null +++ b/includes/js/dojox/flash/tests/test_flash.html @@ -0,0 +1,15 @@ + +
+ + + + + + +For detailed test output see Firebug console (if Firefox). + This test should be run on Firefox, Internet Explorer, and Safari + to confirm that Dojox Flash is working correctly.
+ + \ No newline at end of file diff --git a/includes/js/dojox/flash/tests/test_flash.js b/includes/js/dojox/flash/tests/test_flash.js new file mode 100644 index 0000000..1b26eb2 --- /dev/null +++ b/includes/js/dojox/flash/tests/test_flash.js @@ -0,0 +1,155 @@ +// TODO: FIXME: Refactor this to use D.O.H. instead of its own assertions + +dojo.require("dojox.flash"); + +var flashLoaded = false; +var pageLoaded = false; +var testXML = testBook = null; + +function flashReady(){ + console.debug("flashReady"); + flashLoaded = true; + + if(isReady()){ + run(); + } +} + +function pageReady(){ + console.debug("pageReady"); + pageLoaded = true; + + loadResources(); + + if(isReady()){ + run(); + } +} + +function isReady(){ + return testXML && testBook && pageLoaded && flashLoaded; +} + +function loadResources(){ + console.debug("Trying to load resources"); + + var d = dojo.xhrGet({ + url: "../../storage/tests/resources/testXML.xml", + handleAs: "text" + }); + + d.addCallback(function(results){ + console.debug("testXML loaded"); + testXML = results; + if(isReady()){ + run(); + } + }); + + d.addErrback(function(error){ + console.debug("Unable to load testXML.xml: " + error); + }); + + d = dojo.xhrGet({ + url: "../../storage/tests/resources/testBook.txt", + handleAs: "text" + }); + + d.addCallback(function(results){ + console.debug("testBook loaded"); + testBook = results; + if(isReady()){ + run(); + } + }); + + d.addErrback(function(error){ + console.debug("Unable to load testXML.xml: " + error); + }); +} + +function run(){ + console.debug("run"); + try{ + var correct, actual; + + console.debug("Setting simple message..."); + correct = "hello world"; + dojox.flash.comm.setMessage(correct); + actual = dojox.flash.comm.getMessage(); + assert(correct, actual, "Setting/getting simple message did not work"); + + console.debug("Setting message with evil characters..."); + // our correct and actual values get tricky when we have double back + // slashes; do a trick so that they can be compared easier + var doubleSlash = "\\"; + doubleSlash = doubleSlash.charAt(0); + correct = "hello world\n\n\nasdfasdf!@#$@#%^[]{}&