# {$basedir} is a default variable that can be used in any Ant script
# SRC_DIR =${basedir}/src
# points to the project's libs directory
-# LIBS_DIR =${basedir}/lib
+LIBS_DIR =${basedir}/lib
+
+test.application.name = HalcyonTestRunner
+
+test.src.dir = ${basedir}/tests/src
+test.fakeroot.dir = ${basedir}/tests/fakeroot
+test.bin.dir = ${basedir}/tests/bin
+report.dir = ${basedir}/tests/report
+report.html.dir = ${basedir}/tests/report/html
\ No newline at end of file
<!--<echo message="manifests = ${org_classes} ${it_classes} ${hxasm_classes}"/>-->
</target>
+ <!-- ======================================= -->
+ <!-- Unit Test Targets -->
+ <!-- ======================================= -->
+
+ <target name="compileTestRunner" depends="init" description="Compiles the test runner application.">
+
+ <!-- Compile TestRunner MXML as a SWF -->
+ <mxmlc file="${test.src.dir}/${test.application.name}.mxml"
+ output="${test.bin.dir}/${test.application.name}.swf">
+
+ <!--<load-config filename="${FLEX_HOME}/frameworks/air-config.xml" />-->
+
+ <!-- we need to supply source paths for the real source and the test source. But passing
+ the potlatch2 top-level directory causes a problem since that also contains the test source.
+ We could move every source folder (net, org, it and hxasm) into a src/ folder, or alternatively
+ set up a fake root folder in the test folder with symlinks to the four directories concerned.
+ It's a bodge, but it works. -->
+ <source-path path-element="${test.fakeroot.dir}" />
+ <source-path path-element="${test.src.dir}" />
+
+ <!-- The TestRunner needs the flexunit libraries in the build/libs folder -->
+ <library-path dir="${LIBS_DIR}" append="true">
+ <include name="*.swc" />
+ </library-path>
+
+
+ <!-- Sets java.awt.headless=true so font compilation works in headless environments -->
+ <compiler.headless-server>true</compiler.headless-server>
+ </mxmlc>
+
+ <echo message="The ${test.application.name}.swf test runner has been created in ${test.bin.dir}" />
+ </target>
+
+ <target name="runTestsAndReport" depends="init" description="Launches the test runner, captures results, generates test report artifacts.">
+
+ <mkdir dir="${report.dir}" />
+ <mkdir dir="${report.html.dir}" />
+
+ <!-- Run FlexUnit Ant Task to execute the unit tests and capture reporting data -->
+ <!-- on linux, make sure that gflashplayer is in your PATH and launches a standalone flashplayer binary -->
+ <taskdef resource="flexUnitTasks.tasks" classpath="${LIBS_DIR}/flexUnitTasks-4.0.0.jar" />
+ <flexunit swf="${test.bin.dir}/${test.application.name}.swf" toDir="${report.dir}"
+ haltonfailure="false" verbose="false" localTrusted="true" player="flash" />
+
+ <!-- Generate html JUnit-style reports based on test results -->
+ <junitreport todir="${report.dir}">
+ <fileset dir="${report.dir}">
+ <include name="TEST-*.xml" />
+ </fileset>
+ <report format="frames" todir="${report.html.dir}" />
+ </junitreport>
+
+ <echo message="The unit test reports have been created in ${report.dir}" />
+ </target>
+
+ <target name="test" depends="init, compileTestRunner, runTestsAndReport" description="Compiles unit tests and generates test report artifacts." />
+
</project>
--- /dev/null
+../../hxasm/
\ No newline at end of file
--- /dev/null
+../../it/
\ No newline at end of file
--- /dev/null
+../../net/
\ No newline at end of file
--- /dev/null
+../../org/
\ No newline at end of file
--- /dev/null
+package {
+
+ import net.systemeD.halcyon.connection.NodeTest;
+
+ [Suite]
+ [RunWith("org.flexunit.runners.Suite")]
+ public class AllHalcyonTests {
+
+ public var nodeTest:NodeTest;
+
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+
+<mx:Application
+ xmlns:mx="http://www.adobe.com/2006/mxml"
+ xmlns:flexUnitUIRunner="http://www.adobe.com/2009/flexUnitUIRunner"
+ minWidth="955" minHeight="600"
+ creationComplete="onCreationComplete();">
+
+ <mx:Script>
+ <![CDATA[
+
+ import org.flexunit.internals.TextListener;
+ import org.flexunit.internals.TraceListener;
+ import org.flexunit.listeners.CIListener;
+ import org.flexunit.listeners.UIListener;
+ import org.flexunit.runner.FlexUnitCore;
+ private var core:FlexUnitCore;
+
+ private function onCreationComplete():void
+ {
+ core = new FlexUnitCore();
+ // If you don't need graphical test results, comment out the line
+ // below and the MXML declaring the TestRunnerBase.
+ core.addListener( new UIListener( uiListener ) );
+ // Listener to support continuous integration servers
+ core.addListener( new CIListener() );
+ // If you would like to see text output in verbose mode,
+ // uncomment either of the follow listeners
+ //core.addListener( new TraceListener() ); // For AS3 Projects
+ //core.addListener( TextListener.getDefaultTextListener( LogEventLevel.DEBUG ) ); // For Flex Projects
+ core.run( AllHalcyonTests );
+ }
+ ]]>
+ </mx:Script>
+
+ <flexUnitUIRunner:TestRunnerBase id="uiListener" width="100%" height="100%" />
+
+</mx:Application>
--- /dev/null
+package net.systemeD.halcyon.connection {
+
+ import org.flexunit.Assert;
+ import net.systemeD.halcyon.connection.Node;
+ import net.systemeD.halcyon.connection.UndoableAction;
+
+ public class NodeTest {
+
+
+ [Test]
+ public function dummy():void {
+ Assert.assertEquals(10,10);
+ }
+
+ [Test]
+ public function newNode():void {
+ var n:Node = new Node(1,1,{},true,5,10);
+ Assert.assertEquals(n.lat, 5);
+ }
+
+ [Test]
+ public function moveNode():void {
+ var n:Node = new Node(1,1,{},true,5,10);
+ n.setLatLon(14,41, function(action:UndoableAction):void { action.doAction(); });
+ Assert.assertEquals(n.lat, 14);
+ Assert.assertEquals(n.lon, 41);
+ }
+
+ }
+}