|
From: <luk...@us...> - 2006-03-08 17:28:23
|
Revision: 32 Author: lukebayes Date: 2006-03-08 09:28:15 -0800 (Wed, 08 Mar 2006) ViewCVS: http://svn.sourceforge.net/asunit/?rev=32&view=rev Log Message: ----------- Removed concrete TestSuites from repository as they were causing conflicts in concrete projects Removed Paths: ------------- trunk/framework/as3/AllTests.as trunk/framework/as3/asunit/AllTests.as trunk/framework/as3/asunit/errors/AllTests.as trunk/framework/as3/asunit/framework/AllTests.as trunk/framework/as3/asunit/runner/AllTests.as trunk/framework/as3/asunit/textui/AllTests.as Deleted: trunk/framework/as3/AllTests.as =================================================================== --- trunk/framework/as3/AllTests.as 2006-03-08 17:26:10 UTC (rev 31) +++ trunk/framework/as3/AllTests.as 2006-03-08 17:28:15 UTC (rev 32) @@ -1,10 +0,0 @@ -package { - import asunit.framework.TestSuite; - - public class AllTests extends TestSuite { - - public function AllTests() { - addTest(new asunit.AllTests()); - } - } -} \ No newline at end of file Deleted: trunk/framework/as3/asunit/AllTests.as =================================================================== --- trunk/framework/as3/asunit/AllTests.as 2006-03-08 17:26:10 UTC (rev 31) +++ trunk/framework/as3/asunit/AllTests.as 2006-03-08 17:28:15 UTC (rev 32) @@ -1,15 +0,0 @@ -package asunit { - import asunit.framework.TestSuite; - import asunit.runner.AllTests; - import asunit.textui.AllTests; - - public class AllTests extends TestSuite { - - public function AllTests() { - addTest(new asunit.errors.AllTests()); - addTest(new asunit.framework.AllTests()); - addTest(new asunit.runner.AllTests()); - addTest(new asunit.textui.AllTests()); - } - } -} \ No newline at end of file Deleted: trunk/framework/as3/asunit/errors/AllTests.as =================================================================== --- trunk/framework/as3/asunit/errors/AllTests.as 2006-03-08 17:26:10 UTC (rev 31) +++ trunk/framework/as3/asunit/errors/AllTests.as 2006-03-08 17:28:15 UTC (rev 32) @@ -1,9 +0,0 @@ -package asunit.errors { - import asunit.framework.TestSuite; - - public class AllTests extends TestSuite { - - public function AllTests() { - } - } -} \ No newline at end of file Deleted: trunk/framework/as3/asunit/framework/AllTests.as =================================================================== --- trunk/framework/as3/asunit/framework/AllTests.as 2006-03-08 17:26:10 UTC (rev 31) +++ trunk/framework/as3/asunit/framework/AllTests.as 2006-03-08 17:28:15 UTC (rev 32) @@ -1,13 +0,0 @@ -package asunit.framework { - - public class AllTests extends TestSuite { - - public function AllTests() { - addTest(new AssertTest()); - addTest(new TestCaseTest()); - addTest(new TestFailureTest()); - addTest(new VisualTestCaseTest()); - addTest(new AsynchronousTestCaseExample()); - } - } -} \ No newline at end of file Deleted: trunk/framework/as3/asunit/runner/AllTests.as =================================================================== --- trunk/framework/as3/asunit/runner/AllTests.as 2006-03-08 17:26:10 UTC (rev 31) +++ trunk/framework/as3/asunit/runner/AllTests.as 2006-03-08 17:28:15 UTC (rev 32) @@ -1,9 +0,0 @@ -package asunit.runner { - import asunit.framework.TestSuite; - - public class AllTests extends TestSuite { - - public function AllTests() { - } - } -} \ No newline at end of file Deleted: trunk/framework/as3/asunit/textui/AllTests.as =================================================================== --- trunk/framework/as3/asunit/textui/AllTests.as 2006-03-08 17:26:10 UTC (rev 31) +++ trunk/framework/as3/asunit/textui/AllTests.as 2006-03-08 17:28:15 UTC (rev 32) @@ -1,9 +0,0 @@ -package asunit.textui { - import asunit.framework.TestSuite; - - public class AllTests extends TestSuite { - - public function AllTests() { - } - } -} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ali...@us...> - 2006-03-08 17:53:04
|
Revision: 36 Author: alimills Date: 2006-03-08 09:52:56 -0800 (Wed, 08 Mar 2006) ViewCVS: http://svn.sourceforge.net/asunit/?rev=36&view=rev Log Message: ----------- renaming AsUnit to AsUnitTestRunner Added Paths: ----------- trunk/framework/as3/AsUnitTestRunner.as Removed Paths: ------------- trunk/framework/as3/AsUnit.as Deleted: trunk/framework/as3/AsUnit.as =================================================================== --- trunk/framework/as3/AsUnit.as 2006-03-08 17:50:50 UTC (rev 35) +++ trunk/framework/as3/AsUnit.as 2006-03-08 17:52:56 UTC (rev 36) @@ -1,17 +0,0 @@ -package { - import asunit.textui.TestRunner; - import flash.display.Stage; - import flash.display.StageAlign; - import flash.display.StageScaleMode; - import flash.system.fscommand; - - public class AsUnit extends TestRunner { - - public function AsUnit() { - fscommand("fullscreen", "true"); - stage.align = StageAlign.TOP_LEFT; - stage.scaleMode = StageScaleMode.NO_SCALE; - start(AllTests); - } - } -} Added: trunk/framework/as3/AsUnitTestRunner.as =================================================================== --- trunk/framework/as3/AsUnitTestRunner.as (rev 0) +++ trunk/framework/as3/AsUnitTestRunner.as 2006-03-08 17:52:56 UTC (rev 36) @@ -0,0 +1,17 @@ +package { + import asunit.textui.TestRunner; + import flash.display.Stage; + import flash.display.StageAlign; + import flash.display.StageScaleMode; + import flash.system.fscommand; + + public class AsUnitTestRunner extends TestRunner { + + public function AsUnit() { + fscommand("fullscreen", "true"); + stage.align = StageAlign.TOP_LEFT; + stage.scaleMode = StageScaleMode.NO_SCALE; + start(AllTests); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <luk...@us...> - 2006-09-19 16:13:26
|
Revision: 91
http://svn.sourceforge.net/asunit/?rev=91&view=rev
Author: lukebayes
Date: 2006-09-19 09:13:14 -0700 (Tue, 19 Sep 2006)
Log Message:
-----------
got test fixtures up to date
Modified Paths:
--------------
trunk/framework/as3/AsUnitTestRunner.as
trunk/framework/as3/asunit/framework/AssertTest.as
trunk/framework/as3/asunit/framework/TestCaseTest.as
Modified: trunk/framework/as3/AsUnitTestRunner.as
===================================================================
--- trunk/framework/as3/AsUnitTestRunner.as 2006-09-19 16:11:28 UTC (rev 90)
+++ trunk/framework/as3/AsUnitTestRunner.as 2006-09-19 16:13:14 UTC (rev 91)
@@ -7,8 +7,7 @@
public class AsUnitTestRunner extends TestRunner {
- public function AsUnit() {
- fscommand("fullscreen", "true");
+ public function AsUnitTestRunner() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
start(AllTests);
Modified: trunk/framework/as3/asunit/framework/AssertTest.as
===================================================================
--- trunk/framework/as3/asunit/framework/AssertTest.as 2006-09-19 16:11:28 UTC (rev 90)
+++ trunk/framework/as3/asunit/framework/AssertTest.as 2006-09-19 16:13:14 UTC (rev 91)
@@ -1,6 +1,5 @@
package asunit.framework {
- import flash.util.trace;
import flash.errors.IllegalOperationError;
import flash.display.Sprite;
Modified: trunk/framework/as3/asunit/framework/TestCaseTest.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCaseTest.as 2006-09-19 16:11:28 UTC (rev 90)
+++ trunk/framework/as3/asunit/framework/TestCaseTest.as 2006-09-19 16:13:14 UTC (rev 91)
@@ -1,5 +1,4 @@
package asunit.framework {
- import flash.util.trace;
public class TestCaseTest extends TestCase {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-19 16:19:22
|
Revision: 92
http://svn.sourceforge.net/asunit/?rev=92&view=rev
Author: lukebayes
Date: 2006-09-19 09:19:15 -0700 (Tue, 19 Sep 2006)
Log Message:
-----------
added test suites to repository
Added Paths:
-----------
trunk/framework/as3/AllTests.as
trunk/framework/as3/asunit/AllTests.as
trunk/framework/as3/asunit/framework/AllTests.as
Added: trunk/framework/as3/AllTests.as
===================================================================
--- trunk/framework/as3/AllTests.as (rev 0)
+++ trunk/framework/as3/AllTests.as 2006-09-19 16:19:15 UTC (rev 92)
@@ -0,0 +1,11 @@
+package {
+ import asunit.framework.TestSuite;
+ import asunit.AllTests;
+
+ public class AllTests extends TestSuite {
+
+ public function AllTests() {
+ addTest(new asunit.AllTests());
+ }
+ }
+}
Added: trunk/framework/as3/asunit/AllTests.as
===================================================================
--- trunk/framework/as3/asunit/AllTests.as (rev 0)
+++ trunk/framework/as3/asunit/AllTests.as 2006-09-19 16:19:15 UTC (rev 92)
@@ -0,0 +1,11 @@
+package asunit {
+ import asunit.framework.TestSuite;
+ import asunit.framework.AllTests;
+
+ public class AllTests extends TestSuite {
+
+ public function AllTests() {
+ addTest(new asunit.framework.AllTests());
+ }
+ }
+}
Added: trunk/framework/as3/asunit/framework/AllTests.as
===================================================================
--- trunk/framework/as3/asunit/framework/AllTests.as (rev 0)
+++ trunk/framework/as3/asunit/framework/AllTests.as 2006-09-19 16:19:15 UTC (rev 92)
@@ -0,0 +1,19 @@
+package asunit.framework {
+ import asunit.framework.TestSuite;
+ import asunit.framework.AssertTest;
+ import asunit.framework.TestCaseTest;
+ import asunit.framework.TestFailureTest;
+ import asunit.framework.TestSuiteTest;
+ import asunit.framework.VisualTestCaseTest;
+
+ public class AllTests extends TestSuite {
+
+ public function AllTests() {
+ addTest(new asunit.framework.AssertTest());
+ addTest(new asunit.framework.TestCaseTest());
+ addTest(new asunit.framework.TestFailureTest());
+ addTest(new asunit.framework.TestSuiteTest());
+ addTest(new asunit.framework.VisualTestCaseTest());
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-19 16:24:14
|
Revision: 93
http://svn.sourceforge.net/asunit/?rev=93&view=rev
Author: lukebayes
Date: 2006-09-19 09:24:06 -0700 (Tue, 19 Sep 2006)
Log Message:
-----------
fixing test case constructors
Modified Paths:
--------------
trunk/framework/as3/AsUnitTestRunner.as
trunk/framework/as3/asunit/framework/AllTests.as
trunk/framework/as3/asunit/framework/AssertTest.as
trunk/framework/as3/asunit/framework/TestCaseTest.as
trunk/framework/as3/asunit/framework/TestFailureTest.as
Removed Paths:
-------------
trunk/framework/as3/asunit/framework/TestSuiteTest.as
Modified: trunk/framework/as3/AsUnitTestRunner.as
===================================================================
--- trunk/framework/as3/AsUnitTestRunner.as 2006-09-19 16:19:15 UTC (rev 92)
+++ trunk/framework/as3/AsUnitTestRunner.as 2006-09-19 16:24:06 UTC (rev 93)
@@ -4,13 +4,14 @@
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.system.fscommand;
+ import asunit.framework.TestCaseTest;
public class AsUnitTestRunner extends TestRunner {
public function AsUnitTestRunner() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
- start(AllTests);
+ start(TestCaseTest, "testAsyncMethod");
}
}
}
Modified: trunk/framework/as3/asunit/framework/AllTests.as
===================================================================
--- trunk/framework/as3/asunit/framework/AllTests.as 2006-09-19 16:19:15 UTC (rev 92)
+++ trunk/framework/as3/asunit/framework/AllTests.as 2006-09-19 16:24:06 UTC (rev 93)
@@ -3,7 +3,6 @@
import asunit.framework.AssertTest;
import asunit.framework.TestCaseTest;
import asunit.framework.TestFailureTest;
- import asunit.framework.TestSuiteTest;
import asunit.framework.VisualTestCaseTest;
public class AllTests extends TestSuite {
@@ -12,7 +11,6 @@
addTest(new asunit.framework.AssertTest());
addTest(new asunit.framework.TestCaseTest());
addTest(new asunit.framework.TestFailureTest());
- addTest(new asunit.framework.TestSuiteTest());
addTest(new asunit.framework.VisualTestCaseTest());
}
}
Modified: trunk/framework/as3/asunit/framework/AssertTest.as
===================================================================
--- trunk/framework/as3/asunit/framework/AssertTest.as 2006-09-19 16:19:15 UTC (rev 92)
+++ trunk/framework/as3/asunit/framework/AssertTest.as 2006-09-19 16:24:06 UTC (rev 93)
@@ -5,7 +5,7 @@
public class AssertTest extends TestCase {
- public function AssertTest(testMethod:String = null) {
+ public function AssertTest(testMethod:String) {
super(testMethod);
}
Modified: trunk/framework/as3/asunit/framework/TestCaseTest.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCaseTest.as 2006-09-19 16:19:15 UTC (rev 92)
+++ trunk/framework/as3/asunit/framework/TestCaseTest.as 2006-09-19 16:24:06 UTC (rev 93)
@@ -2,6 +2,10 @@
public class TestCaseTest extends TestCase {
+ public function TestCaseTest(testMethod:String) {
+ super(testMethod);
+ }
+
public function testInstantiated():void {
assertTrue(this is TestCase);
}
@@ -37,5 +41,9 @@
assertTrue("testMethod2Run", mock.testMethod2Run);
assertTrue("testMethod3Run", mock.testMethod3Run);
}
+
+ public function testAsyncMethod():void {
+ assertTrue(false);
+ }
}
}
\ No newline at end of file
Modified: trunk/framework/as3/asunit/framework/TestFailureTest.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestFailureTest.as 2006-09-19 16:19:15 UTC (rev 92)
+++ trunk/framework/as3/asunit/framework/TestFailureTest.as 2006-09-19 16:24:06 UTC (rev 93)
@@ -2,6 +2,10 @@
public class TestFailureTest extends TestCase {
+ public function TestFailureTest(testMethod:String) {
+ super(testMethod);
+ }
+
public function testInstantiated():void {
var failure:TestFailure = new TestFailure(this, new Error());
assertTrue(failure is TestFailure);
Deleted: trunk/framework/as3/asunit/framework/TestSuiteTest.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestSuiteTest.as 2006-09-19 16:19:15 UTC (rev 92)
+++ trunk/framework/as3/asunit/framework/TestSuiteTest.as 2006-09-19 16:24:06 UTC (rev 93)
@@ -1,11 +0,0 @@
-package asunit.framework {
-
- public class TestSuiteTest extends TestSuite {
-
- public function TestSuiteTest() {
-// addTest(new AssertTest());
-// addTest(new AssertTest());
-// addTest(new AssertTest());
- }
- }
-}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-21 01:32:49
|
Revision: 115
http://svn.sourceforge.net/asunit/?rev=115&view=rev
Author: lukebayes
Date: 2006-09-20 18:32:40 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
Async test cases and suites seem to be working properly
Modified Paths:
--------------
trunk/framework/as3/AsUnitTestRunner.as
trunk/framework/as3/asunit/framework/Assert.as
trunk/framework/as3/asunit/framework/Test.as
trunk/framework/as3/asunit/framework/TestCase.as
trunk/framework/as3/asunit/framework/TestSuite.as
trunk/framework/as3/asunit/textui/TestRunner.as
Modified: trunk/framework/as3/AsUnitTestRunner.as
===================================================================
--- trunk/framework/as3/AsUnitTestRunner.as 2006-09-20 21:23:53 UTC (rev 114)
+++ trunk/framework/as3/AsUnitTestRunner.as 2006-09-21 01:32:40 UTC (rev 115)
@@ -1,10 +1,12 @@
package {
import asunit.textui.TestRunner;
+ import asunit.framework.TestCaseTest;
public class AsUnitTestRunner extends TestRunner {
public function AsUnitTestRunner() {
start(AllTests, null, TestRunner.SHOW_TRACE);
+// start(TestCaseTest, "testAsync");
}
}
}
Modified: trunk/framework/as3/asunit/framework/Assert.as
===================================================================
--- trunk/framework/as3/asunit/framework/Assert.as 2006-09-20 21:23:53 UTC (rev 114)
+++ trunk/framework/as3/asunit/framework/Assert.as 2006-09-21 01:32:40 UTC (rev 115)
@@ -1,14 +1,15 @@
package asunit.framework {
-
+ import asunit.errors.AssertionFailedError;
+
import flash.errors.IllegalOperationError;
- import asunit.errors.AssertionFailedError;
+ import flash.events.EventDispatcher;
import flash.utils.Proxy;
/**
* A set of assert methods. Messages are only displayed when an assert fails.
*/
- public class Assert {
+ public class Assert extends EventDispatcher {
/**
* Protect constructor since it is a static only class
*/
Modified: trunk/framework/as3/asunit/framework/Test.as
===================================================================
--- trunk/framework/as3/asunit/framework/Test.as 2006-09-20 21:23:53 UTC (rev 114)
+++ trunk/framework/as3/asunit/framework/Test.as 2006-09-21 01:32:40 UTC (rev 115)
@@ -1,7 +1,8 @@
package asunit.framework {
import flash.display.DisplayObjectContainer;
+ import flash.events.IEventDispatcher;
- public interface Test {
+ public interface Test extends IEventDispatcher {
function countTestCases():int;
function toString():String;
function setResult(result:TestResult):void;
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2006-09-20 21:23:53 UTC (rev 114)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2006-09-21 01:32:40 UTC (rev 115)
@@ -10,6 +10,7 @@
import flash.net.getClassByAlias;
import flash.utils.setTimeout;
import flash.utils.clearTimeout;
+ import flash.events.Event;
/**
* A test case defines the fixture to run multiple tests. To define a test case<br>
@@ -89,7 +90,7 @@
private var currentMethod:String;
private var runSingle:Boolean;
private var methodIterator:Iterator;
- private var methodIsAsynchronous:Boolean;
+ protected var methodIsAsynchronous:Boolean;
/**
* Constructs a test case with the given name.
@@ -99,12 +100,14 @@
var className:Object = description.@name;
var methods:XMLList = description..method.(@name.match("^test"));
if(testMethod != null) {
- runSingle = true;
testMethods = testMethod.split(", ").join(",").split(",");
} else {
setTestMethods(methods);
}
- setName(className.toString());
+ if(testMethods.length == 1) {
+ runSingle = true;
+ }
+ setName(className.toString());
}
/**
@@ -152,8 +155,7 @@
* @see TestResult
*/
public function run():void {
- var result:TestResult = getResult();
- result.run(this);
+ getResult().run(this);
}
public function setResult(result:TestResult):void {
@@ -181,12 +183,11 @@
}
}
finally {
- if(!runSingle) {
- if(!itr.hasNext() && !methodIsAsynchronous) {
- cleanUp();
- result.endTest(this);
- isComplete = true;
- }
+ if(!itr.hasNext() && !methodIsAsynchronous) {
+ cleanUp();
+ getResult().endTest(this);
+ isComplete = true;
+ dispatchEvent(new Event(Event.COMPLETE));
}
}
}
@@ -225,10 +226,10 @@
}
}
catch(e:AssertionFailedError) {
- result.addFailure(this, e);
+ getResult().addFailure(this, e);
}
catch(ioe:Error) {
- result.addError(this, ioe);
+ getResult().addError(this, ioe);
}
return true;
}
@@ -250,7 +251,7 @@
/**
* Returns a string representation of the test case
*/
- public function toString():String {
+ override public function toString():String {
return getName() + "." + getCurrentMethod() + "()";
}
/**
@@ -278,29 +279,32 @@
}
protected function addAsync(handler:Function, timeout:int=500):Function {
- methodIsAsynchronous = true;
+ this.methodIsAsynchronous = true;
var context:TestCase = this;
- asyncMethodTimeoutId = setTimeout(timeoutHandler, timeout);
+ this.asyncMethodTimeoutId = setTimeout(this.timeoutHandler, timeout, timeout);
return function(args:*):* {
+ clearTimeout(context.asyncMethodTimeoutId);
try {
handler.apply(context, arguments);
}
catch(e:AssertionFailedError) {
- context.result.addFailure(context, e);
+ context.getResult().addFailure(context, e);
}
catch(ioe:IllegalOperationError) {
- trace('foo'); // this trace needs to be here?! Why?!
- context.result.addError(context, ioe);
+ trace('illegaloperation'); // this trace needs to be here?! Why?!
+ // without that trace, the app throws an error!!!!
+ context.getResult().addError(context, ioe);
}
finally {
+ trace("ASYNC METHOD FINALLY BLOCK CALLED!");
context.methodIsAsynchronous = false;
context.runBare();
}
}
}
- protected function timeoutHandler():void {
- result.addError(this, new IllegalOperationError("TestCase.DEFAULT_TIMEOUT (" + DEFAULT_TIMEOUT + "ms) exceeded on an asynchronous test method."));
+ protected function timeoutHandler(timeout:Number):void {
+ result.addError(this, new IllegalOperationError("TestCase.timeout (" + timeout + "ms) exceeded on an asynchronous test method."));
methodIsAsynchronous = false;
runBare();
}
Modified: trunk/framework/as3/asunit/framework/TestSuite.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestSuite.as 2006-09-20 21:23:53 UTC (rev 114)
+++ trunk/framework/as3/asunit/framework/TestSuite.as 2006-09-21 01:32:40 UTC (rev 115)
@@ -1,5 +1,8 @@
package asunit.framework {
import flash.display.DisplayObjectContainer;
+ import flash.events.Event;
+ import asunit.util.Iterator;
+ import asunit.util.ArrayIterator;
/**
* A <code>TestSuite</code> is a <code>Composite</code> of Tests.
@@ -15,6 +18,7 @@
*/
public class TestSuite extends TestCase implements Test {
private var fTests:Array = new Array();
+ private var testsCompleteCount:Number = 0;
public function TestSuite() {
super();
@@ -48,12 +52,22 @@
*/
public override function run():void {
var result:TestResult = getResult();
- for each(var test:TestCase in fTests) {
+ var test:Test;
+ var itr:Iterator = new ArrayIterator(fTests);
+ while(itr.hasNext()) {
+ test = Test(itr.next());
test.setResult(result);
+ test.addEventListener(Event.COMPLETE, testCompleteHandler);
test.run();
}
}
-
+
+ private function testCompleteHandler(event:Event):void {
+ if(++testsCompleteCount >= testCount()) {
+ dispatchEvent(new Event(Event.COMPLETE));
+ }
+ }
+
/**
* Returns the number of tests in this suite
*/
Modified: trunk/framework/as3/asunit/textui/TestRunner.as
===================================================================
--- trunk/framework/as3/asunit/textui/TestRunner.as 2006-09-20 21:23:53 UTC (rev 114)
+++ trunk/framework/as3/asunit/textui/TestRunner.as 2006-09-21 01:32:40 UTC (rev 115)
@@ -32,6 +32,8 @@
public static const EXCEPTION_EXIT:int = 2;
public static const SHOW_TRACE:Boolean = true;
protected var fPrinter:ResultPrinter;
+ protected var startTime:Number;
+ protected var result:TestResult;
public function TestRunner() {
configureListeners();
@@ -66,14 +68,14 @@
// fscommand("showmenu", "false");
try {
- var suite:Test;
+ var instance:Test;
if(testMethod != null) {
- suite = new testCase(testMethod);
+ instance = new testCase(testMethod);
}
else {
- suite = new testCase();
+ instance = new testCase();
}
- return doRun(suite, showTrace);
+ return doRun(instance, showTrace);
}
catch(e:Error) {
throw new Error("Could not create and run test suite: " + e.getStackTrace());
@@ -81,8 +83,8 @@
return null;
}
- public function doRun(suite:Test, showTrace:Boolean = false):TestResult {
- var result:TestResult = new TestResult();
+ public function doRun(test:Test, showTrace:Boolean = false):TestResult {
+ result = new TestResult();
if(fPrinter == null) {
setPrinter(new ResultPrinter(showTrace));
}
@@ -90,39 +92,18 @@
fPrinter.setShowTrace(showTrace);
}
result.addListener(getPrinter());
- var startTime:Number = getTimer();
- suite.setResult(result);
- suite.setContext(this);
- suite.run();
-
- // Wait for all tests to be completed before finishing
- // the output.
- // This is how we are going to support asynchronous
- // TestCases.
- var intervalObj:Object = new Object();
- intervalObj.startTime = startTime;
- intervalObj.result = result;
- intervalObj.suite = suite;
- intervalObj.runOnce = false;
- // If you have no asynchronous TestCases, this will complete
- // in one millisecond
- intervalObj.intervalId = setInterval(onTestCompleted, 1, intervalObj);
-
+ startTime = getTimer();
+ test.setResult(result);
+ test.setContext(this);
+ test.addEventListener(Event.COMPLETE, testCompleteHandler);
+ test.run();
return result;
}
- private function onTestCompleted(intervalObj:Object):void {
- if(intervalObj.suite.getIsComplete()) {
- var endTime:Number = getTimer();
- var runTime:Number = endTime - intervalObj.startTime;
- getPrinter().printResult(intervalObj.result, runTime);
- clearInterval(intervalObj.intervalId);
- } else if(!intervalObj.runOnce) {
- // If you have an asynchronous TestCase, poll at less frequent intervals
- clearInterval(intervalObj.intervalId);
- intervalObj.runOnce = true;
- intervalObj.intervalId = setInterval(onTestCompleted, 20, intervalObj);
- }
+ private function testCompleteHandler(event:Event):void {
+ var endTime:Number = getTimer();
+ var runTime:Number = endTime - startTime;
+ getPrinter().printResult(result, runTime);
}
public function setPrinter(printer:ResultPrinter):void {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-11-24 08:32:12
|
Revision: 140
http://svn.sourceforge.net/asunit/?rev=140&view=rev
Author: lukebayes
Date: 2006-11-24 00:32:08 -0800 (Fri, 24 Nov 2006)
Log Message:
-----------
Cleaning up build process
Modified Paths:
--------------
trunk/framework/as3/build.sh
Property Changed:
----------------
trunk/framework/as3/
Property changes on: trunk/framework/as3
___________________________________________________________________
Name: svn:ignore
- bin
html-template
.settings
+ .flexLibProperties
bin
html-template
.settings
Modified: trunk/framework/as3/build.sh
===================================================================
--- trunk/framework/as3/build.sh 2006-11-22 18:37:25 UTC (rev 139)
+++ trunk/framework/as3/build.sh 2006-11-24 08:32:08 UTC (rev 140)
@@ -1,3 +1,8 @@
-#!/bin/bash
-
-compc -source-path . -output AsUnit.swc -namespace http://www.asunit.org/as3 manifest.xml -include-namespaces http://www.asunit.org/as3
\ No newline at end of file
+#! /bin/bash
+
+rm -rf bin
+mkdir bin
+
+# First Compile the SWC File...
+
+mxmlc -library-path 'bin/AsUnit.swc' -source-path '../../framework-test/as3' -debug -output 'bin/AsUnitTestRunner.swf' AsUnitTestRunner.as
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2007-02-10 06:46:12
|
Revision: 158
http://svn.sourceforge.net/asunit/?rev=158&view=rev
Author: lukebayes
Date: 2007-02-09 22:46:13 -0800 (Fri, 09 Feb 2007)
Log Message:
-----------
removed unused build and manifest files
Removed Paths:
-------------
trunk/framework/as3/build.sh
trunk/framework/as3/manifest.xml
Deleted: trunk/framework/as3/build.sh
===================================================================
--- trunk/framework/as3/build.sh 2007-01-29 23:09:39 UTC (rev 157)
+++ trunk/framework/as3/build.sh 2007-02-10 06:46:13 UTC (rev 158)
@@ -1,8 +0,0 @@
-#! /bin/bash
-
-rm -rf bin
-mkdir bin
-
-# First Compile the SWC File...
-
-mxmlc -library-path 'bin/AsUnit.swc' -source-path '../../framework-test/as3' -debug -output 'bin/AsUnitTestRunner.swf' AsUnitTestRunner.as
Deleted: trunk/framework/as3/manifest.xml
===================================================================
--- trunk/framework/as3/manifest.xml 2007-01-29 23:09:39 UTC (rev 157)
+++ trunk/framework/as3/manifest.xml 2007-02-10 06:46:13 UTC (rev 158)
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<componentPackage>
- <component id="Assert" class="asunit.framework.Assert" />
- <component id="AsynchronousTestCase" class="asunit.framework.AsynchronousTestCase" />
- <component id="AsynchronousTestCaseExample" class="asunit.framework.AsynchronousTestCaseExample" />
- <component id="Test" class="asunit.framework.Test" />
- <component id="TestCase" class="asunit.framework.TestCase" />
- <component id="TestCaseExample" class="asunit.framework.TestCaseExample" />
- <component id="TestFailure" class="asunit.framework.TestFailure" />
- <component id="TestListener" class="asunit.framework.TestListener" />
- <component id="TestResult" class="asunit.framework.TestResult" />
- <component id="TestSuite" class="asunit.framework.TestSuite" />
-
- <component id="BaseTestRunner" class="asunit.runner.BaseTestRunner" />
- <component id="TestSuiteLoader" class="asunit.runner.TestSuiteLoader" />
- <component id="Version" class="asunit.runner.Version" />
- <component id="FlexRunner" class="asunit.textui.FlexRunner" />
- <component id="FlexTestRunner" class="asunit.textui.FlexTestRunner" />
- <component id="ResultPrinter" class="asunit.textui.ResultPrinter" />
- <component id="TestRunner" class="asunit.textui.TestRunner" />
- <component id="ArrayIterator" class="asunit.util.ArrayIterator" />
- <component id="Iterator" class="asunit.util.Iterator" />
- <component id="Properties" class="asunit.util.Properties" />
- <component id="LayoutManager" class="mx.managers.LayoutManager" />
-
- <component id="AbstractMemberCalledError" class="asunit.errors.AbstractMemberCalledError" />
- <component id="AssertionFailedError" class="asunit.errors.AssertionFailedError" />
- <component id="ClassNotFoundError" class="asunit.errors.ClassNotFoundError" />
- <component id="InstanceNotFoundError" class="asunit.errors.InstanceNotFoundError" />
- <component id="UnimplementedFeatureError" class="asunit.errors.UnimplementedFeatureError" />
-</componentPackage>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-19 16:56:33
|
Revision: 96
http://svn.sourceforge.net/asunit/?rev=96&view=rev
Author: lukebayes
Date: 2006-09-19 09:56:18 -0700 (Tue, 19 Sep 2006)
Log Message:
-----------
added ArrayIterator to framework
Modified Paths:
--------------
trunk/framework/as3/AsUnitTestRunner.as
trunk/framework/as3/asunit/AllTests.as
trunk/framework/as3/asunit/framework/AssertTest.as
trunk/framework/as3/asunit/framework/TestCaseMock.as
trunk/framework/as3/asunit/framework/TestCaseTest.as
trunk/framework/as3/asunit/framework/TestFailureTest.as
trunk/framework/as3/asunit/framework/VisualTestCaseTest.as
Added Paths:
-----------
trunk/framework/as3/asunit/util/AllTests.as
trunk/framework/as3/asunit/util/ArrayIterator.as
trunk/framework/as3/asunit/util/ArrayIteratorTest.as
trunk/framework/as3/asunit/util/Iterator.as
Modified: trunk/framework/as3/AsUnitTestRunner.as
===================================================================
--- trunk/framework/as3/AsUnitTestRunner.as 2006-09-19 16:41:23 UTC (rev 95)
+++ trunk/framework/as3/AsUnitTestRunner.as 2006-09-19 16:56:18 UTC (rev 96)
@@ -1,17 +1,12 @@
package {
import asunit.textui.TestRunner;
- import flash.display.Stage;
- import flash.display.StageAlign;
- import flash.display.StageScaleMode;
- import flash.system.fscommand;
import asunit.framework.TestCaseTest;
public class AsUnitTestRunner extends TestRunner {
public function AsUnitTestRunner() {
- stage.align = StageAlign.TOP_LEFT;
- stage.scaleMode = StageScaleMode.NO_SCALE;
- start(TestCaseTest, "testAsyncMethod");
+ start(AllTests, null, TestRunner.SHOW_TRACE);
+// start(TestCaseTest, "testAsyncMethod");
}
}
}
Modified: trunk/framework/as3/asunit/AllTests.as
===================================================================
--- trunk/framework/as3/asunit/AllTests.as 2006-09-19 16:41:23 UTC (rev 95)
+++ trunk/framework/as3/asunit/AllTests.as 2006-09-19 16:56:18 UTC (rev 96)
@@ -1,11 +1,15 @@
package asunit {
import asunit.framework.TestSuite;
import asunit.framework.AllTests;
+ import asunit.textui.AllTests;
+ import asunit.util.AllTests;
public class AllTests extends TestSuite {
public function AllTests() {
addTest(new asunit.framework.AllTests());
+ addTest(new asunit.textui.AllTests());
+ addTest(new asunit.util.AllTests());
}
}
}
Modified: trunk/framework/as3/asunit/framework/AssertTest.as
===================================================================
--- trunk/framework/as3/asunit/framework/AssertTest.as 2006-09-19 16:41:23 UTC (rev 95)
+++ trunk/framework/as3/asunit/framework/AssertTest.as 2006-09-19 16:56:18 UTC (rev 96)
@@ -5,7 +5,7 @@
public class AssertTest extends TestCase {
- public function AssertTest(testMethod:String) {
+ public function AssertTest(testMethod:String = null) {
super(testMethod);
}
Modified: trunk/framework/as3/asunit/framework/TestCaseMock.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCaseMock.as 2006-09-19 16:41:23 UTC (rev 95)
+++ trunk/framework/as3/asunit/framework/TestCaseMock.as 2006-09-19 16:56:18 UTC (rev 96)
@@ -5,7 +5,7 @@
public var testMethod2Run:Boolean;
public var testMethod3Run:Boolean;
- public function TestCaseMock(methodName:String) {
+ public function TestCaseMock(methodName:String = null) {
super(methodName);
}
Modified: trunk/framework/as3/asunit/framework/TestCaseTest.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCaseTest.as 2006-09-19 16:41:23 UTC (rev 95)
+++ trunk/framework/as3/asunit/framework/TestCaseTest.as 2006-09-19 16:56:18 UTC (rev 96)
@@ -2,7 +2,7 @@
public class TestCaseTest extends TestCase {
- public function TestCaseTest(testMethod:String) {
+ public function TestCaseTest(testMethod:String = null) {
super(testMethod);
}
@@ -41,9 +41,5 @@
assertTrue("testMethod2Run", mock.testMethod2Run);
assertTrue("testMethod3Run", mock.testMethod3Run);
}
-
- public function testAsyncMethod():void {
- assertTrue(false);
- }
}
}
\ No newline at end of file
Modified: trunk/framework/as3/asunit/framework/TestFailureTest.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestFailureTest.as 2006-09-19 16:41:23 UTC (rev 95)
+++ trunk/framework/as3/asunit/framework/TestFailureTest.as 2006-09-19 16:56:18 UTC (rev 96)
@@ -2,7 +2,7 @@
public class TestFailureTest extends TestCase {
- public function TestFailureTest(testMethod:String) {
+ public function TestFailureTest(testMethod:String = null) {
super(testMethod);
}
Modified: trunk/framework/as3/asunit/framework/VisualTestCaseTest.as
===================================================================
--- trunk/framework/as3/asunit/framework/VisualTestCaseTest.as 2006-09-19 16:41:23 UTC (rev 95)
+++ trunk/framework/as3/asunit/framework/VisualTestCaseTest.as 2006-09-19 16:56:18 UTC (rev 96)
@@ -4,6 +4,10 @@
public class VisualTestCaseTest extends TestCase {
private var instance:Sprite;
+ public function VisualTestCaseTest(testMethod:String = null) {
+ super(testMethod);
+ }
+
protected override function setUp():void {
instance = new Sprite();
addChild(instance);
Added: trunk/framework/as3/asunit/util/AllTests.as
===================================================================
--- trunk/framework/as3/asunit/util/AllTests.as (rev 0)
+++ trunk/framework/as3/asunit/util/AllTests.as 2006-09-19 16:56:18 UTC (rev 96)
@@ -0,0 +1,11 @@
+package asunit.util {
+ import asunit.framework.TestSuite;
+ import asunit.util.ArrayIteratorTest;
+
+ public class AllTests extends TestSuite {
+
+ public function AllTests() {
+ addTest(new asunit.util.ArrayIteratorTest());
+ }
+ }
+}
Added: trunk/framework/as3/asunit/util/ArrayIterator.as
===================================================================
--- trunk/framework/as3/asunit/util/ArrayIterator.as (rev 0)
+++ trunk/framework/as3/asunit/util/ArrayIterator.as 2006-09-19 16:56:18 UTC (rev 96)
@@ -0,0 +1,24 @@
+package asunit.util {
+ import asunit.util.Iterator;
+
+ public class ArrayIterator implements Iterator {
+ private var list:Array;
+ private var index:Number = 0;
+
+ public function ArrayIterator(list:Array) {
+ this.list = list;
+ }
+
+ public function hasNext():Boolean {
+ return list[index] != null;
+ }
+
+ public function next():Object {
+ return list[index++];
+ }
+
+ public function reset():void {
+ index = 0;
+ }
+ }
+}
Added: trunk/framework/as3/asunit/util/ArrayIteratorTest.as
===================================================================
--- trunk/framework/as3/asunit/util/ArrayIteratorTest.as (rev 0)
+++ trunk/framework/as3/asunit/util/ArrayIteratorTest.as 2006-09-19 16:56:18 UTC (rev 96)
@@ -0,0 +1,65 @@
+package asunit.util {
+ import asunit.framework.TestCase;
+
+ public class ArrayIteratorTest extends TestCase {
+ private var itr:ArrayIterator;
+
+ public function ArrayIteratorTest(testMethod:String = null) {
+ super(testMethod);
+ }
+
+ protected override function setUp():void {
+ itr = new ArrayIterator(getSimpleArray(5));
+ }
+
+ private function getSimpleArray(count:Number):Array {
+ var arr:Array = new Array();
+ for(var i:Number = 0; i < count; i++) {
+ arr.push("item-" + i);
+ }
+ return arr;
+ }
+
+ protected override function tearDown():void {
+ itr = null;
+ }
+
+ public function testInstantiated():void {
+ assertTrue("ArrayIterator instantiated", itr is ArrayIterator);
+ }
+
+ public function testHasNext():void {
+ assertTrue(itr.hasNext());
+ }
+
+ public function testNext():void {
+ assertEquals("item-0", itr.next());
+ }
+
+ public function testNextTwice():void {
+ assertEquals("item-0", itr.next());
+ assertEquals("item-1", itr.next());
+ }
+
+ public function testLast():void {
+ assertTrue(itr.hasNext());
+ assertEquals("item-0", itr.next());
+ assertTrue(itr.hasNext());
+ assertEquals("item-1", itr.next());
+ assertTrue(itr.hasNext());
+ assertEquals("item-2", itr.next());
+ assertTrue(itr.hasNext());
+ assertEquals("item-3", itr.next());
+ assertTrue(itr.hasNext());
+ assertEquals("item-4", itr.next());
+ assertFalse(itr.hasNext());
+ }
+
+ public function testReset():void {
+ testLast();
+ itr.reset();
+ assertTrue(itr.hasNext());
+ assertEquals("item-0", itr.next());
+ }
+ }
+}
Added: trunk/framework/as3/asunit/util/Iterator.as
===================================================================
--- trunk/framework/as3/asunit/util/Iterator.as (rev 0)
+++ trunk/framework/as3/asunit/util/Iterator.as 2006-09-19 16:56:18 UTC (rev 96)
@@ -0,0 +1,8 @@
+package asunit.util {
+
+ public interface Iterator {
+ function next():Object;
+ function hasNext():Boolean;
+ function reset():void;
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-19 20:35:14
|
Revision: 98
http://svn.sourceforge.net/asunit/?rev=98&view=rev
Author: lukebayes
Date: 2006-09-19 13:35:05 -0700 (Tue, 19 Sep 2006)
Log Message:
-----------
Working on async test methods
Modified Paths:
--------------
trunk/framework/as3/AsUnitTestRunner.as
trunk/framework/as3/asunit/framework/Assert.as
trunk/framework/as3/asunit/framework/TestCase.as
trunk/framework/as3/asunit/framework/TestResult.as
trunk/framework/as3/asunit/textui/TestRunnerTest.as
trunk/framework/as3/asunit/textui/TestRunnerTestCaseMock.as
Modified: trunk/framework/as3/AsUnitTestRunner.as
===================================================================
--- trunk/framework/as3/AsUnitTestRunner.as 2006-09-19 16:57:15 UTC (rev 97)
+++ trunk/framework/as3/AsUnitTestRunner.as 2006-09-19 20:35:05 UTC (rev 98)
@@ -1,12 +1,13 @@
package {
import asunit.textui.TestRunner;
import asunit.framework.TestCaseTest;
+ import asunit.textui.TestRunnerTest;
public class AsUnitTestRunner extends TestRunner {
public function AsUnitTestRunner() {
start(AllTests, null, TestRunner.SHOW_TRACE);
-// start(TestCaseTest, "testAsyncMethod");
+// start(TestRunnerTest);
}
}
}
Modified: trunk/framework/as3/asunit/framework/Assert.as
===================================================================
--- trunk/framework/as3/asunit/framework/Assert.as 2006-09-19 16:57:15 UTC (rev 97)
+++ trunk/framework/as3/asunit/framework/Assert.as 2006-09-19 20:35:05 UTC (rev 98)
@@ -2,12 +2,13 @@
import flash.errors.IllegalOperationError;
import asunit.errors.AssertionFailedError;
+ import flash.utils.Proxy;
/**
* A set of assert methods. Messages are only displayed when an assert fails.
*/
- public class Assert {
+ public class Assert extends Proxy {
/**
* Protect constructor since it is a static only class
*/
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2006-09-19 16:57:15 UTC (rev 97)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2006-09-19 20:35:05 UTC (rev 98)
@@ -5,7 +5,13 @@
import flash.display.DisplayObjectContainer;
import flash.errors.IllegalOperationError;
import flash.utils.describeType;
+ import asunit.util.Iterator;
+ import asunit.util.ArrayIterator;
+ import flash.net.getClassByAlias;
+ import flash.utils.setTimeout;
+ import flash.utils.flash_proxy;
+ use namespace flash_proxy;
/**
* A test case defines the fixture to run multiple tests. To define a test case<br>
* 1) implement a subclass of TestCase<br>
@@ -70,7 +76,6 @@
* @see TestResult
* @see TestSuite
*/
-
public class TestCase extends Assert implements Test {
/**
* the name of the test case
@@ -82,6 +87,7 @@
protected var context:DisplayObjectContainer;
private var currentMethod:String;
private var runSingle:Boolean;
+ private var methodIterator:Iterator;
/**
@@ -111,9 +117,25 @@
protected function setTestMethods(methodNodes:XMLList):void {
testMethods = new Array();
var methodNames:Object = methodNodes.@name;
+ var completeMethods:Array = new Array();
+ var name:String;
for each(var item:Object in methodNames) {
- testMethods.push(item.toString());
+ name = item.toString();
+ if(name.match(/Complete$/)) {
+ completeMethods.push(name);
+ swapCompleteMethod(name);
+ }
+ else {
+ testMethods.push(name);
+ }
}
+ for each(name in completeMethods) {
+ var index:int = name.indexOf("Complete");
+ var baseName:String = name.substr(0, index);
+ if(testMethods.indexOf(baseName) == -1) {
+ testMethods.push(name);
+ }
+ }
}
/**
@@ -161,28 +183,35 @@
* throws Error
*/
public function runBare():void {
- var methods:Array = testMethods;
+ var name:String;
+ var itr:Iterator = getMethodIterator();
try {
- for each(var name:String in methods) {
- try {
- runMethod(name);
+ while(itr.hasNext()) {
+ name = String(itr.next());
+ trace("itrating with: " + getName() + "." + name);
+ if(!runMethod(name)) {
+ trace("RETURNING ON : " + name);
+ break;
}
- catch(e:AssertionFailedError) {
- result.addFailure(this, e);
- }
- catch(ioe:Error) {
- result.addError(this, ioe);
- }
}
}
finally {
if(!runSingle) {
cleanUp();
+ if(!itr.hasNext()) {
+ result.endTest(this);
+ isComplete = true;
+ }
}
}
-
- isComplete = true;
}
+
+ private function getMethodIterator():Iterator {
+ if(methodIterator == null) {
+ methodIterator = new ArrayIterator(testMethods);
+ }
+ return methodIterator;
+ }
// Override this method in Asynchronous test cases
// or any other time you want to perform additional
@@ -190,19 +219,57 @@
protected function cleanUp():void {
}
- private function runMethod(methodName:String):void {
- setUp();
- currentMethod = methodName;
+// override flash_proxy function hasProperty(name:*):Boolean {
+// return (this[name] != undefined);
+// }
+
+// override flash_proxy function getProperty(name:*):* {
+// return this[name];
+// }
+
+ private function runMethod(methodName:String):Boolean {
try {
- this[methodName]();
- }
- finally {
- if(!runSingle) {
- tearDown();
+ setUp();
+ currentMethod = methodName;
+ try {
+// var ns:Namespace = flash_proxy;
+// if(this.flash_proxy::hasProperty(methodName + "Complete")) {
+// trace("HAS PROP : " + methodName);
+// }
+// if(this[methodName + "Complete"] != null) {
+// if(this.hasOwnProperty(methodName + "Complete")) {
+// setTimeout(this[methodName], 1);
+// return false;
+// }
+ this[methodName]();
}
+ finally {
+ if(!runSingle) {
+ tearDown();
+ }
+ }
}
+ catch(e:AssertionFailedError) {
+ result.addFailure(this, e);
+ }
+ catch(ioe:Error) {
+ result.addError(this, ioe);
+ }
+ return true;
}
+ private function swapCompleteMethod(name:String):void {
+ trace("swapping complete method with: " + name);
+ var obj:Object = new Object();
+ obj[name] = this[name];
+// this[name] = defaultCompleteMethod;
+// this.prototype["__" + name] = this.prototype[name];
+// this[name] = defaultCompleteMethod;
+ }
+
+ private function defaultCompleteMethod():void {
+ trace("default complete method called");
+ }
/**
* Sets up the fixture, for example, instantiate a mock object.
* This method is called before each test is executed.
Modified: trunk/framework/as3/asunit/framework/TestResult.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestResult.as 2006-09-19 16:57:15 UTC (rev 97)
+++ trunk/framework/as3/asunit/framework/TestResult.as 2006-09-19 20:35:05 UTC (rev 98)
@@ -103,18 +103,7 @@
*/
public function run(test:TestCase):void {
startTest(test);
- try {
- test.runBare();
- }
- catch(e:AssertionFailedError) {
- addFailure(test, e);
- }
- catch(ioe:IllegalOperationError) {
- addError(test, ioe);
- }
- finally {
- endTest(test);
- }
+ test.runBare();
}
/**
* Gets the number of run tests.
Modified: trunk/framework/as3/asunit/textui/TestRunnerTest.as
===================================================================
--- trunk/framework/as3/asunit/textui/TestRunnerTest.as 2006-09-19 16:57:15 UTC (rev 97)
+++ trunk/framework/as3/asunit/textui/TestRunnerTest.as 2006-09-19 20:35:05 UTC (rev 98)
@@ -1,5 +1,6 @@
package asunit.textui {
- import asunit.framework.TestCase;
+ import asunit.framework.TestCase;
+ import flash.utils.setTimeout;
public class TestRunnerTest extends TestCase {
private var instance:TestRunner;
@@ -21,9 +22,18 @@
public function testInstantiated():void {
assertTrue("TestRunner instantiated", instance is TestRunner);
}
+
+// public function testAsync():void {
+// setTimeout(testAsyncComplete, 10);
+// }
- public function testStart():void {
- instance.start(TestRunnerTestCaseMock);
+// public function testAsyncComplete():void {
+// fail("test async complete failed");
+// runBare();
+// }
+
+ public function testSomethingComplete():void {
+ trace("testSomethignCOmplete executed");
}
}
}
Modified: trunk/framework/as3/asunit/textui/TestRunnerTestCaseMock.as
===================================================================
--- trunk/framework/as3/asunit/textui/TestRunnerTestCaseMock.as 2006-09-19 16:57:15 UTC (rev 97)
+++ trunk/framework/as3/asunit/textui/TestRunnerTestCaseMock.as 2006-09-19 20:35:05 UTC (rev 98)
@@ -15,6 +15,10 @@
testMethod1Run = true;
}
+ public function testMethod1Completed():void {
+ trace("testMethod1Handler called");
+ }
+
public function testMethod2():void {
testMethod2Run = true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-19 21:40:56
|
Revision: 99
http://svn.sourceforge.net/asunit/?rev=99&view=rev
Author: lukebayes
Date: 2006-09-19 14:40:51 -0700 (Tue, 19 Sep 2006)
Log Message:
-----------
got a basic async test method working, still not ideal though
Modified Paths:
--------------
trunk/framework/as3/AsUnitTestRunner.as
trunk/framework/as3/asunit/framework/TestCase.as
trunk/framework/as3/asunit/textui/TestRunnerTest.as
Modified: trunk/framework/as3/AsUnitTestRunner.as
===================================================================
--- trunk/framework/as3/AsUnitTestRunner.as 2006-09-19 20:35:05 UTC (rev 98)
+++ trunk/framework/as3/AsUnitTestRunner.as 2006-09-19 21:40:51 UTC (rev 99)
@@ -6,8 +6,8 @@
public class AsUnitTestRunner extends TestRunner {
public function AsUnitTestRunner() {
- start(AllTests, null, TestRunner.SHOW_TRACE);
-// start(TestRunnerTest);
+// start(AllTests, null, TestRunner.SHOW_TRACE);
+ start(TestRunnerTest);
}
}
}
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2006-09-19 20:35:05 UTC (rev 98)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2006-09-19 21:40:51 UTC (rev 99)
@@ -76,7 +76,7 @@
* @see TestResult
* @see TestSuite
*/
- public class TestCase extends Assert implements Test {
+ dynamic public class TestCase extends Assert implements Test {
/**
* the name of the test case
*/
@@ -88,12 +88,14 @@
private var currentMethod:String;
private var runSingle:Boolean;
private var methodIterator:Iterator;
+ private var asyncMethods:Object;
/**
* Constructs a test case with the given name.
*/
public function TestCase(testMethod:String = null) {
+ asyncMethods = new Object();
var description:XML = describeType(this);
var className:Object = description.@name;
var methods:XMLList = description..method.(@name.match("^test"));
@@ -123,7 +125,6 @@
name = item.toString();
if(name.match(/Complete$/)) {
completeMethods.push(name);
- swapCompleteMethod(name);
}
else {
testMethods.push(name);
@@ -135,6 +136,9 @@
if(testMethods.indexOf(baseName) == -1) {
testMethods.push(name);
}
+ else {
+ swapCompleteMethod(name);
+ }
}
}
@@ -185,12 +189,14 @@
public function runBare():void {
var name:String;
var itr:Iterator = getMethodIterator();
+ var isWaiting:Boolean = false;
try {
while(itr.hasNext()) {
name = String(itr.next());
- trace("itrating with: " + getName() + "." + name);
+ trace("name: " + name);
if(!runMethod(name)) {
- trace("RETURNING ON : " + name);
+ trace("BLOCKING EXECUTION ON : " + name);
+ isWaiting = true;
break;
}
}
@@ -198,7 +204,8 @@
finally {
if(!runSingle) {
cleanUp();
- if(!itr.hasNext()) {
+ if(!itr.hasNext() && !isWaiting) {
+ trace("itr hasNext was false");
result.endTest(this);
isComplete = true;
}
@@ -219,12 +226,16 @@
protected function cleanUp():void {
}
-// override flash_proxy function hasProperty(name:*):Boolean {
-// return (this[name] != undefined);
-// }
+ override flash_proxy function hasProperty(name:*):Boolean {
+ return (this[name] != undefined);
+ }
-// override flash_proxy function getProperty(name:*):* {
-// return this[name];
+ override flash_proxy function getProperty(name:*):* {
+ return asyncMethods[name];
+ }
+
+// override flash_proxy function setProperty(name:*, value:*):void {
+// this[name] = value;
// }
private function runMethod(methodName:String):Boolean {
@@ -232,6 +243,11 @@
setUp();
currentMethod = methodName;
try {
+ if((methodName + "Complete") in this) {
+ trace("FOUND YOU! at: " + methodName);
+ this[methodName]();
+ return false;
+ }
// var ns:Namespace = flash_proxy;
// if(this.flash_proxy::hasProperty(methodName + "Complete")) {
// trace("HAS PROP : " + methodName);
@@ -260,15 +276,15 @@
private function swapCompleteMethod(name:String):void {
trace("swapping complete method with: " + name);
- var obj:Object = new Object();
- obj[name] = this[name];
-// this[name] = defaultCompleteMethod;
-// this.prototype["__" + name] = this.prototype[name];
-// this[name] = defaultCompleteMethod;
+ asyncMethods["__" + name] = this[name];
+ asyncMethods[name] = defaultCompleteMethod;
+// this[name] = this.defaultCompleteMethod;
+ //var result:Boolean = delete this[name];
+ //trace("RESULT: " + result);
}
- private function defaultCompleteMethod():void {
- trace("default complete method called");
+ public function defaultCompleteMethod():void {
+ trace("asunit complete called");
}
/**
* Sets up the fixture, for example, instantiate a mock object.
@@ -322,5 +338,8 @@
return getContext().removeChild(child);
}
+ public function fail(message:String):void {
+ result.addFailure(this, new AssertionFailedError(message));
+ }
}
}
\ No newline at end of file
Modified: trunk/framework/as3/asunit/textui/TestRunnerTest.as
===================================================================
--- trunk/framework/as3/asunit/textui/TestRunnerTest.as 2006-09-19 20:35:05 UTC (rev 98)
+++ trunk/framework/as3/asunit/textui/TestRunnerTest.as 2006-09-19 21:40:51 UTC (rev 99)
@@ -23,17 +23,17 @@
assertTrue("TestRunner instantiated", instance is TestRunner);
}
-// public function testAsync():void {
-// setTimeout(testAsyncComplete, 10);
-// }
+ public function testAsync():void {
+ setTimeout(testAsyncComplete, 10);
+ }
-// public function testAsyncComplete():void {
-// fail("test async complete failed");
-// runBare();
-// }
+ public function testAsyncComplete():void {
+ trace("user complete called");
+ fail("test async complete failed");
+ runBare();
+ }
public function testSomethingComplete():void {
- trace("testSomethignCOmplete executed");
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-19 22:11:43
|
Revision: 100
http://svn.sourceforge.net/asunit/?rev=100&view=rev
Author: lukebayes
Date: 2006-09-19 15:11:36 -0700 (Tue, 19 Sep 2006)
Log Message:
-----------
working toward async test methods, almost there
Modified Paths:
--------------
trunk/framework/as3/AsUnitTestRunner.as
trunk/framework/as3/asunit/framework/Assert.as
trunk/framework/as3/asunit/framework/AssertTest.as
trunk/framework/as3/asunit/framework/TestCase.as
trunk/framework/as3/asunit/textui/TestRunnerTest.as
Modified: trunk/framework/as3/AsUnitTestRunner.as
===================================================================
--- trunk/framework/as3/AsUnitTestRunner.as 2006-09-19 21:40:51 UTC (rev 99)
+++ trunk/framework/as3/AsUnitTestRunner.as 2006-09-19 22:11:36 UTC (rev 100)
@@ -6,8 +6,8 @@
public class AsUnitTestRunner extends TestRunner {
public function AsUnitTestRunner() {
-// start(AllTests, null, TestRunner.SHOW_TRACE);
- start(TestRunnerTest);
+ start(AllTests, null, TestRunner.SHOW_TRACE);
+// start(TestRunnerTest);
}
}
}
Modified: trunk/framework/as3/asunit/framework/Assert.as
===================================================================
--- trunk/framework/as3/asunit/framework/Assert.as 2006-09-19 21:40:51 UTC (rev 99)
+++ trunk/framework/as3/asunit/framework/Assert.as 2006-09-19 22:11:36 UTC (rev 100)
@@ -8,7 +8,7 @@
* A set of assert methods. Messages are only displayed when an assert fails.
*/
- public class Assert extends Proxy {
+ public class Assert {
/**
* Protect constructor since it is a static only class
*/
Modified: trunk/framework/as3/asunit/framework/AssertTest.as
===================================================================
--- trunk/framework/as3/asunit/framework/AssertTest.as 2006-09-19 21:40:51 UTC (rev 99)
+++ trunk/framework/as3/asunit/framework/AssertTest.as 2006-09-19 22:11:36 UTC (rev 100)
@@ -51,7 +51,7 @@
public function testFail():void {
try {
- fail("this shouldn't be caught");
+ Assert.fail("this shouldn't be caught");
}
catch(e:Error) {
assertTrue("passed", true);
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2006-09-19 21:40:51 UTC (rev 99)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2006-09-19 22:11:36 UTC (rev 100)
@@ -9,9 +9,7 @@
import asunit.util.ArrayIterator;
import flash.net.getClassByAlias;
import flash.utils.setTimeout;
- import flash.utils.flash_proxy;
- use namespace flash_proxy;
/**
* A test case defines the fixture to run multiple tests. To define a test case<br>
* 1) implement a subclass of TestCase<br>
@@ -76,7 +74,7 @@
* @see TestResult
* @see TestSuite
*/
- dynamic public class TestCase extends Assert implements Test {
+ public class TestCase extends Assert implements Test {
/**
* the name of the test case
*/
@@ -88,14 +86,12 @@
private var currentMethod:String;
private var runSingle:Boolean;
private var methodIterator:Iterator;
- private var asyncMethods:Object;
+ private var methodIsAsynchronous:Boolean;
-
/**
* Constructs a test case with the given name.
*/
public function TestCase(testMethod:String = null) {
- asyncMethods = new Object();
var description:XML = describeType(this);
var className:Object = description.@name;
var methods:XMLList = description..method.(@name.match("^test"));
@@ -119,27 +115,11 @@
protected function setTestMethods(methodNodes:XMLList):void {
testMethods = new Array();
var methodNames:Object = methodNodes.@name;
- var completeMethods:Array = new Array();
var name:String;
for each(var item:Object in methodNames) {
name = item.toString();
- if(name.match(/Complete$/)) {
- completeMethods.push(name);
- }
- else {
- testMethods.push(name);
- }
+ testMethods.push(name);
}
- for each(name in completeMethods) {
- var index:int = name.indexOf("Complete");
- var baseName:String = name.substr(0, index);
- if(testMethods.indexOf(baseName) == -1) {
- testMethods.push(name);
- }
- else {
- swapCompleteMethod(name);
- }
- }
}
/**
@@ -189,23 +169,22 @@
public function runBare():void {
var name:String;
var itr:Iterator = getMethodIterator();
- var isWaiting:Boolean = false;
try {
while(itr.hasNext()) {
name = String(itr.next());
trace("name: " + name);
if(!runMethod(name)) {
trace("BLOCKING EXECUTION ON : " + name);
- isWaiting = true;
break;
}
}
}
finally {
if(!runSingle) {
- cleanUp();
- if(!itr.hasNext() && !isWaiting) {
- trace("itr hasNext was false");
+ if(!itr.hasNext() && !methodIsAsynchronous) {
+ trace("--------------");
+ trace("INSIDE THE END");
+ cleanUp();
result.endTest(this);
isComplete = true;
}
@@ -225,39 +204,16 @@
// member cleanup after all test methods have run
protected function cleanUp():void {
}
-
- override flash_proxy function hasProperty(name:*):Boolean {
- return (this[name] != undefined);
- }
- override flash_proxy function getProperty(name:*):* {
- return asyncMethods[name];
- }
-
-// override flash_proxy function setProperty(name:*, value:*):void {
-// this[name] = value;
-// }
-
private function runMethod(methodName:String):Boolean {
try {
setUp();
currentMethod = methodName;
try {
- if((methodName + "Complete") in this) {
- trace("FOUND YOU! at: " + methodName);
- this[methodName]();
+ this[methodName]();
+ if(methodIsAsynchronous) {
return false;
}
-// var ns:Namespace = flash_proxy;
-// if(this.flash_proxy::hasProperty(methodName + "Complete")) {
-// trace("HAS PROP : " + methodName);
-// }
-// if(this[methodName + "Complete"] != null) {
-// if(this.hasOwnProperty(methodName + "Complete")) {
-// setTimeout(this[methodName], 1);
-// return false;
-// }
- this[methodName]();
}
finally {
if(!runSingle) {
@@ -274,18 +230,6 @@
return true;
}
- private function swapCompleteMethod(name:String):void {
- trace("swapping complete method with: " + name);
- asyncMethods["__" + name] = this[name];
- asyncMethods[name] = defaultCompleteMethod;
-// this[name] = this.defaultCompleteMethod;
- //var result:Boolean = delete this[name];
- //trace("RESULT: " + result);
- }
-
- public function defaultCompleteMethod():void {
- trace("asunit complete called");
- }
/**
* Sets up the fixture, for example, instantiate a mock object.
* This method is called before each test is executed.
@@ -330,6 +274,24 @@
return context;
}
+ protected function addAsync(handler:Function):Function {
+ methodIsAsynchronous = true;
+ var context:Object = this;
+ return function(args:*):* {
+ try {
+ handler.apply(context, arguments);
+ }
+ catch(e:AssertionFailedError) {
+ context.result.addFailure(context, e);
+ }
+ catch(ioe:IllegalOperationError) {
+ context.result.addError(context, ioe);
+ }
+ context.methodIsAsynchronous = false;
+ context.runBare();
+ }
+ }
+
protected function addChild(child:DisplayObject):DisplayObject {
return getContext().addChild(child);
}
@@ -338,8 +300,8 @@
return getContext().removeChild(child);
}
- public function fail(message:String):void {
- result.addFailure(this, new AssertionFailedError(message));
- }
+// public function fail(message:String):void {
+// result.addFailure(this, new AssertionFailedError(message));
+// }
}
}
\ No newline at end of file
Modified: trunk/framework/as3/asunit/textui/TestRunnerTest.as
===================================================================
--- trunk/framework/as3/asunit/textui/TestRunnerTest.as 2006-09-19 21:40:51 UTC (rev 99)
+++ trunk/framework/as3/asunit/textui/TestRunnerTest.as 2006-09-19 22:11:36 UTC (rev 100)
@@ -1,6 +1,8 @@
package asunit.textui {
import asunit.framework.TestCase;
- import flash.utils.setTimeout;
+ import flash.utils.setTimeout;
+ import flash.events.Event;
+ import flash.errors.IllegalOperationError;
public class TestRunnerTest extends TestCase {
private var instance:TestRunner;
@@ -20,20 +22,26 @@
}
public function testInstantiated():void {
- assertTrue("TestRunner instantiated", instance is TestRunner);
+ assertTrue("TestRunner instantiated with: " + instance, instance is TestRunner);
}
public function testAsync():void {
- setTimeout(testAsyncComplete, 10);
+ var handler:Function = addAsync(asyncCompleteHandler);
+ setTimeout(handler, 1000, new Event(Event.ACTIVATE));
}
- public function testAsyncComplete():void {
- trace("user complete called");
+ public function asyncCompleteHandler(event:Event):void {
+// throw new IllegalOperationError("what the fuck?");
fail("test async complete failed");
- runBare();
}
public function testSomethingComplete():void {
}
+
+ public function testSomethingElse():void {
+ }
+
+ public function testAnotherThing():void {
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-20 18:21:15
|
Revision: 104
http://svn.sourceforge.net/asunit/?rev=104&view=rev
Author: lukebayes
Date: 2006-09-20 11:20:59 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
moving test classes to framework-test
Removed Paths:
-------------
trunk/framework/as3/AllTests.as
trunk/framework/as3/asunit/framework/AllTests.as
trunk/framework/as3/asunit/framework/AssertTest.as
trunk/framework/as3/asunit/framework/MockData.xml
trunk/framework/as3/asunit/framework/TestCaseMock.as
trunk/framework/as3/asunit/framework/TestCaseTest.as
trunk/framework/as3/asunit/framework/TestFailureTest.as
trunk/framework/as3/asunit/framework/VisualTestCaseTest.as
trunk/framework/as3/asunit/runner/BaseTestRunnerMock.as
trunk/framework/as3/asunit/textui/AllTests.as
trunk/framework/as3/asunit/textui/TestRunnerTest.as
trunk/framework/as3/asunit/textui/TestRunnerTestCaseMock.as
trunk/framework/as3/asunit/util/AllTests.as
trunk/framework/as3/asunit/util/ArrayIteratorTest.as
Deleted: trunk/framework/as3/AllTests.as
===================================================================
--- trunk/framework/as3/AllTests.as 2006-09-20 18:16:23 UTC (rev 103)
+++ trunk/framework/as3/AllTests.as 2006-09-20 18:20:59 UTC (rev 104)
@@ -1,11 +0,0 @@
-package {
- import asunit.framework.TestSuite;
- import asunit.AllTests;
-
- public class AllTests extends TestSuite {
-
- public function AllTests() {
- addTest(new asunit.AllTests());
- }
- }
-}
Deleted: trunk/framework/as3/asunit/framework/AllTests.as
===================================================================
--- trunk/framework/as3/asunit/framework/AllTests.as 2006-09-20 18:16:23 UTC (rev 103)
+++ trunk/framework/as3/asunit/framework/AllTests.as 2006-09-20 18:20:59 UTC (rev 104)
@@ -1,17 +0,0 @@
-package asunit.framework {
- import asunit.framework.TestSuite;
- import asunit.framework.AssertTest;
- import asunit.framework.TestCaseTest;
- import asunit.framework.TestFailureTest;
- import asunit.framework.VisualTestCaseTest;
-
- public class AllTests extends TestSuite {
-
- public function AllTests() {
- addTest(new asunit.framework.AssertTest());
- addTest(new asunit.framework.TestCaseTest());
- addTest(new asunit.framework.TestFailureTest());
- addTest(new asunit.framework.VisualTestCaseTest());
- }
- }
-}
Deleted: trunk/framework/as3/asunit/framework/AssertTest.as
===================================================================
--- trunk/framework/as3/asunit/framework/AssertTest.as 2006-09-20 18:16:23 UTC (rev 103)
+++ trunk/framework/as3/asunit/framework/AssertTest.as 2006-09-20 18:20:59 UTC (rev 104)
@@ -1,187 +0,0 @@
-package asunit.framework {
-
- import flash.errors.IllegalOperationError;
- import flash.display.Sprite;
-
- public class AssertTest extends TestCase {
-
- public function AssertTest(testMethod:String = null) {
- super(testMethod);
- }
-
- public function testAssertTrue():void {
- assertTrue(true);
- }
-
- public function testAssertFalse():void {
- assertFalse(false);
- }
-
- public function testAssertFalseWithMessage():void {
- assertFalse("message", false);
- }
-
- public function testAssertTrueWithMessage():void {
- assertTrue("message", true);
- }
-
- public function testAssertTrueFailure():void {
- try {
- assertTrue(false);
- }
- catch(e:Error) {
- return;
- }
- assertTrue("assertTrue(false) should have failed but didn't", false);
- }
-
- public function testAssertTrueMessage():void {
- assertTrue("asertTrue with message", true);
- }
-
- public function testAssertTrueMessageFailure():void {
- try {
- assertTrue("trueMessage", false);
- }
- catch(e:Error) {
- return;
- }
- assertTrue("assertTrue('message', false) should have failed but didn't", false);
- }
-
- public function testFail():void {
- try {
- Assert.fail("this shouldn't be caught");
- }
- catch(e:Error) {
- assertTrue("passed", true);
- return;
- }
- fail("failure should be thrown");
- }
-
- public function testAssertEqualsSimple():void {
- var obj1:Object = new Object();
- assertEquals(obj1, obj1);
- }
-
- public function testEqualsMethod():void {
- var obj1:Object = new Object();
- obj1.equals = function():Boolean {
- return true;
- }
-
- var obj2:Object = new Object();
- obj2.equals = function():Boolean {
- return true;
- }
- assertEquals(obj1, obj2);
- }
-
- public function testEqualsSimpleMessage():void {
- var obj1:Object = new Object();
- assertEquals("message", obj1, obj1);
- }
-
- public function testEqualsFailure():void {
- var obj1:Object = new Object();
- var obj2:Object = new Object();
- try {
- assertEquals(obj1, obj2);
- }
- catch(e:Error) {
- return;
- }
- fail("obj1 does not equal obj2");
- }
-
- public function testEqualsSimpleMessageFailure():void {
- try {
- var obj1:Object = new Object();
- var obj2:Object = new Object();
- assertEquals("message", obj1, obj2);
- }
- catch(e:Error) {
- return;
- }
- fail("obj1 does not equal obj2 with message");
- }
-
- public function testNull():void {
- assertNull(null);
- }
-
- public function testNullMessage():void {
- assertNull("message", null);
- }
-
- public function testNullFailure():void {
- var obj:Object = new Object();
- try {
- assertNull("message", obj);
- }
- catch(e:Error) {
- return;
- }
- fail("null failure");
- }
-
- public function testNotNull():void {
- var obj:Object = new Object();
- assertNotNull(obj);
- }
-
- public function testNotNullFailure():void {
- try {
- assertNotNull(null);
- }
- catch(e:Error) {
- return;
- }
- fail("not null failed");
- }
-
- public function testNotNullMessage():void {
- var obj:Object = new Object();
- assertNotNull("not null", obj);
- }
-
- public function testSame():void {
- var obj:Object = new Object();
- assertSame(obj, obj);
- }
-
- public function testSameFailure():void {
- try {
- assertSame(new Object(), new Object());
- }
- catch(e:Error) {
- return;
- }
- fail("same failure");
- }
-
- public function testNotSame():void {
- var obj1:Object = new Object();
- var obj2:Object = new Object();
- assertNotSame(obj1, obj2);
- }
-
- public function testNotSameFailure():void {
- var obj1:Object = new Object();
- try {
- assertNotSame(obj1, obj1);
- }
- catch(e:Error) {
- return;
- }
- fail("not same failure");
- }
-
- public function testNotSameMessage():void {
- var obj1:Object = new Object();
- var obj2:Object = new Object();
- assertNotSame("not same message", obj1, obj2);
- }
- }
-}
\ No newline at end of file
Deleted: trunk/framework/as3/asunit/framework/MockData.xml
===================================================================
--- trunk/framework/as3/asunit/framework/MockData.xml 2006-09-20 18:16:23 UTC (rev 103)
+++ trunk/framework/as3/asunit/framework/MockData.xml 2006-09-20 18:20:59 UTC (rev 104)
@@ -1,8 +0,0 @@
-<books>
- <book publisher="Addison-Wesley" name="Design Patterns" />
- <book publisher="Addison-Wesley" name="The Pragmatic Programmer" />
- <book publisher="Addison-Wesley" name="Test Driven Development" />
- <book publisher="Addison-Wesley" name="Refactoring to Patterns" />
- <book publisher="O'Reilly Media" name="The Cathedral & the Bazaar" />
- <book publisher="O'Reilly Media" name="Unit Test Frameworks" />
-</books>
\ No newline at end of file
Deleted: trunk/framework/as3/asunit/framework/TestCaseMock.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCaseMock.as 2006-09-20 18:16:23 UTC (rev 103)
+++ trunk/framework/as3/asunit/framework/TestCaseMock.as 2006-09-20 18:20:59 UTC (rev 104)
@@ -1,24 +0,0 @@
-package asunit.framework {
-
- public class TestCaseMock extends TestCase {
- public var testMethod1Run:Boolean;
- public var testMethod2Run:Boolean;
- public var testMethod3Run:Boolean;
-
- public function TestCaseMock(methodName:String = null) {
- super(methodName);
- }
-
- public function testMethod1():void {
- testMethod1Run = true;
- }
-
- public function testMethod2():void {
- testMethod2Run = true;
- }
-
- public function testMethod3():void {
- testMethod3Run = true;
- }
- }
-}
\ No newline at end of file
Deleted: trunk/framework/as3/asunit/framework/TestCaseTest.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCaseTest.as 2006-09-20 18:16:23 UTC (rev 103)
+++ trunk/framework/as3/asunit/framework/TestCaseTest.as 2006-09-20 18:20:59 UTC (rev 104)
@@ -1,45 +0,0 @@
-package asunit.framework {
-
- public class TestCaseTest extends TestCase {
-
- public function TestCaseTest(testMethod:String = null) {
- super(testMethod);
- }
-
- public function testInstantiated():void {
- assertTrue(this is TestCase);
- }
-
- public function testCustomConstructor():void {
- var mock:TestCaseMock = new TestCaseMock("testMethod1");
- mock.run();
- assertTrue("testMethod1Run", mock.testMethod1Run);
- assertFalse("testMethod2Run", mock.testMethod2Run);
- assertFalse("testMethod3Run", mock.testMethod3Run);
- }
-
- public function testCustomConstructor2():void {
- var mock:TestCaseMock = new TestCaseMock("testMethod1, testMethod3");
- mock.run();
- assertTrue("testMethod1Run", mock.testMethod1Run);
- assertFalse("testMethod2Run", mock.testMethod2Run);
- assertTrue("testMethod3Run", mock.testMethod3Run);
- }
-
- public function testCustomConstructor3():void {
- var mock:TestCaseMock = new TestCaseMock("testMethod1,testMethod3");
- mock.run();
- assertTrue("testMethod1Run", mock.testMethod1Run);
- assertFalse("testMethod2Run", mock.testMethod2Run);
- assertTrue("testMethod3Run", mock.testMethod3Run);
- }
-
- public function testCustomConstructor4():void {
- var mock:TestCaseMock = new TestCaseMock("testMethod1, testMethod2,testMethod3");
- mock.run();
- assertTrue("testMethod1Run", mock.testMethod1Run);
- assertTrue("testMethod2Run", mock.testMethod2Run);
- assertTrue("testMethod3Run", mock.testMethod3Run);
- }
- }
-}
\ No newline at end of file
Deleted: trunk/framework/as3/asunit/framework/TestFailureTest.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestFailureTest.as 2006-09-20 18:16:23 UTC (rev 103)
+++ trunk/framework/as3/asunit/framework/TestFailureTest.as 2006-09-20 18:20:59 UTC (rev 104)
@@ -1,14 +0,0 @@
-package asunit.framework {
-
- public class TestFailureTest extends TestCase {
-
- public function TestFailureTest(testMethod:String = null) {
- super(testMethod);
- }
-
- public function testInstantiated():void {
- var failure:TestFailure = new TestFailure(this, new Error());
- assertTrue(failure is TestFailure);
- }
- }
-}
\ No newline at end of file
Deleted: trunk/framework/as3/asunit/framework/VisualTestCaseTest.as
===================================================================
--- trunk/framework/as3/asunit/framework/VisualTestCaseTest.as 2006-09-20 18:16:23 UTC (rev 103)
+++ trunk/framework/as3/asunit/framework/VisualTestCaseTest.as 2006-09-20 18:20:59 UTC (rev 104)
@@ -1,43 +0,0 @@
-package asunit.framework {
- import flash.display.Sprite;
-
- public class VisualTestCaseTest extends TestCase {
- private var instance:Sprite;
-
- public function VisualTestCaseTest(testMethod:String = null) {
- super(testMethod);
- }
-
- protected override function setUp():void {
- instance = new Sprite();
- addChild(instance);
- }
-
- protected override function tearDown():void {
- removeChild(instance);
- }
-
- public function testInstance():void {
- assertTrue(instance is Sprite);
- }
-
- public function testSize():void {
- assertTrue(instance.width == 0);
- assertTrue(instance.height == 0);
- }
-
- public function testDrawnSize():void {
- instance.graphics.beginFill(0xFF0000);
- instance.graphics.drawRect(0, 0, 10, 20);
-
- assertTrue(instance.width == 10);
- assertTrue(instance.height == 20);
- }
-
- public function testSecondSize():void {
- assertTrue(instance.width == 0);
- assertTrue(instance.height == 0);
- }
-
- }
-}
\ No newline at end of file
Deleted: trunk/framework/as3/asunit/runner/BaseTestRunnerMock.as
===================================================================
--- trunk/framework/as3/asunit/runner/BaseTestRunnerMock.as 2006-09-20 18:16:23 UTC (rev 103)
+++ trunk/framework/as3/asunit/runner/BaseTestRunnerMock.as 2006-09-20 18:20:59 UTC (rev 104)
@@ -1,6 +0,0 @@
-package asunit.runner {
-
- public class BaseTestRunnerMock extends BaseTestRunner {
-
- }
-}
\ No newline at end of file
Deleted: trunk/framework/as3/asunit/textui/AllTests.as
===================================================================
--- trunk/framework/as3/asunit/textui/AllTests.as 2006-09-20 18:16:23 UTC (rev 103)
+++ trunk/framework/as3/asunit/textui/AllTests.as 2006-09-20 18:20:59 UTC (rev 104)
@@ -1,11 +0,0 @@
-package asunit.textui {
- import asunit.framework.TestSuite;
- import asunit.textui.TestRunnerTest;
-
- public class AllTests extends TestSuite {
-
- public function AllTests() {
- addTest(new asunit.textui.TestRunnerTest());
- }
- }
-}
Deleted: trunk/framework/as3/asunit/textui/TestRunnerTest.as
===================================================================
--- trunk/framework/as3/asunit/textui/TestRunnerTest.as 2006-09-20 18:16:23 UTC (rev 103)
+++ trunk/framework/as3/asunit/textui/TestRunnerTest.as 2006-09-20 18:20:59 UTC (rev 104)
@@ -1,55 +0,0 @@
-package asunit.textui {
- import asunit.framework.TestCase;
- import flash.utils.setTimeout;
- import flash.events.Event;
- import flash.errors.IllegalOperationError;
-
- public class TestRunnerTest extends TestCase {
- private var instance:TestRunner;
-
- public function TestRunnerTest(testMethod:String = null) {
- super(testMethod);
- }
-
- protected override function setUp():void {
- instance = new TestRunner();
- addChild(instance);
- }
-
- protected override function tearDown():void {
- removeChild(instance);
- instance = null;
- }
-
- public function testInstantiated():void {
- assertTrue("TestRunner instantiated with: " + instance, instance is TestRunner);
- }
-
- public function testAsync():void {
- var handler:Function = addAsync(asyncCompleteHandler);
- setTimeout(handler, 400, new Event(Event.ACTIVATE));
- }
-
- public function asyncCompleteHandler(event:Event):void {
-// throw new IllegalOperationError("what the heck?");
- }
-
- public function testAsync2():void {
- var handler:Function = addAsync(async2CompleteHandler);
- setTimeout(handler, 40);
- }
-
- public function async2CompleteHandler():void {
-// fail("test async complete failed");
- }
-
- public function testSomethingComplete():void {
- }
-
- public function testSomethingElse():void {
- }
-
- public function testAnotherThing():void {
- }
- }
-}
Deleted: trunk/framework/as3/asunit/textui/TestRunnerTestCaseMock.as
===================================================================
--- trunk/framework/as3/asunit/textui/TestRunnerTestCaseMock.as 2006-09-20 18:16:23 UTC (rev 103)
+++ trunk/framework/as3/asunit/textui/TestRunnerTestCaseMock.as 2006-09-20 18:20:59 UTC (rev 104)
@@ -1,30 +0,0 @@
-package asunit.textui {
-
- import asunit.framework.TestCase;
-
- public class TestRunnerTestCaseMock extends TestCase {
- public var testMethod1Run:Boolean;
- public var testMethod2Run:Boolean;
- public var testMethod3Run:Boolean;
-
- public function TestRunnerTestCaseMock(methodName:String = null) {
- super(methodName);
- }
-
- public function testMethod1():void {
- testMethod1Run = true;
- }
-
- public function testMethod1Completed():void {
- trace("testMethod1Handler called");
- }
-
- public function testMethod2():void {
- testMethod2Run = true;
- }
-
- public function testMethod3():void {
- testMethod3Run = true;
- }
- }
-}
\ No newline at end of file
Deleted: trunk/framework/as3/asunit/util/AllTests.as
===================================================================
--- trunk/framework/as3/asunit/util/AllTests.as 2006-09-20 18:16:23 UTC (rev 103)
+++ trunk/framework/as3/asunit/util/AllTests.as 2006-09-20 18:20:59 UTC (rev 104)
@@ -1,11 +0,0 @@
-package asunit.util {
- import asunit.framework.TestSuite;
- import asunit.util.ArrayIteratorTest;
-
- public class AllTests extends TestSuite {
-
- public function AllTests() {
- addTest(new asunit.util.ArrayIteratorTest());
- }
- }
-}
Deleted: trunk/framework/as3/asunit/util/ArrayIteratorTest.as
===================================================================
--- trunk/framework/as3/asunit/util/ArrayIteratorTest.as 2006-09-20 18:16:23 UTC (rev 103)
+++ trunk/framework/as3/asunit/util/ArrayIteratorTest.as 2006-09-20 18:20:59 UTC (rev 104)
@@ -1,65 +0,0 @@
-package asunit.util {
- import asunit.framework.TestCase;
-
- public class ArrayIteratorTest extends TestCase {
- private var itr:ArrayIterator;
-
- public function ArrayIteratorTest(testMethod:String = null) {
- super(testMethod);
- }
-
- protected override function setUp():void {
- itr = new ArrayIterator(getSimpleArray(5));
- }
-
- private function getSimpleArray(count:Number):Array {
- var arr:Array = new Array();
- for(var i:Number = 0; i < count; i++) {
- arr.push("item-" + i);
- }
- return arr;
- }
-
- protected override function tearDown():void {
- itr = null;
- }
-
- public function testInstantiated():void {
- assertTrue("ArrayIterator instantiated", itr is ArrayIterator);
- }
-
- public function testHasNext():void {
- assertTrue(itr.hasNext());
- }
-
- public function testNext():void {
- assertEquals("item-0", itr.next());
- }
-
- public function testNextTwice():void {
- assertEquals("item-0", itr.next());
- assertEquals("item-1", itr.next());
- }
-
- public function testLast():void {
- assertTrue(itr.hasNext());
- assertEquals("item-0", itr.next());
- assertTrue(itr.hasNext());
- assertEquals("item-1", itr.next());
- assertTrue(itr.hasNext());
- assertEquals("item-2", itr.next());
- assertTrue(itr.hasNext());
- assertEquals("item-3", itr.next());
- assertTrue(itr.hasNext());
- assertEquals("item-4", itr.next());
- assertFalse(itr.hasNext());
- }
-
- public function testReset():void {
- testLast();
- itr.reset();
- assertTrue(itr.hasNext());
- assertEquals("item-0", itr.next());
- }
- }
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-20 21:21:44
|
Revision: 112
http://svn.sourceforge.net/asunit/?rev=112&view=rev
Author: lukebayes
Date: 2006-09-20 14:21:37 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
got async method working better
Modified Paths:
--------------
trunk/framework/as3/AsUnitTestRunner.as
trunk/framework/as3/asunit/framework/TestCase.as
Added Paths:
-----------
trunk/framework/as3/asunit/framework/TestCaseExample.as
Removed Paths:
-------------
trunk/framework/as3/asunit/AllTests.as
Modified: trunk/framework/as3/AsUnitTestRunner.as
===================================================================
--- trunk/framework/as3/AsUnitTestRunner.as 2006-09-20 18:50:50 UTC (rev 111)
+++ trunk/framework/as3/AsUnitTestRunner.as 2006-09-20 21:21:37 UTC (rev 112)
@@ -1,13 +1,13 @@
package {
+ import asunit.framework.TestCaseExample;
import asunit.textui.TestRunner;
- import asunit.framework.TestCaseTest;
import asunit.textui.TestRunnerTest;
public class AsUnitTestRunner extends TestRunner {
public function AsUnitTestRunner() {
- start(AllTests, null, TestRunner.SHOW_TRACE);
-// start(TestRunnerTest);
+// start(AllTests, null, TestRunner.SHOW_TRACE);
+ start(TestCaseExample);
}
}
}
Deleted: trunk/framework/as3/asunit/AllTests.as
===================================================================
--- trunk/framework/as3/asunit/AllTests.as 2006-09-20 18:50:50 UTC (rev 111)
+++ trunk/framework/as3/asunit/AllTests.as 2006-09-20 21:21:37 UTC (rev 112)
@@ -1,15 +0,0 @@
-package asunit {
- import asunit.framework.TestSuite;
- import asunit.framework.AllTests;
- import asunit.textui.AllTests;
- import asunit.util.AllTests;
-
- public class AllTests extends TestSuite {
-
- public function AllTests() {
- addTest(new asunit.framework.AllTests());
- addTest(new asunit.textui.AllTests());
- addTest(new asunit.util.AllTests());
- }
- }
-}
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2006-09-20 18:50:50 UTC (rev 111)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2006-09-20 21:21:37 UTC (rev 112)
@@ -79,7 +79,7 @@
/**
* the name of the test case
*/
- protected var DEFAULT_TIMEOUT:int = 500;
+ protected static var DEFAULT_TIMEOUT:int = 500;
protected var fName:String;
protected var result:TestResult;
protected var testMethods:Array;
@@ -277,10 +277,10 @@
return context;
}
- protected function addAsync(handler:Function):Function {
+ protected function addAsync(handler:Function, timeout:int=500):Function {
methodIsAsynchronous = true;
- var context:Object = this;
- asyncMethodTimeoutId = setTimeout(timeoutHandler, DEFAULT_TIMEOUT);
+ var context:TestCase = this;
+ asyncMethodTimeoutId = setTimeout(timeoutHandler, timeout);
return function(args:*):* {
try {
handler.apply(context, arguments);
@@ -289,10 +289,13 @@
context.result.addFailure(context, e);
}
catch(ioe:IllegalOperationError) {
+ trace('foo'); // this trace needs to be here?! Why?!
context.result.addError(context, ioe);
}
- context.methodIsAsynchronous = false;
- context.runBare();
+ finally {
+ context.methodIsAsynchronous = false;
+ context.runBare();
+ }
}
}
Added: trunk/framework/as3/asunit/framework/TestCaseExample.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCaseExample.as (rev 0)
+++ trunk/framework/as3/asunit/framework/TestCaseExample.as 2006-09-20 21:21:37 UTC (rev 112)
@@ -0,0 +1,77 @@
+package asunit.framework {
+ import asunit.framework.TestCase;
+ import flash.display.Sprite;
+ import flash.events.Event;
+ import flash.events.IEventDispatcher;
+ import flash.events.EventDispatcher;
+ import flash.utils.setTimeout;
+
+ // These should always end with Test, the example
+ // doesn't because we don't want TestSuites in this
+ // directory.
+ public class TestCaseExample extends TestCase {
+ private var date:Date;
+ private var sprite:Sprite;
+
+ // TestCase constructors must be implemented as follows
+ // so that we can execute a single method on them from
+ // the TestRunner
+ public function TestCaseExample(testMethod:String = null) {
+ super(testMethod);
+ }
+
+ // This method will be called before every test method
+ protected override function setUp():void {
+ date = new Date();
+// sprite = new Sprite();
+// addChild(sprite);
+ }
+
+ // This method will be called after every test method
+ // but only if we're executing the entire TestCase,
+ // the tearDown method won't be called if we're
+ // calling start(MyTestCase, "someMethod");
+ protected override function tearDown():void {
+// removeChild(sprite);
+// sprite = null;
+ date = null;
+ }
+
+ // This is auto-created by the XULUI and ensures that
+ // our objects are actually created as we expect.
+ public function testInstantiated():void {
+ assertTrue("Date instantiated", date is Date);
+// assertTrue("Sprite instantiated", sprite is Sprite);
+ }
+
+ // This is an example of a typical test method
+ public function testMonthGetterSetter():void {
+ date.month = 1;
+ assertEquals(1, date.month);
+ }
+
+ // This is an asynchronous test method
+ public function testAsyncFeature():void {
+ // create a new object that dispatches events...
+ var dispatcher:IEventDispatcher = new EventDispatcher();
+ // get a TestCase async event handler reference
+ var handler:Function = addAsync(changeHandler);
+ // subscribe to your event dispatcher using the returned handler
+ dispatcher.addEventListener(Event.CHANGE, handler);
+ // cause the event to be dispatched.
+// dispatcher.dispatchEvent(new Event(Event.CHANGE));
+ setTimeout(dispatcher.dispatchEvent, 200, new Event(Event.CHANGE));
+ }
+
+ protected function changeHandler(event:Event):void {
+ assertEquals(Event.CHANGE, event.type);
+ }
+
+ public function testAsyncFeatureTimeout():void {
+ var dispatcher:IEventDispatcher = new EventDispatcher();
+ var handler:Function = addAsync(changeHandler, 100);
+ dispatcher.addEventListener(Event.CHANGE, handler);
+ dispatcher.dispatchEvent(new Event(Event.CHANGE));
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-10-12 06:21:11
|
Revision: 127
http://svn.sourceforge.net/asunit/?rev=127&view=rev
Author: lukebayes
Date: 2006-10-11 23:21:07 -0700 (Wed, 11 Oct 2006)
Log Message:
-----------
Moved base flex application to textui package
Added Paths:
-----------
trunk/framework/as3/asunit/textui/FlexRunner.as
Removed Paths:
-------------
trunk/framework/as3/AsUnitApplication.as
Deleted: trunk/framework/as3/AsUnitApplication.as
===================================================================
--- trunk/framework/as3/AsUnitApplication.as 2006-10-12 06:13:25 UTC (rev 126)
+++ trunk/framework/as3/AsUnitApplication.as 2006-10-12 06:21:07 UTC (rev 127)
@@ -1,20 +0,0 @@
-package {
- import asunit.framework.TestResult;
- import mx.core.Application;
- import asunit.textui.TestRunner;
- import asunit.textui.FlexTestRunner;
-
- public class AsUnitApplication extends Application {
- protected var runner:TestRunner;
-
- override protected function createChildren():void {
- super.createChildren();
- runner = new FlexTestRunner();
- rawChildren.addChild(runner);
- }
-
- public function start(testCase:Class, testMethod:String = null, showTrace:Boolean = false):TestResult {
- return runner.start(testCase, testMethod, showTrace);
- }
- }
-}
Added: trunk/framework/as3/asunit/textui/FlexRunner.as
===================================================================
--- trunk/framework/as3/asunit/textui/FlexRunner.as (rev 0)
+++ trunk/framework/as3/asunit/textui/FlexRunner.as 2006-10-12 06:21:07 UTC (rev 127)
@@ -0,0 +1,19 @@
+package asunit.textui {
+ import asunit.framework.TestResult;
+
+ import mx.core.Application;
+
+ public class FlexRunner extends Application {
+ protected var runner:TestRunner;
+
+ override protected function createChildren():void {
+ super.createChildren();
+ runner = new FlexTestRunner();
+ rawChildren.addChild(runner);
+ }
+
+ public function start(testCase:Class, testMethod:String = null, showTrace:Boolean = false):TestResult {
+ return runner.start(testCase, testMethod, showTrace);
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-11-07 00:01:35
|
Revision: 132
http://svn.sourceforge.net/asunit/?rev=132&view=rev
Author: lukebayes
Date: 2006-11-06 16:01:21 -0800 (Mon, 06 Nov 2006)
Log Message:
-----------
Added custom Implementation of LayoutManager that will prevent Validation of Flex components after tearDown has been called, this greatly speeds up the execution of larger test suites
Modified Paths:
--------------
trunk/framework/as3/AsUnitTestRunner.as
trunk/framework/as3/asunit/framework/TestCase.as
Added Paths:
-----------
trunk/framework/as3/mx/
trunk/framework/as3/mx/managers/
trunk/framework/as3/mx/managers/ILayoutManagerClient.as
trunk/framework/as3/mx/managers/LayoutManager.as
trunk/framework/as3/mx/managers/LayoutManagerTest.as
trunk/framework/as3/mx/managers/MockContainer.as
Modified: trunk/framework/as3/AsUnitTestRunner.as
===================================================================
--- trunk/framework/as3/AsUnitTestRunner.as 2006-10-23 19:12:48 UTC (rev 131)
+++ trunk/framework/as3/AsUnitTestRunner.as 2006-11-07 00:01:21 UTC (rev 132)
@@ -1,12 +1,10 @@
package {
import asunit.textui.TestRunner;
- import asunit.framework.TestCaseTest;
public class AsUnitTestRunner extends TestRunner {
public function AsUnitTestRunner() {
start(AllTests, null, TestRunner.SHOW_TRACE);
-// start(TestCaseTest, "testCustomConstructor");
}
}
}
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2006-10-23 19:12:48 UTC (rev 131)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2006-11-07 00:01:21 UTC (rev 132)
@@ -13,6 +13,7 @@
import flash.events.TimerEvent;
import flash.utils.setTimeout;
import flash.utils.clearTimeout;
+ import mx.managers.LayoutManager;
/**
* A test case defines the fixture to run multiple tests. To define a test case<br>
@@ -309,6 +310,7 @@
}
if(!runSingle) {
tearDown();
+ LayoutManager.getInstance().resetAll();
}
setTimeout(runBare, 5);
}
Added: trunk/framework/as3/mx/managers/ILayoutManagerClient.as
===================================================================
--- trunk/framework/as3/mx/managers/ILayoutManagerClient.as (rev 0)
+++ trunk/framework/as3/mx/managers/ILayoutManagerClient.as 2006-11-07 00:01:21 UTC (rev 132)
@@ -0,0 +1,161 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (C) 2003-2006 Adobe Macromedia Software LLC and its licensors.
+// All Rights Reserved. The following is Source Code and is subject to all
+// restrictions on such code as contained in the End User License Agreement
+// accompanying this product.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.managers
+{
+
+import flash.events.IEventDispatcher;
+import mx.core.mx_internal;
+
+use namespace mx_internal;
+
+/**
+ * The ILayoutManagerClient interface defines the interface
+ * that a component must implement to participate in the
+ * LayoutManager's commit/measurement/layout sequence.
+ *
+ * <p>Objects that implement this interface can be passed to the
+ * LayoutManager's <code>invalidateProperties()</code> method.
+ * When the LayoutManager reaches the commit properties phase,
+ * the LayoutManager invokes this object's <code>validateProperties()</code>
+ * method.</p>
+ *
+ * <p>Similarly, if an object is passed to the LayoutManager's
+ * <code>invalidateSize()</code> method, then the LayoutManager
+ * calls that object's <code>validateSize()</code> method
+ * during its measurement phase, and if an object is passed
+ * to LayoutManager's <code>invalidateDisplayList()</code> method,
+ * then the LayoutManager calls its <code>validateDisplayList()</code> method
+ * during the layout phase.</p>
+ *
+ * <p>The ILayoutManagerClient interface is implemented by the UIComponent
+ * and ProgrammaticSkin classes.</p>
+ */
+public interface ILayoutManagerClient extends IEventDispatcher
+{
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // initialized
+ //----------------------------------
+
+ /**
+ * A flag that determines if an object has been through all three phases
+ * of layout validation (provided that any were required)
+ * This flag should only be modified by the LayoutManager.
+ */
+ function get initialized():Boolean;
+
+ /**
+ * @private
+ */
+ function set initialized(value:Boolean):void;
+
+ //----------------------------------
+ // nestLevel
+ //----------------------------------
+
+ /**
+ * The top-level SystemManager has a nestLevel of 1.
+ * Its immediate children (the top-level Application and any pop-up
+ * windows) have a <code>nestLevel</code> of 2.
+ * Their children have a <code>nestLevel</code> of 3, and so on.
+ *
+ * The <code>nestLevel</code> is used to sort ILayoutManagerClients
+ * during the measurement and layout phases.
+ * During the commit phase, the LayoutManager commits properties on clients
+ * in order of decreasing <code>nestLevel</code>, so that an object's
+ * children have already had their properties committed before Flex
+ * commits properties on the object itself.
+ * During the measurement phase, the LayoutManager measures clients
+ * in order of decreasing <code>nestLevel</code>, so that an object's
+ * children have already been measured before Flex measures
+ * the object itself.
+ * During the layout phase, the LayoutManager lays out clients
+ * in order of increasing <code>nestLevel</code>, so that an object
+ * has a chance to set the sizes of its children before the child
+ * objects are asked to position and size their children.
+ */
+ function get nestLevel():int;
+
+ /**
+ * @private
+ */
+ function set nestLevel(value:int):void;
+
+ //----------------------------------
+ // processedDescriptors
+ //----------------------------------
+
+ /**
+ * @copy mx.core.UIComponent#processedDescriptors
+ */
+ function get processedDescriptors():Boolean;
+
+ /**
+ * @private
+ */
+ function set processedDescriptors(value:Boolean):void;
+
+ //----------------------------------
+ // updateCompletePendingFlag
+ //----------------------------------
+
+ /**
+ * A flag that determines if an object is waiting to have its
+ * <code>updateComplete</code> event dispatched.
+ * This flag should only be modified by the LayoutManager.
+ */
+ function get updateCompletePendingFlag():Boolean;
+
+ /**
+ * @private
+ */
+ function set updateCompletePendingFlag(value:Boolean):void;
+
+ //--------------------------------------------------------------------------
+ //
+ // Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Validates the properties of a component.
+ * If the <code>LayoutManager.invalidateProperties()</code> method is called with
+ * this ILayoutManagerClient, then the <code>validateProperties()</code> method
+ * is called when it's time to commit property values.
+ */
+ function validateProperties():void;
+
+ /**
+ * Validates the measured size of the component
+ * If the <code>LayoutManager.invalidateSize()</code> method is called with
+ * this ILayoutManagerClient, then the <code>validateSize()</code> method
+ * is called when it's time to do measurements.
+ *
+ * @param recursive If <code>true</code>, call this method
+ * on the objects children.
+ */
+ function validateSize(recursive:Boolean=false):void;
+
+ /**
+ * Validates the position and size of children and draws other
+ * visuals.
+ * If the <code>LayoutManager.invalidateDisplayList()</code> method is called with
+ * this ILayoutManagerClient, then the <code>validateDisplayList()</code> method
+ * is called when it's time to update the display list.
+ */
+ function validateDisplayList():void;
+}
+
+}
Added: trunk/framework/as3/mx/managers/LayoutManager.as
===================================================================
--- trunk/framework/as3/mx/managers/LayoutManager.as (rev 0)
+++ trunk/framework/as3/mx/managers/LayoutManager.as 2006-11-07 00:01:21 UTC (rev 132)
@@ -0,0 +1,945 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (C) 2003-2006 Adobe Macromedia Software LLC and its licensors.
+// All Rights Reserved. The following is Source Code and is subject to all
+// restrictions on such code as contained in the End User License Agreement
+// accompanying this product.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.managers
+{
+
+import flash.display.Stage;
+import flash.events.Event;
+import flash.events.EventDispatcher;
+import mx.core.Application;
+import mx.core.UIComponent;
+import mx.core.mx_internal;
+import mx.events.FlexEvent;
+import mx.managers.layoutClasses.PriorityQueue;
+
+use namespace mx_internal;
+
+/**
+ * The LayoutManager is the engine behind
+ * Flex's measurement and layout strategy.
+ * Layout is performed in three phases; commit, measurement, and layout.
+ *
+ * <p>Each phase is distinct from the others and all UIComponents of
+ * one phase are processed prior to moving on to the next phase.
+ * During the processing of UIComponents in a phase, requests for
+ * UIComponents to get re-processed by some phase may occur.
+ * These requests are queued and are only processed
+ * during the next run of the phase.</p>
+ *
+ * <p>The <b>commit</b> phase begins with a call to
+ * <code>validateProperties()</code>, which walks through a list
+ * (sorted by nesting level) of objects calling each object's
+ * <a href="../core/UIComponent.html#validateProperties()">
+ * <code>validateProperties()</code></a>method.</p>
+ *
+ * <p>The objects in the list are processed by nesting order,
+ * with the <b>most</b> deeply nested object accessed first.
+ * This can also be referred to as bottom-up inside-out ordering.</p>
+ *
+ * <p>This phase allows components whose contents depend on property
+ * settings to configure themselves prior to the measurement
+ * and the layout phases.
+ * For the sake of performance, sometimes a component's property setter
+ * method does not do all the work to update to the new property value.
+ * Instead, the property setter calls the <code>invalidateProperties()</code>
+ * method, deferring the work until this phase runs.
+ * This prevents unnecessary work if the property is set multiple times.</p>
+ *
+ * <p>The <b>measurement</b> phase begins with a call to
+ * <code>validateSize()</code>, which walks through a list
+ * (sorted by nesting level) of objects calling each object's
+ * <a href="../core/UIComponent.html#validateSize()"><code>validateSize()</code></a>
+ * method to determine if the object has changed in size.</p>
+ *
+ * <p>If an object's <a href="../core/UIComponent.html#invalidateSize()">
+ * <code>invalidateSize()</code></a> method was previously called,
+ * then the <code>validateSize()</code> method is called.
+ * If the size or position of the object was changed as a result of the
+ * <code>validateSize()</code> call, then the object's
+ * <a href="../core/UIComponent.html#invalidateDisplayList()">
+ * <code>invalidateDisplayList()</code></a> method is called, thus adding
+ * the object to the processing queue for the next run of the layout phase.
+ * Additionally, the object's parent is marked for both measurement
+ * and layout phases, by calling
+ * <a href="../core/UIComponent.html#invalidateSize()">
+ * <code>invalidateSize()</code></a> and
+ * <a href="../core/UIComponent.html#invalidateDisplayList()">
+ * <code>invalidateDisplayList()</code></a> respectively.</p>
+ *
+ * <p>The objects in the list are processed by nesting order,
+ * with the <b>most</b> deeply nested object accessed first.
+ * This can also be referred to as bottom-up inside-out ordering.</p>
+ *
+ * <p>The <b>layout</b> phase begins with a call to the
+ * <code>validateDisplayList()</code> method, which walks through a list
+ * (reverse sorted by nesting level) of objects calling each object's
+ * <a href="../core/UIComponent.html#validateDisplayList()">
+ * <code>validateDisplayList()</code></a> method to request the object to size
+ * and position all components contained within it (i.e. its children).</p>
+ *
+ * <p>If an object's <a href="../core/UIComponent.html#invalidateDisplayList()">
+ * <code>invalidateDisplayList()</code></a> method was previously called,
+ * then <code>validateDisplayList()</code> method for the object is called.</p>
+ *
+ * <p>The objects in the list are processed in reversed nesting order,
+ * with the <b>least</b> deeply nested object accessed first.
+ * This can also be referred to as top-down or outside-in ordering.</p>
+ *
+ * <p>In general, components do not override the <code>validateProperties()</code>,
+ * <code>validateSize()</code>, or <code>validateDisplayList()</code> methods.
+ * In the case of UIComponents, most components override the
+ * <code>commitProperties()</code>, <code>measure()</code>, or
+ * <code>updateDisplayList()</code> methods, which are called
+ * by the <code>validateProperties()</code>,
+ * <code>validateSize()</code>, or
+ * <code>validateDisplayList()</code> methods, respectively.</p>
+ *
+ * <p>At application startup, a single instance of the LayoutManager is created
+ * and stored in the <code>UIComponent.layoutManager</code> property.
+ * All components are expected to use that instance.
+ * If you do not have access to the UIComponent object,
+ * you can also access the LayoutManager using the static
+ * <code>LayoutManager.getInstance()</code> method.</p>
+ */
+public class LayoutManager extends EventDispatcher
+{
+
+ //--------------------------------------------------------------------------
+ //
+ // Class variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ * The sole instance of this singleton class.
+ */
+ private static var instance:LayoutManager;
+
+ //--------------------------------------------------------------------------
+ //
+ // Class methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Returns the sole instance of this singleton class,
+ * creating it if it does not already exist.
+ */
+ public static function getInstance():LayoutManager
+ {
+ if (!instance)
+ instance = new LayoutManager();
+
+ return instance;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructor.
+ */
+ public function LayoutManager()
+ {
+ super();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ * A queue of objects that need to dispatch updateComplete events
+ * when invalidation processing is complete
+ */
+ private var updateCompleteQueue:PriorityQueue = new PriorityQueue();
+
+ /**
+ * @private
+ * A queue of objects to be processed during the first phase
+ * of invalidation processing, when an ILayoutManagerClient has
+ * its validateProperties() method called (which in a UIComponent
+ * calls commitProperties()).
+ * Objects are added to this queue by invalidateProperties()
+ * and removed by validateProperties().
+ */
+ private var invalidatePropertiesQueue:PriorityQueue = new PriorityQueue();
+
+ /**
+ * @private
+ * A flag indicating whether there are objects
+ * in the invalidatePropertiesQueue.
+ * It is set true by invalidateProperties()
+ * and set false by validateProperties().
+ */
+ private var invalidatePropertiesFlag:Boolean = false;
+
+ // flag when in validateClient to check the properties queue again
+ private var invalidateClientPropertiesFlag:Boolean = false;
+
+ /**
+ * @private
+ * A queue of objects to be processed during the second phase
+ * of invalidation processing, when an ILayoutManagerClient has
+ * its validateSize() method called (which in a UIComponent
+ * calls measure()).
+ * Objects are added to this queue by invalidateSize().
+ * and removed by validateSize().
+ */
+ private var invalidateSizeQueue:PriorityQueue = new PriorityQueue();
+
+ /**
+ * @private
+ * A flag indicating whether there are objects
+ * in the invalidateSizeQueue.
+ * It is set true by invalidateSize()
+ * and set false by validateSize().
+ */
+ private var invalidateSizeFlag:Boolean = false;
+
+ // flag when in validateClient to check the size queue again
+ private var invalidateClientSizeFlag:Boolean = false;
+
+ /**
+ * @private
+ * A queue of objects to be processed during the third phase
+ * of invalidation processing, when an ILayoutManagerClient has
+ * its validateDisplayList() method called (which in a
+ * UIComponent calls updateDisplayList()).
+ * Objects are added to this queue by invalidateDisplayList()
+ * and removed by validateDisplayList().
+ */
+ private var invalidateDisplayListQueue:PriorityQueue = new PriorityQueue();
+
+ /**
+ * @private
+ * A flag indicating whether there are objects
+ * in the invalidateDisplayListQueue.
+ * It is set true by invalidateDisplayList()
+ * and set false by validateDisplayList().
+ */
+ private var invalidateDisplayListFlag:Boolean = false;
+
+ /**
+ * @private
+ */
+ private var callLaterObject:UIComponent;
+
+ /**
+ * @private
+ */
+ private var callLaterPending:Boolean = false;
+
+ /**
+ * @private
+ */
+ private var originalFrameRate:Number;
+
+ /**
+ * @private
+ * used in validateClient to quickly estimate whether we have to
+ * search the queues again
+ */
+ private var targetLevel:int = int.MAX_VALUE;
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // usePhasedInstantiation
+ //----------------------------------
+
+ /**
+ * @private
+ * Storage for the usePhasedInstantiation property.
+ */
+ private var _usePhasedInstantiation:Boolean = false;
+
+ /**
+ * A flag that indicates whether the LayoutManager allows screen updates
+ * between phases.
+ * If <code>true</code>, measurement and layout are done in phases, one phase
+ * per screen update.
+ * All components have their <code>validateProperties()</code>
+ * and <code>commitProperties()</code> methods
+ * called until all their properties are validated.
+ * The screen will then be updated.
+ *
+ * <p>Then all components will have their <code>validateSize()</code>
+ * and <code>measure()</code>
+ * methods called until all components have been measured, then the screen
+ * will be updated again. </p>
+ *
+ * <p>Finally, all components will have their
+ * <code>validateDisplayList()</code> and
+ * <code>updateDisplayList()</code> methods called until all components
+ * have been validated, and the screen will be updated again.
+ * If in the validation of one phase, an earlier phase gets invalidated,
+ * the LayoutManager starts over.
+ * This is more efficient when large numbers of components
+ * are being created an initialized. The framework is responsible for setting
+ * this property.</p>
+ *
+ * <p>If <code>false</code>, all three phases are completed before the screen is updated.</p>
+ */
+ public function get usePhasedInstantiation():Boolean
+ {
+ return _usePhasedInstantiation;
+ }
+
+ /**
+ * @private
+ */
+ public function set usePhasedInstantiation(value:Boolean):void
+ {
+ if (_usePhasedInstantiation != value)
+ {
+ _usePhasedInstantiation = value;
+
+ // While we're doing phased instantiation, temporarily increase
+ // the frame rate. That will cause the enterFrame and render
+ // events to fire more promptly, which improves performance.
+ var stage:Stage = SystemManager.topLevelSystemManagers[0].stage;
+ if (value)
+ {
+ originalFrameRate = stage.frameRate;
+ stage.frameRate = 1000;
+ }
+ else
+ {
+ stage.frameRate = originalFrameRate;
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Methods: Invalidation
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Adds an object to the list of components that want their
+ * <code>validateProperties()</code> method called.
+ * A component should call this method when a property changes.
+ * Typically, a property setter method
+ * stores a the new value in a temporary variable and calls
+ * the <code>invalidateProperties()</code> method
+ * so that its <code>validateProperties()</code>
+ * and <code>commitProperties()</code> methods are called
+ * later, when the new value will actually be applied to the component and/or
+ * its children. The advantage of this strategy is that often, more than one
+ * property is changed at a time and the properties may interact with each
+ * other, or repeat some code as they are applied, or need to be applied in
+ * a specific order. This strategy allows the most efficient method of
+ * applying new property values.
+ *
+ * @param obj The object whose property changed.
+ */
+ public function invalidateProperties(obj:ILayoutManagerClient ):void
+ {
+ if (!invalidatePropertiesFlag && Application.application.systemManager)
+ {
+ invalidatePropertiesFlag = true;
+
+ if (!callLaterPending)
+ {
+ if (!callLaterObject)
+ {
+ callLaterObject = new UIComponent();
+ callLaterObject.systemManager =
+ Application.application.systemManager;
+ callLaterObject.callLater(waitAFrame);
+ }
+ else
+ {
+ callLaterObject.callLater(doPhasedInstantiation);
+ }
+
+ callLaterPending = true;
+ }
+ }
+
+ // trace("LayoutManager adding " + Object(obj) + " to invalidatePropertiesQueue");
+
+ if (targetLevel <= obj.nestLevel)
+ invalidateClientPropertiesFlag = true;
+
+ invalidatePropertiesQueue.addObject(obj, obj.nestLevel);
+
+ // trace("LayoutManager added " + Object(obj) + " to invalidatePropertiesQueue");
+ }
+
+ /**
+ * Adds an object to the list of components that want their
+ * <code>validateSize()</code> method called.
+ * Called when an object's size changes.
+ *
+ * <p>An object's size can change for two reasons:</p>
+ *
+ * <ol>
+ * <li>The content of the object changes. For example, the size of a
+ * button changes when its <code>label</code> is changed.</li>
+ * <li>A script explicitly changes one of the following properties:
+ * <code>minWidth</code>, <code>minHeight</code>,
+ * <code>explicitWidth</code>, <code>explicitHeight</code>,
+ * <code>maxWidth</code>, or <code>maxHeight</code>.</li>
+ * </ol>
+ *
+ * <p>When the first condition occurs, it's necessary to recalculate
+ * the measurements for the object.
+ * When the second occurs, it's not necessary to recalculate the
+ * measurements because the new size of the object is known.
+ * However, it's necessary to remeasure and relayout the object's
+ * parent.</p>
+ *
+ * @param obj The object whose size changed.
+ */
+ public function invalidateSize(obj:ILayoutManagerClient ):void
+ {
+ if (!invalidateSizeFlag && Application.application.systemManager)
+ {
+ invalidateSizeFlag = true;
+
+ if (!callLaterPending)
+ {
+ if (!callLaterObject)
+ {
+ callLaterObject = new UIComponent();
+ callLaterObject.systemManager =
+ Application.application.systemManager;
+ callLaterObject.callLater(waitAFrame);
+ }
+ else
+ {
+ callLaterObject.callLater(doPhasedInstantiation);
+ }
+
+ callLaterPending = true;
+ }
+ }
+
+ // trace("LayoutManager adding " + Object(obj) + " to invalidateSizeQueue");
+
+ if (targetLevel <= obj.nestLevel)
+ invalidateClientSizeFlag = true;
+
+ invalidateSizeQueue.addObject(obj, obj.nestLevel);
+
+ // trace("LayoutManager added " + Object(obj) + " to invalidateSizeQueue");
+ }
+
+ /**
+ * Called when a component changes in some way that its layout and/or visuals
+ * need to be changed.
+ * In that case, it is necessary to run the component's layout algorithm,
+ * even if the component's size hasn't changed. For example, when a new child component
+ * is added, or a style property changes or the component has been given
+ * a new size by its parent.
+ *
+ * @param obj The object that changed.
+ */
+ public function invalidateDisplayList(obj:ILayoutManagerClient ):void
+ {
+ if (!invalidateDisplayListFlag && Application.application.systemManager)
+ {
+ invalidateDisplayListFlag = true;
+
+ if (!callLaterPending)
+ {
+ if (!callLaterObject)
+ {
+ callLaterObject = new UIComponent();
+ callLaterObject.systemManager =
+ Application.application.systemManager;
+ callLaterObject.callLater(waitAFrame);
+ }
+ else
+ {
+ callLaterObject.callLater(doPhasedInstantiation);
+ }
+
+ callLaterPending = true;
+ }
+ }
+
+ // trace("LayoutManager adding " + Object(obj) + " to invalidateDisplayListQueue");
+
+ invalidateDisplayListQueue.addObject(obj, obj.nestLevel);
+
+ // trace("LayoutManager added " + Object(obj) + " to invalidateDisplayListQueue");
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Methods: Commitment, measurement, layout, and drawing
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Validates all components whose properties have changed and have called
+ * the <code>invalidateProperties()</code> method.
+ * It calls the <code>validateProperties()</code> method on those components
+ * and will call <code>validateProperties()</code> on any other components that are
+ * invalidated while validating other components.
+ */
+ private function validateProperties():void
+ {
+ // trace("--- LayoutManager: validateProperties --->");
+
+ // Keep traversing the invalidatePropertiesQueue until we've reached the end.
+ // More elements may get added to the queue while we're in this loop, or a
+ // a recursive call to this function may remove elements from the queue while
+ // we're in this loop.
+ var obj:ILayoutManagerClient = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallest());
+ while (obj)
+ {
+ // trace("LayoutManager calling validateProperties() on " + Object(obj) + " " + DisplayObject(obj).width + " " + DisplayObject(obj).height);
+
+ obj.validateProperties();
+ if (!obj.updateCompletePendingFlag)
+ updateCompleteQueue.addObject(obj, obj.nestLevel);
+
+ // Once we start, don't stop.
+ obj = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallest());
+ }
+
+ if (invalidatePropertiesQueue.isEmpty())
+ {
+ // trace("Properties Queue is empty");
+
+ invalidatePropertiesFlag = false;
+ }
+
+ // trace("<--- LayoutManager: validateProperties ---");
+ }
+
+ /**
+ * Validates all components whose properties have changed and have called
+ * the <code>invalidateSize()</code> method.
+ * It calls the <code>validateSize()</code> method on those components
+ * and will call the <code>validateSize()</code> method
+ * on any other components that are
+ * invalidated while validating other components.
+ * The </code>validateSize()</code> method starts with
+ * the most deeply nested child in the tree of display objects
+ */
+ private function validateSize():void
+ {
+ // trace("--- LayoutManager: validateSize --->");
+
+ var obj:ILayoutManagerClient = ILayoutManagerClient(invalidateSizeQueue.removeLargest());
+ while (obj)
+ {
+ // trace("LayoutManager calling validateSize() on " + Object(obj));
+
+ obj.validateSize();
+ if (!obj.updateCompletePendingFlag)
+ updateCompleteQueue.addObject(obj, obj.nestLevel);
+
+ // trace("LayoutManager validateSize: " + Object(obj) + " " + IFlexDisplayObject(obj).measuredWidth + " " + IFlexDisplayObject(obj).measuredHeight);
+
+ obj = ILayoutManagerClient(invalidateSizeQueue.removeLargest());
+ }
+
+ if (invalidateSizeQueue.isEmpty())
+ {
+ // trace("Measurement Queue is empty");
+
+ invalidateSizeFlag = false;
+ }
+
+ // trace("<--- LayoutManager: validateSize ---");
+ }
+
+ /**
+ * Validates all components whose properties have changed and have called
+ * the <code>invalidateDisplayList()</code> method.
+ * It calls <code>validateDisplayList()</code> method on those components
+ * and will call the <code>validateDisplayList()</code> method
+ * on any other components that are
+ * invalidated while validating other components.
+ * The <code>validateDisplayList()</code> method starts with
+ * the least deeply nested child in the tree of display objects
+ *
+ */
+ private function validateDisplayList():void
+ {
+
+ // trace("--- LayoutManager: validateDisplayList --->");
+
+ var obj:ILayoutManagerClient = ILayoutManagerClient(invalidateDisplayListQueue.removeSmallest());
+ while (obj)
+ {
+ // trace("LayoutManager calling validateDisplayList on " + Object(obj) + " " + DisplayObject(obj).width + " " + DisplayObject(obj).height);
+
+ obj.validateDisplayList();
+ if (!obj.updateCompletePendingFlag)
+ updateCompleteQueue.addObject(obj, obj.nestLevel);
+
+ // trace("LayoutManager return from validateDisplayList on " + Object(obj) + " " + DisplayObject(obj).width + " " + DisplayObject(obj).height);
+
+ // Once we start, don't stop.
+ obj = ILayoutManagerClient(invalidateDisplayListQueue.removeSmallest());
+ }
+
+
+ if (invalidateDisplayListQueue.isEmpty())
+ {
+ // trace("Layout Queue is empty");
+
+ invalidateDisplayListFlag = fals...
[truncated message content] |
|
From: <luk...@us...> - 2006-11-07 01:24:06
|
Revision: 136
http://svn.sourceforge.net/asunit/?rev=136&view=rev
Author: lukebayes
Date: 2006-11-06 17:23:44 -0800 (Mon, 06 Nov 2006)
Log Message:
-----------
Cleaned up classes for swc creation, removed unused support and error classes
Modified Paths:
--------------
trunk/framework/as3/asunit/errors/AbstractMemberCalledError.as
trunk/framework/as3/asunit/errors/AssertionFailedError.as
trunk/framework/as3/asunit/errors/ClassNotFoundError.as
trunk/framework/as3/asunit/errors/InstanceNotFoundError.as
trunk/framework/as3/asunit/errors/UnimplementedFeatureError.as
trunk/framework/as3/asunit/framework/AsynchronousTestCaseExample.as
trunk/framework/as3/asunit/framework/TestCaseExample.as
trunk/framework/as3/asunit/runner/BaseTestRunner.as
trunk/framework/as3/asunit/textui/TestRunner.as
trunk/framework/as3/asunit/util/Properties.as
Added Paths:
-----------
trunk/framework/as3/build.sh
trunk/framework/as3/manifest.xml
Removed Paths:
-------------
trunk/framework/as3/asunit/errors/InvocationTargetError.as
trunk/framework/as3/asunit/runner/TestRunListener.as
Modified: trunk/framework/as3/asunit/errors/AbstractMemberCalledError.as
===================================================================
--- trunk/framework/as3/asunit/errors/AbstractMemberCalledError.as 2006-11-07 00:17:29 UTC (rev 135)
+++ trunk/framework/as3/asunit/errors/AbstractMemberCalledError.as 2006-11-07 01:23:44 UTC (rev 136)
@@ -1,10 +1,10 @@
package asunit.errors {
public class AbstractMemberCalledError extends Error {
- public var name:String = "AbstractMemberCalledError";
public function AbstractMemberCalledError(message:String) {
super(message);
+ name = "AbstractMemberCalledError";
}
}
}
\ No newline at end of file
Modified: trunk/framework/as3/asunit/errors/AssertionFailedError.as
===================================================================
--- trunk/framework/as3/asunit/errors/AssertionFailedError.as 2006-11-07 00:17:29 UTC (rev 135)
+++ trunk/framework/as3/asunit/errors/AssertionFailedError.as 2006-11-07 01:23:44 UTC (rev 136)
@@ -1,7 +1,6 @@
package asunit.errors {
public class AssertionFailedError extends Error {
-// public var name:String = "AssertionFailedError";
public function AssertionFailedError(message:String) {
super(message);
Modified: trunk/framework/as3/asunit/errors/ClassNotFoundError.as
===================================================================
--- trunk/framework/as3/asunit/errors/ClassNotFoundError.as 2006-11-07 00:17:29 UTC (rev 135)
+++ trunk/framework/as3/asunit/errors/ClassNotFoundError.as 2006-11-07 01:23:44 UTC (rev 136)
@@ -1,10 +1,10 @@
package asunit.errors {
public class ClassNotFoundError extends Error {
- public var name:String = "ClassNotFoundError";
public function ClassNotFoundError(message:String) {
super(message);
+ name = "ClassNotFoundError";
}
}
}
\ No newline at end of file
Modified: trunk/framework/as3/asunit/errors/InstanceNotFoundError.as
===================================================================
--- trunk/framework/as3/asunit/errors/InstanceNotFoundError.as 2006-11-07 00:17:29 UTC (rev 135)
+++ trunk/framework/as3/asunit/errors/InstanceNotFoundError.as 2006-11-07 01:23:44 UTC (rev 136)
@@ -1,7 +1,6 @@
package asunit.errors {
public class InstanceNotFoundError extends Error {
-// public var name:String = "InstanceNotFoundError";
public function InstanceNotFoundError(message:String) {
super(message);
Deleted: trunk/framework/as3/asunit/errors/InvocationTargetError.as
===================================================================
--- trunk/framework/as3/asunit/errors/InvocationTargetError.as 2006-11-07 00:17:29 UTC (rev 135)
+++ trunk/framework/as3/asunit/errors/InvocationTargetError.as 2006-11-07 01:23:44 UTC (rev 136)
@@ -1,10 +0,0 @@
-package asunit.errors {
-
- public class InvocationTargetError extends Error {
- public var name:String = "InvocationTargetError";
-
- public function InvocationTargetError(message:String) {
- super(message);
- }
- }
-}
\ No newline at end of file
Modified: trunk/framework/as3/asunit/errors/UnimplementedFeatureError.as
===================================================================
--- trunk/framework/as3/asunit/errors/UnimplementedFeatureError.as 2006-11-07 00:17:29 UTC (rev 135)
+++ trunk/framework/as3/asunit/errors/UnimplementedFeatureError.as 2006-11-07 01:23:44 UTC (rev 136)
@@ -1,10 +1,10 @@
package asunit.errors {
public class UnimplementedFeatureError extends Error {
- public var name:String = "UnimplementedFeatureError";
public function UnimplementedFeatureError(message:String) {
super(message);
+ name = "UnimplementedFeatureError";
}
}
}
\ No newline at end of file
Modified: trunk/framework/as3/asunit/framework/AsynchronousTestCaseExample.as
===================================================================
--- trunk/framework/as3/asunit/framework/AsynchronousTestCaseExample.as 2006-11-07 00:17:29 UTC (rev 135)
+++ trunk/framework/as3/asunit/framework/AsynchronousTestCaseExample.as 2006-11-07 01:23:44 UTC (rev 136)
@@ -1,5 +1,4 @@
package asunit.framework {
- import flash.util.trace;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.*;
@@ -54,7 +53,7 @@
protected override function tearDown():void {
// destroy the class under test instance
- delete instance;
+ instance = null;
}
public function testBookCount():void {
Modified: trunk/framework/as3/asunit/framework/TestCaseExample.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCaseExample.as 2006-11-07 00:17:29 UTC (rev 135)
+++ trunk/framework/as3/asunit/framework/TestCaseExample.as 2006-11-07 01:23:44 UTC (rev 136)
@@ -69,5 +69,5 @@
// perform assertions in your handler
assertEquals(Event.CHANGE, event.type);
}
-
+ }
}
Modified: trunk/framework/as3/asunit/runner/BaseTestRunner.as
===================================================================
--- trunk/framework/as3/asunit/runner/BaseTestRunner.as 2006-11-07 00:17:29 UTC (rev 135)
+++ trunk/framework/as3/asunit/runner/BaseTestRunner.as 2006-11-07 01:23:44 UTC (rev 136)
@@ -1,360 +1,15 @@
package asunit.runner {
- import asunit.errors.AbstractMemberCalledError;
- import asunit.errors.AssertionFailedError;
- import asunit.errors.ClassNotFoundError;
- import asunit.errors.InvocationTargetError;
- import asunit.errors.UnimplementedFeatureError;
- import asunit.framework.Test;
- import asunit.framework.TestListener;
- import asunit.framework.TestSuite;
- import asunit.util.Properties;
-
import flash.display.Sprite;
- import flash.errors.IllegalOperationError;
- import flash.utils.describeType;
- import flash.utils.getDefinitionByName;
/**
* Base class for all test runners.
* This class was born live on stage in Sardinia during XP2000.
*/
public class BaseTestRunner extends Sprite {
-// public class BaseTestRunner extends Sprite implements TestListener {
-/*
- public static const SUITE_METHODNAME:String = "suite";
- public static const STATUS_ERROR:int = 1;
- public static const STATUS_FAILURE:int = 2;
- private static var fPreferences:Properties;
- protected static var fgMaxMessageLength:int = 500;
- protected static var fgFilterStack:Boolean = true;
- protected var fLoading:Boolean = true;
- private var abstractClassName:String = "asunit.runner::BaseTestRunner";
-
- public function BaseTestRunner() {
-// if(describeType(this).@name == abstractClassName) {
-// throw new AbstractMemberCalledError("BaseTestRunner.constructor");
-// }
- }
-
- // Implementation of TestListener
-
- public function startTest(test:Test):void {
- testStarted(test.toString());
- }
-
- protected static function setPreferences(preferences:Properties):void {
- fPreferences = preferences;
- }
-
- protected static function getPreferences():Properties {
- if (fPreferences == null) {
- fPreferences = new Properties();
- fPreferences.put("loading", "true");
- fPreferences.put("filterstack", "true");
- }
- return fPreferences;
- }
-
- private static function readPreferences():void {
- throw new UnimplementedFeatureError("BaseTestRunner.readPreferences");
-// var is:InputStream = null;
-// try {
-// is = new FileInputStream(getPreferencesFile());
-// setPreferences(new Properties(getPreferences()));
-// getPreferences().load(is);
-// } catch (IOException e) {
-// try {
-// if (is != null)
-// is.close();
-// } catch (IOException e1) {
-// }
-// }
- }
-
- // throws IOException
- public static function savePreferences():void {
- throw new UnimplementedFeatureError("BaseTestRunner.savePreferences");
-// FileOutputStream fos = new FileOutputStream(getPreferencesFile());
-// try {
-// getPreferences().store(fos, "");
-// } finally {
-// fos.close();
-// }
- }
-
- public function setPreference(key:String, value:String):void {
- getPreferences().setProperty(key, value);
- }
-
- public function endTest(test:Test):void {
- testEnded(test.toString());
- }
-
- public function addError(test:Test, t:Error):void {
- testFailed(BaseTestRunner.STATUS_ERROR, test, t);
- }
-
- public function addFailure(test:Test, t:AssertionFailedError):void {
- testFailed(BaseTestRunner.STATUS_FAILURE, test, t);
- }
-
- // TestRunListener implementation
- // BEGIN ABSTRACT METHODS
- public function testStarted(testName:String):void {
- throw new AbstractMemberCalledError("BaseTestRunner.testStarted");
- }
-
- public function testEnded(testName:String):void {
- throw new AbstractMemberCalledError("BaseTestRunner.testEnded");
- }
-
- public function testFailed(status:int, test:Test, t:Error):void {
- throw new AbstractMemberCalledError("BaseTestRunner.testFailed");
- }
-
- // Override to define how to handle a failed loading of
- // a test suite.
- protected function runFailed(message:String):void {
- throw new AbstractMemberCalledError("BaseTestRunner.runFailed");
- }
-
- // Returns the Test corresponding to the given suite. This is
- // a template method, subclasses override runFailed(), clearStatus().
- public function getTest(testCase:Class):Test {
- return null;
-
- !!!!!!!!!!CHANGEED testCase from String to CLASS - not implemented yet
- if (suiteClassName.length <= 0) {
- clearStatus();
- return null;
- }
- var TestClass:Class = null;
-
- try {
- TestClass = getDefinitionByName(testCase);
- }
- catch(e:ClassNotFoundError) {
- var clazz:String = e.getMessage();
- if (clazz == null) {
- clazz = suiteClassName;
- }
- runFailed("Class not found \"" + clazz + "\"");
- return null;
- } catch(e:Error) {
- runFailed("Error: " + e.toString());
- return null;
- }
-
- var testInstance:Test = null;
- try {
- testInstance = new TestClass();
- } catch(e:Error) {
- // try to extract a test suite automatically
- //clearStatus();
- //return new TestSuite(TestClass);
- return null;
- }
- */
-
-/*
- try {
- testClass = loadSuiteClass(suiteClassName);
- } catch (e:ClassNotFoundError) {
- var clazz:String = e.getMessage();
- if (clazz == null) {
- clazz = suiteClassName;
- }
- runFailed("Class not found \"" + clazz + "\"");
- return null;
- } catch(e:Error) {
- runFailed("Error: " + e.toString());
- return null;
- }
- var suiteMethod:Function = null;
- try {
- suiteMethod = testClass.getMethod(SUITE_METHODNAME, new Class[0]);
- } catch(e:Error) {
- // try to extract a test suite automatically
- clearStatus();
- return new TestSuite(testClass);
- }
-// if (! Modifier.isStatic(suiteMethod.getModifiers())) {
-// runFailed("Suite() method must be static");
-// return null;
-// }
- var test:Test = null;
- try {
- test = Test(suiteMethod.invoke(null, new Class[0])); // static method
- if (test == null) {
- return test;
- }
- }
- catch (e:InvocationTargetError) {
- runFailed("Failed to invoke suite():" + e.getTargetException().toString());
- return null;
- }
- catch (e:IllegalOperationError) {
- runFailed("Failed to invoke suite():" + e.toString());
- return null;
- }
- clearStatus();
- return test;
- }
-
- // Returns the formatted string of the elapsed time.
- public function elapsedTimeAsString(runTime:Number):String {
- return runTime.toString();
-// return NumberFormat.getInstance().format(Number(runTime/1000));
- }
-
- // Processes the command line arguments and
- // returns the name of the suite class to run or null
- protected function processArguments(args:Array):String {
- var suiteName:String = null;
- for (var i:int; i < args.length; i++) {
- if (args[i] == "-noloading") {
- setLoading(false);
- } else if (args[i] == "-nofilterstack") {
- fgFilterStack= false;
- } else if (args[i] == "-c") {
- if (args.length > i+1) {
- suiteName = extractClassName(args[i+1]);
- }
- else {
- trace("Missing Test class name");
- }
- i++;
- } else {
- suiteName = args[i];
- }
- }
- return suiteName;
- }
-
- // Sets the loading behaviour of the test runner
- public function setLoading(enable:Boolean):void {
- fLoading = enable;
- }
-
- // Extract the class name from a String in VA/Java style
- public function extractClassName(className:String):String {
- if(className.indexOf("Default package for") == 0) {
- return className.substring(className.lastIndexOf(".") + 1);
- }
- return className;
- }
-
- // Truncates a String to the maximum length.
- public static function truncate(s:String):String {
- if (fgMaxMessageLength != -1 && s.length > fgMaxMessageLength)
- s = s.substring(0, fgMaxMessageLength) + "...";
- return s;
- }
-
- // Returns the loaded Class for a suite name.
- // throws ClassNotFoundException
- protected function loadSuiteClass(suiteClassName:String):Class {
- return getLoader().load(suiteClassName);
- }
-
- // Clears the status message.
- protected function clearStatus():void { // Belongs in the GUI TestRunner class
- throw new AbstractMemberCalledError("BaseTestRunner.clearStatus");
- }
-
- // Returns the loader to be used.
- public function getLoader():TestSuiteLoader {
- throw new UnimplementedFeatureError("BaseTestRunner.getLoader");
-// if (useReloadingTestSuiteLoader())
-// return new ReloadingTestSuiteLoader();
-// return new StandardTestSuiteLoader();
- }
-
- protected function useReloadingTestSuiteLoader():Boolean {
- return false;
-// return getPreference("loading").equals("true") && !inVAJava() && fLoading;
- }
-
- // Should return File...
- private static function getPreferencesFile():Object {
- throw new UnimplementedFeatureError("BaseTestRunner.getPreferencesFile");
-// var home:String = System.getProperty("user.home");
-// return new File(home, "junit.properties");
- }
-
- public static function getPreference(key:String):String {
- return getPreferences().getProperty(key);
- }
-
-// public static function inVAJava():Boolean {
-// try {
-// Class.forName("com.ibm.uvm.tools.DebugSupport");
-// }
-// catch (e:Error) {
-// return false;
-// }
-// return true;
-// }
-
- // Returns a filtered stack trace
- public static function getFilteredTrace(t:Error):String {
- throw new UnimplementedFeatureError("BaseTestRunner.getFilteredTrace");
- var stringWriter:StringWriter = new StringWriter();
- var writer:PrintWriter = new PrintWriter(stringWriter);
- t.printStackTrace(writer);
- var buffer:StringBuffer = stringWriter.getBuffer();
- var trace:String = buffer.toString();
- return BaseTestRunner.getFilteredTrace(trace);
- }
-*/
// Filters stack frames from internal JUnit classes
public static function getFilteredTrace(stack:String):String {
return stack;
-
- //throw new UnimplementedFeatureError("BaseTestRunner.getFilteredTrace");
-// if (showStackRaw()) {
-// return stack;
-// }
-//
-// var sw:StringWriter = new StringWriter();
-// var pw:PrintWriter = new PrintWriter(sw);
-// var sr:StringReader = new StringReader(stack);
-// var br:BufferedReader = new BufferedReader(sr);
-// var line:String;
-// try {
-// while ((line = br.readLine()) != null) {
-// if (!filterLine(line))
-// pw.println(line);
-// }
-// } catch (Exception IOException) {
-// return stack; // return the stack unfiltered
-// }
-// return sw.toString();
}
-/*
- protected static function showStackRaw():Boolean {
- return !getPreference("filterstack") == true || fgFilterStack == false;
- }
-
- protected static function filterLine(line:String):Boolean {
- var patterns:Array = new Array();
- patterns.push("junit.framework.TestCase");
- patterns.push("junit.framework.TestResult");
- patterns.push("junit.framework.TestSuite");
- patterns.push("junit.framework.Assert."); // don't filter AssertionFailure
- patterns.push("junit.swingui.TestRunner");
- patterns.push("junit.awtui.TestRunner");
- patterns.push("junit.textui.TestRunner");
- patterns.push("java.lang.reflect.Method.invoke(");
-
- for(var i:uint; i < patterns.length; i++) {
- if (line.indexOf(patterns[i]) > 0) {
- return true;
- }
- }
- return false;
- }
- */
}
}
Deleted: trunk/framework/as3/asunit/runner/TestRunListener.as
===================================================================
--- trunk/framework/as3/asunit/runner/TestRunListener.as 2006-11-07 00:17:29 UTC (rev 135)
+++ trunk/framework/as3/asunit/runner/TestRunListener.as 2006-11-07 01:23:44 UTC (rev 136)
@@ -1,20 +0,0 @@
-package asunit.runner {
- /**
- * A listener interface for observing the
- * execution of a test run. Unlike TestListener,
- * this interface using only primitive objects,
- * making it suitable for remote test execution.
- */
- public interface TestRunListener {
- /* test status constants*/
- static const STATUS_ERROR:int;
- static const STATUS_FAILURE:int;
-
- function testRunStarted(testSuiteName:String, testCount:int):void;
- function testRunEnded(elapsedTime:Number):void;
- function testRunStopped(elapsedTime:Number):void;
- function testStarted(testName:String):void;
- function testEnded(testName:String):void;
- function testFailed(status:int, testName:String, trace:String):void;
- }
-}
\ No newline at end of file
Modified: trunk/framework/as3/asunit/textui/TestRunner.as
===================================================================
--- trunk/framework/as3/asunit/textui/TestRunner.as 2006-11-07 00:17:29 UTC (rev 135)
+++ trunk/framework/as3/asunit/textui/TestRunner.as 2006-11-07 01:23:44 UTC (rev 136)
@@ -43,7 +43,6 @@
private function configureListeners():void {
addEventListener(Event.ADDED, addedHandler);
-// addEventListener(KeyboardEventType.KEY_DOWN, onKeyDown);
}
protected function addedHandler(event:Event):void {
Modified: trunk/framework/as3/asunit/util/Properties.as
===================================================================
--- trunk/framework/as3/asunit/util/Properties.as 2006-11-07 00:17:29 UTC (rev 135)
+++ trunk/framework/as3/asunit/util/Properties.as 2006-11-07 01:23:44 UTC (rev 136)
@@ -23,6 +23,7 @@
catch(e:Error) {
throw IllegalOperationError("Properties.getProperty");
}
+ return null;
}
}
}
\ No newline at end of file
Added: trunk/framework/as3/build.sh
===================================================================
--- trunk/framework/as3/build.sh (rev 0)
+++ trunk/framework/as3/build.sh 2006-11-07 01:23:44 UTC (rev 136)
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+compc -source-path . -output AsUnit.swc -namespace http://www.asunit.org/as3 manifest.xml -include-namespaces http://www.asunit.org/as3
\ No newline at end of file
Added: trunk/framework/as3/manifest.xml
===================================================================
--- trunk/framework/as3/manifest.xml (rev 0)
+++ trunk/framework/as3/manifest.xml 2006-11-07 01:23:44 UTC (rev 136)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<componentPackage>
+ <component id="Assert" class="asunit.framework.Assert" />
+ <component id="AsynchronousTestCase" class="asunit.framework.AsynchronousTestCase" />
+ <component id="AsynchronousTestCaseExample" class="asunit.framework.AsynchronousTestCaseExample" />
+ <component id="Test" class="asunit.framework.Test" />
+ <component id="TestCase" class="asunit.framework.TestCase" />
+ <component id="TestCaseExample" class="asunit.framework.TestCaseExample" />
+ <component id="TestFailure" class="asunit.framework.TestFailure" />
+ <component id="TestListener" class="asunit.framework.TestListener" />
+ <component id="TestResult" class="asunit.framework.TestResult" />
+ <component id="TestSuite" class="asunit.framework.TestSuite" />
+
+ <component id="BaseTestRunner" class="asunit.runner.BaseTestRunner" />
+ <component id="TestSuiteLoader" class="asunit.runner.TestSuiteLoader" />
+ <component id="Version" class="asunit.runner.Version" />
+ <component id="FlexRunner" class="asunit.textui.FlexRunner" />
+ <component id="FlexTestRunner" class="asunit.textui.FlexTestRunner" />
+ <component id="ResultPrinter" class="asunit.textui.ResultPrinter" />
+ <component id="TestRunner" class="asunit.textui.TestRunner" />
+ <component id="ArrayIterator" class="asunit.util.ArrayIterator" />
+ <component id="Iterator" class="asunit.util.Iterator" />
+ <component id="Properties" class="asunit.util.Properties" />
+ <component id="LayoutManager" class="mx.managers.LayoutManager" />
+
+ <component id="AbstractMemberCalledError" class="asunit.errors.AbstractMemberCalledError" />
+ <component id="AssertionFailedError" class="asunit.errors.AssertionFailedError" />
+ <component id="ClassNotFoundError" class="asunit.errors.ClassNotFoundError" />
+ <component id="InstanceNotFoundError" class="asunit.errors.InstanceNotFoundError" />
+ <component id="UnimplementedFeatureError" class="asunit.errors.UnimplementedFeatureError" />
+</componentPackage>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ali...@us...> - 2007-03-26 23:09:07
|
Revision: 162
http://svn.sourceforge.net/asunit/?rev=162&view=rev
Author: alimills
Date: 2007-03-26 16:09:08 -0700 (Mon, 26 Mar 2007)
Log Message:
-----------
removing modified mx LayoutManager
Modified Paths:
--------------
trunk/framework/as3/asunit/framework/TestCase.as
Removed Paths:
-------------
trunk/framework/as3/mx/
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2007-02-27 21:57:22 UTC (rev 161)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2007-03-26 23:09:08 UTC (rev 162)
@@ -123,6 +123,9 @@
try {
var manager:Class = getDefinitionByName("mx.managers.LayoutManager") as Class;
layoutManager = manager["getInstance"]();
+ if(!layoutManager.hasOwnProperty("resetAll")) {
+ throw new Error("TestCase :: mx.managers.LayoutManager missing resetAll method");
+ }
}
catch(e:Error) {
layoutManager = new Object();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|