asproject 0.1.92 → 0.1.118
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/asclass_arguments.rb +1 -1
- data/lib/asproject.rb +3 -1
- data/lib/asproject/version.rb +1 -1
- data/lib/asproject_arguments.rb +5 -5
- data/lib/path_finder.rb +17 -7
- data/lib/tasks/asunit.rb +8 -0
- data/lib/tasks/flash_log.rb +2 -1
- data/lib/tasks/flash_player.rb +10 -6
- data/lib/tasks/mxmlc.rb +13 -2
- data/lib/tasks/remote_file_loader.rb +144 -0
- data/lib/tasks/remote_file_task.rb +2 -128
- data/lib/tasks/remote_library_task.rb +75 -0
- data/templates/asclass/as2/Class.as +1 -1
- data/templates/asproject/as2/{art → assets}/.crap_file +0 -0
- data/templates/asproject/as2/project/rakefile.rb +3 -2
- data/templates/asproject/as3/{art → assets}/.crap_file +0 -0
- data/templates/asproject/as3/project/rakefile.rb +3 -3
- data/templates/asproject/fdt/project/.as2_classpath +1 -1
- metadata +9 -129
- data/templates/asproject/asunit2/project/lib/asunit/AsUnitUi.swf +0 -0
- data/templates/asproject/asunit2/project/lib/asunit/Sys.as +0 -70
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanel.as +0 -182
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTest.as +0 -84
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextArea.as +0 -111
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextAreaTest.as +0 -26
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTitleBar.as +0 -81
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ResizeHandle.as +0 -35
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollArrow.as +0 -34
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollHandle.as +0 -43
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollListener.as +0 -10
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/TextScroller.as +0 -169
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Rectangle.as +0 -29
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Triangle.as +0 -27
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/AsUnit.as +0 -19
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assert.as +0 -408
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assertion.as +0 -27
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as +0 -68
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Test.as +0 -3
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCase.as +0 -191
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCaseXml.as +0 -31
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestFailure.as +0 -15
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestResult.as +0 -15
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestRunner.as +0 -41
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSetup.as +0 -19
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSuite.as +0 -22
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/Main.as +0 -325
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/RemoteVersion.as +0 -24
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/SuccessMeter.as +0 -32
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Comparable.as +0 -7
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventListener.as +0 -29
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventSource.as +0 -89
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnClient.as +0 -42
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnGateway.as +0 -47
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnServer.as +0 -61
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalMessageBroker.as +0 -58
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Observable.as +0 -11
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/TextFile.as +0 -30
- data/templates/asproject/asunit25/project/lib/asunit/AsUnitTestRunner.as +0 -13
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionFailedError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionPassedError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/ClassNotFoundError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/IllegalOperationError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InvocationTargetError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Assert.as +0 -376
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertMock.as +0 -15
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertTest.as +0 -59
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/ITestListener.as +0 -13
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Test.as +0 -11
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCase.as +0 -278
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseMock.as +0 -23
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseTest.as +0 -29
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseXml.as +0 -38
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestFailure.as +0 -47
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestResult.as +0 -168
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestSuite.as +0 -102
- data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/BaseTestRunner.as +0 -101
- data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/IResultPrinter.as +0 -8
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/ResultPrinter.as +0 -254
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/SuccessBar.as +0 -41
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/TestRunner.as +0 -17
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIterator.as +0 -24
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIteratorTest.as +0 -52
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/Iterator.as +0 -5
- data/templates/asproject/asunit3/project/lib/asunit/AsUnitTestRunner.as +0 -10
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AbstractMemberCalledError.as +0 -10
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AssertionFailedError.as +0 -10
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/ClassNotFoundError.as +0 -10
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +0 -10
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +0 -10
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Assert.as +0 -271
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCase.as +0 -52
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCaseExample.as +0 -71
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Test.as +0 -15
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCase.as +0 -354
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCaseExample.as +0 -73
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestFailure.as +0 -47
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestListener.as +0 -22
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestResult.as +0 -158
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestSuite.as +0 -115
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/BaseTestRunner.as +0 -15
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/TestSuiteLoader.as +0 -9
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/Version.as +0 -11
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexRunner.as +0 -19
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexTestRunner.as +0 -55
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/ResultPrinter.as +0 -245
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/TestRunner.as +0 -121
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/ArrayIterator.as +0 -26
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Iterator.as +0 -9
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Properties.as +0 -30
data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCase.as
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
package asunit.framework {
|
2
|
-
import flash.net.URLRequest;
|
3
|
-
import flash.net.URLLoader;
|
4
|
-
import flash.events.*;
|
5
|
-
import flash.errors.IllegalOperationError;
|
6
|
-
|
7
|
-
/**
|
8
|
-
* Extend this class if you have a TestCase that requires the
|
9
|
-
* asynchronous load of external data.
|
10
|
-
*/
|
11
|
-
public class AsynchronousTestCase extends TestCase {
|
12
|
-
|
13
|
-
public function AsynchronousTestCase(testMethod:String = null) {
|
14
|
-
super(testMethod);
|
15
|
-
}
|
16
|
-
|
17
|
-
protected function configureListeners(loader:URLLoader):void {
|
18
|
-
loader.addEventListener(Event.COMPLETE, completeHandler);
|
19
|
-
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
|
20
|
-
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
|
21
|
-
loader.addEventListener(Event.OPEN, openHandler);
|
22
|
-
loader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
|
23
|
-
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
|
24
|
-
}
|
25
|
-
|
26
|
-
// override this method and implement your own completeHandler
|
27
|
-
// you should be sure to call super.run() from the body of
|
28
|
-
// this override.
|
29
|
-
protected function completeHandler(event:Event):void {
|
30
|
-
}
|
31
|
-
|
32
|
-
// TODO: add support for failing status events...
|
33
|
-
protected function httpStatusHandler(event:HTTPStatusEvent):void {
|
34
|
-
}
|
35
|
-
|
36
|
-
protected function ioErrorHandler(event:IOErrorEvent):void {
|
37
|
-
result.addError(this, new IllegalOperationError(event.toString()));
|
38
|
-
isComplete = true;
|
39
|
-
}
|
40
|
-
|
41
|
-
protected function openHandler(event:Event):void {
|
42
|
-
}
|
43
|
-
|
44
|
-
protected function progressHandler(event:ProgressEvent):void {
|
45
|
-
}
|
46
|
-
|
47
|
-
protected function securityErrorHandler(event:SecurityErrorEvent):void {
|
48
|
-
result.addError(this, new IllegalOperationError(event.toString()));
|
49
|
-
isComplete = true;
|
50
|
-
}
|
51
|
-
}
|
52
|
-
}
|
data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCaseExample.as
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
package asunit.framework {
|
2
|
-
import flash.net.URLRequest;
|
3
|
-
import flash.net.URLLoader;
|
4
|
-
import flash.events.*;
|
5
|
-
|
6
|
-
/**
|
7
|
-
* This example is built on the following mock data:
|
8
|
-
* <books>
|
9
|
-
* <book publisher="Addison-Wesley" name="Design Patterns" />
|
10
|
-
* <book publisher="Addison-Wesley" name="The Pragmattic Programmer" />
|
11
|
-
* <book publisher="Addison-Wesley" name="Test Driven Development" />
|
12
|
-
* <book publisher="Addison-Wesley" name="Refactoring to Patterns" />
|
13
|
-
* <book publisher="O'Reilly Media" name="The Cathedral & the Bazaar" />
|
14
|
-
* <book publisher="O'Reilly Media" name="Unit Test Frameworks" />
|
15
|
-
* </books>
|
16
|
-
*
|
17
|
-
* This example was created to illustrate how one can build an synchronous
|
18
|
-
* TestCase - one that relies on remote data of some sort.
|
19
|
-
* This use case is now diminished by the creation of E4X and easily
|
20
|
-
* readable/editable XML data directly in source form.
|
21
|
-
* But asynchronous tests will probably need to be built at some point
|
22
|
-
* by somebody... If you're them, maybe you can use this as a template.
|
23
|
-
*/
|
24
|
-
|
25
|
-
public class AsynchronousTestCaseExample extends AsynchronousTestCase {
|
26
|
-
private var source:String = "asunit/framework/MockData.xml";
|
27
|
-
private var dataSource:XML;
|
28
|
-
private var instance:Object;
|
29
|
-
|
30
|
-
// Override the run method and begin the request for remote data
|
31
|
-
public override function run():void {
|
32
|
-
var request:URLRequest = new URLRequest(source);
|
33
|
-
var loader:URLLoader = new URLLoader();
|
34
|
-
// configureListeners is a method on the AsynchronousTestCase
|
35
|
-
// and it will handle error states by failing loudly...
|
36
|
-
configureListeners(loader);
|
37
|
-
loader.load(request);
|
38
|
-
}
|
39
|
-
|
40
|
-
protected override function completeHandler(event:Event):void {
|
41
|
-
// put a copy of the data into a member reference
|
42
|
-
dataSource = XML(event.target.data).copy();
|
43
|
-
// call super.run() to execute test methods
|
44
|
-
super.run();
|
45
|
-
}
|
46
|
-
|
47
|
-
protected override function setUp():void {
|
48
|
-
// create a new instance of the class under test
|
49
|
-
instance = new Object();
|
50
|
-
// copy the data into a member or method of the instance
|
51
|
-
instance.data = dataSource.copy();
|
52
|
-
}
|
53
|
-
|
54
|
-
protected override function tearDown():void {
|
55
|
-
// destroy the class under test instance
|
56
|
-
instance = null;
|
57
|
-
}
|
58
|
-
|
59
|
-
public function testBookCount():void {
|
60
|
-
var data:XML = XML(instance.data);
|
61
|
-
var list:XMLList = data..book;
|
62
|
-
assertTrue("list.length() == " + list.length() + " (6?)", list.length() == 6);
|
63
|
-
}
|
64
|
-
|
65
|
-
public function testOReillyBookCount():void {
|
66
|
-
var data:XML = XML(instance.data);
|
67
|
-
var list:XMLList = data..book.(@publisher == "O'Reilly Media");
|
68
|
-
assertTrue("list.length() == " + list.length() + " (2?)", list.length() == 2);
|
69
|
-
}
|
70
|
-
}
|
71
|
-
}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
package asunit.framework {
|
2
|
-
import flash.display.DisplayObjectContainer;
|
3
|
-
import flash.events.IEventDispatcher;
|
4
|
-
|
5
|
-
public interface Test extends IEventDispatcher {
|
6
|
-
function countTestCases():int;
|
7
|
-
function toString():String;
|
8
|
-
function setResult(result:TestResult):void;
|
9
|
-
function run():void;
|
10
|
-
function getCurrentMethod():String;
|
11
|
-
function getIsComplete():Boolean;
|
12
|
-
function setContext(context:DisplayObjectContainer):void;
|
13
|
-
function getContext():DisplayObjectContainer;
|
14
|
-
}
|
15
|
-
}
|
@@ -1,354 +0,0 @@
|
|
1
|
-
package asunit.framework {
|
2
|
-
import asunit.errors.AssertionFailedError;
|
3
|
-
|
4
|
-
import flash.display.DisplayObject;
|
5
|
-
import flash.display.DisplayObjectContainer;
|
6
|
-
import flash.errors.IllegalOperationError;
|
7
|
-
import flash.utils.describeType;
|
8
|
-
import asunit.util.Iterator;
|
9
|
-
import asunit.util.ArrayIterator;
|
10
|
-
import flash.net.getClassByAlias;
|
11
|
-
import flash.events.Event;
|
12
|
-
import flash.utils.Timer;
|
13
|
-
import flash.events.TimerEvent;
|
14
|
-
import flash.utils.setTimeout;
|
15
|
-
import flash.utils.clearTimeout;
|
16
|
-
import flash.utils.getDefinitionByName;
|
17
|
-
|
18
|
-
/**
|
19
|
-
* A test case defines the fixture to run multiple tests. To define a test case<br>
|
20
|
-
* 1) implement a subclass of TestCase<br>
|
21
|
-
* 2) define instance variables that store the state of the fixture<br>
|
22
|
-
* 3) initialize the fixture state by overriding <code>setUp</code><br>
|
23
|
-
* 4) clean-up after a test by overriding <code>tearDown</code>.<br>
|
24
|
-
* Each test runs in its own fixture so there
|
25
|
-
* can be no side effects among test runs.
|
26
|
-
* Here is an example:
|
27
|
-
* <pre>
|
28
|
-
* public class MathTest extends TestCase {
|
29
|
-
* protected double fValue1;
|
30
|
-
* protected double fValue2;
|
31
|
-
*
|
32
|
-
* protected void setUp() {
|
33
|
-
* fValue1= 2.0;
|
34
|
-
* fValue2= 3.0;
|
35
|
-
* }
|
36
|
-
* }
|
37
|
-
* </pre>
|
38
|
-
*
|
39
|
-
* For each test implement a method which interacts
|
40
|
-
* with the fixture. Verify the expected results with assertions specified
|
41
|
-
* by calling <code>assertTrue</code> with a boolean.
|
42
|
-
* <pre>
|
43
|
-
* public void testAdd() {
|
44
|
-
* double result= fValue1 + fValue2;
|
45
|
-
* assertTrue(result == 5.0);
|
46
|
-
* }
|
47
|
-
* </pre>
|
48
|
-
* Once the methods are defined you can run them. The framework supports
|
49
|
-
* both a static type safe and more dynamic way to run a test.
|
50
|
-
* In the static way you override the runTest method and define the method to
|
51
|
-
* be invoked. A convenient way to do so is with an anonymous inner class.
|
52
|
-
* <pre>
|
53
|
-
* TestCase test= new MathTest("add") {
|
54
|
-
* public void runTest() {
|
55
|
-
* testAdd();
|
56
|
-
* }
|
57
|
-
* };
|
58
|
-
* test.run();
|
59
|
-
* </pre>
|
60
|
-
* The dynamic way uses reflection to implement <code>runTest</code>. It dynamically finds
|
61
|
-
* and invokes a method.
|
62
|
-
* In this case the name of the test case has to correspond to the test method
|
63
|
-
* to be run.
|
64
|
-
* <pre>
|
65
|
-
* TestCase= new MathTest("testAdd");
|
66
|
-
* test.run();
|
67
|
-
* </pre>
|
68
|
-
* The tests to be run can be collected into a TestSuite. JUnit provides
|
69
|
-
* different <i>test runners</i> which can run a test suite and collect the results.
|
70
|
-
* A test runner either expects a static method <code>suite</code> as the entry
|
71
|
-
* point to get a test to run or it will extract the suite automatically.
|
72
|
-
* <pre>
|
73
|
-
* public static Test suite() {
|
74
|
-
* suite.addTest(new MathTest("testAdd"));
|
75
|
-
* suite.addTest(new MathTest("testDivideByZero"));
|
76
|
-
* return suite;
|
77
|
-
* }
|
78
|
-
* </pre>
|
79
|
-
* @see TestResult
|
80
|
-
* @see TestSuite
|
81
|
-
*/
|
82
|
-
public class TestCase extends Assert implements Test {
|
83
|
-
/**
|
84
|
-
* the name of the test case
|
85
|
-
*/
|
86
|
-
protected static const DEFAULT_TIMEOUT:int = 1000;
|
87
|
-
protected var fName:String;
|
88
|
-
protected var result:TestResult;
|
89
|
-
protected var testMethods:Array;
|
90
|
-
protected var isComplete:Boolean;
|
91
|
-
protected var context:DisplayObjectContainer;
|
92
|
-
protected var methodIsAsynchronous:Boolean;
|
93
|
-
protected var timeout:Timer;
|
94
|
-
private var currentMethod:String;
|
95
|
-
private var runSingle:Boolean;
|
96
|
-
private var methodIterator:Iterator;
|
97
|
-
private var layoutManager:Object;
|
98
|
-
|
99
|
-
/**
|
100
|
-
* Constructs a test case with the given name.
|
101
|
-
*/
|
102
|
-
public function TestCase(testMethod:String = null) {
|
103
|
-
var description:XML = describeType(this);
|
104
|
-
var className:Object = description.@name;
|
105
|
-
var methods:XMLList = description..method.(@name.match("^test"));
|
106
|
-
if(testMethod != null) {
|
107
|
-
testMethods = testMethod.split(", ").join(",").split(",");
|
108
|
-
if(testMethods.length == 1) {
|
109
|
-
runSingle = true;
|
110
|
-
}
|
111
|
-
} else {
|
112
|
-
setTestMethods(methods);
|
113
|
-
}
|
114
|
-
setName(className.toString());
|
115
|
-
resolveLayoutManager();
|
116
|
-
}
|
117
|
-
|
118
|
-
private function resolveLayoutManager():void {
|
119
|
-
// Avoid creating import dependencies on flex framework
|
120
|
-
// If you have the framework.swc in your classpath,
|
121
|
-
// the layout manager will be found, if not, a mcok
|
122
|
-
// will be used.
|
123
|
-
try {
|
124
|
-
var manager:Class = getDefinitionByName("mx.managers.LayoutManager") as Class;
|
125
|
-
layoutManager = manager["getInstance"]();
|
126
|
-
if(!layoutManager.hasOwnProperty("resetAll")) {
|
127
|
-
throw new Error("TestCase :: mx.managers.LayoutManager missing resetAll method");
|
128
|
-
}
|
129
|
-
}
|
130
|
-
catch(e:Error) {
|
131
|
-
layoutManager = new Object();
|
132
|
-
layoutManager.resetAll = function():void {
|
133
|
-
}
|
134
|
-
}
|
135
|
-
}
|
136
|
-
|
137
|
-
/**
|
138
|
-
* Sets the name of a TestCase
|
139
|
-
* @param name The name to set
|
140
|
-
*/
|
141
|
-
public function setName(name:String):void {
|
142
|
-
fName = name;
|
143
|
-
}
|
144
|
-
|
145
|
-
protected function setTestMethods(methodNodes:XMLList):void {
|
146
|
-
testMethods = new Array();
|
147
|
-
var methodNames:Object = methodNodes.@name;
|
148
|
-
var name:String;
|
149
|
-
for each(var item:Object in methodNames) {
|
150
|
-
name = item.toString();
|
151
|
-
testMethods.push(name);
|
152
|
-
}
|
153
|
-
}
|
154
|
-
|
155
|
-
/**
|
156
|
-
* Counts the number of test cases executed by run(TestResult result).
|
157
|
-
*/
|
158
|
-
public function countTestCases():int {
|
159
|
-
return testMethods.length;
|
160
|
-
}
|
161
|
-
|
162
|
-
/**
|
163
|
-
* Creates a default TestResult object
|
164
|
-
*
|
165
|
-
* @see TestResult
|
166
|
-
*/
|
167
|
-
protected function createResult():TestResult {
|
168
|
-
return new TestResult();
|
169
|
-
}
|
170
|
-
|
171
|
-
/**
|
172
|
-
* A convenience method to run this test, collecting the results with
|
173
|
-
* either the TestResult provided or a default, new TestResult object.
|
174
|
-
* Expects either:
|
175
|
-
* run():void // will return the newly created TestResult
|
176
|
-
* run(result:TestResult):TestResult // will use the TestResult
|
177
|
-
* that was passed in.
|
178
|
-
*
|
179
|
-
* @see TestResult
|
180
|
-
*/
|
181
|
-
public function run():void {
|
182
|
-
getResult().run(this);
|
183
|
-
}
|
184
|
-
|
185
|
-
public function setResult(result:TestResult):void {
|
186
|
-
this.result = result;
|
187
|
-
}
|
188
|
-
|
189
|
-
protected function getResult():TestResult {
|
190
|
-
return (result == null) ? createResult() : result;
|
191
|
-
}
|
192
|
-
|
193
|
-
/**
|
194
|
-
* Runs the bare test sequence.
|
195
|
-
* @exception Error if any exception is thrown
|
196
|
-
* throws Error
|
197
|
-
*/
|
198
|
-
public function runBare():void {
|
199
|
-
if(isComplete) {
|
200
|
-
return;
|
201
|
-
}
|
202
|
-
var name:String;
|
203
|
-
var itr:Iterator = getMethodIterator();
|
204
|
-
if(itr.hasNext()) {
|
205
|
-
name = String(itr.next());
|
206
|
-
runMethod(name);
|
207
|
-
}
|
208
|
-
else {
|
209
|
-
cleanUp();
|
210
|
-
getResult().endTest(this);
|
211
|
-
isComplete = true;
|
212
|
-
dispatchEvent(new Event(Event.COMPLETE));
|
213
|
-
}
|
214
|
-
}
|
215
|
-
|
216
|
-
private function getMethodIterator():Iterator {
|
217
|
-
if(methodIterator == null) {
|
218
|
-
methodIterator = new ArrayIterator(testMethods);
|
219
|
-
}
|
220
|
-
return methodIterator;
|
221
|
-
}
|
222
|
-
|
223
|
-
// Override this method in Asynchronous test cases
|
224
|
-
// or any other time you want to perform additional
|
225
|
-
// member cleanup after all test methods have run
|
226
|
-
protected function cleanUp():void {
|
227
|
-
}
|
228
|
-
|
229
|
-
private function runMethod(methodName:String):void {
|
230
|
-
try {
|
231
|
-
setUp();
|
232
|
-
currentMethod = methodName;
|
233
|
-
methodIsAsynchronous = false;
|
234
|
-
this[methodName]();
|
235
|
-
}
|
236
|
-
catch(assertionFailedError:AssertionFailedError) {
|
237
|
-
getResult().addFailure(this, assertionFailedError);
|
238
|
-
}
|
239
|
-
catch(unknownError:Error) {
|
240
|
-
getResult().addError(this, unknownError);
|
241
|
-
}
|
242
|
-
finally {
|
243
|
-
if(!methodIsAsynchronous) {
|
244
|
-
runTearDown();
|
245
|
-
}
|
246
|
-
}
|
247
|
-
}
|
248
|
-
|
249
|
-
/**
|
250
|
-
* Sets up the fixture, for example, instantiate a mock object.
|
251
|
-
* This method is called before each test is executed.
|
252
|
-
* throws Exception on error
|
253
|
-
*/
|
254
|
-
protected function setUp():void {
|
255
|
-
}
|
256
|
-
/**
|
257
|
-
* Tears down the fixture, for example, delete mock object.
|
258
|
-
* This method is called after a test is executed.
|
259
|
-
* throws Exception on error
|
260
|
-
*/
|
261
|
-
protected function tearDown():void {
|
262
|
-
}
|
263
|
-
/**
|
264
|
-
* Returns a string representation of the test case
|
265
|
-
*/
|
266
|
-
override public function toString():String {
|
267
|
-
return getName() + "." + getCurrentMethod() + "()";
|
268
|
-
}
|
269
|
-
/**
|
270
|
-
* Gets the name of a TestCase
|
271
|
-
* @return returns a String
|
272
|
-
*/
|
273
|
-
public function getName():String {
|
274
|
-
return fName;
|
275
|
-
}
|
276
|
-
|
277
|
-
public function getCurrentMethod():String {
|
278
|
-
return currentMethod;
|
279
|
-
}
|
280
|
-
|
281
|
-
public function getIsComplete():Boolean {
|
282
|
-
return isComplete;
|
283
|
-
}
|
284
|
-
|
285
|
-
public function setContext(context:DisplayObjectContainer):void {
|
286
|
-
this.context = context;
|
287
|
-
}
|
288
|
-
|
289
|
-
public function getContext():DisplayObjectContainer {
|
290
|
-
return context;
|
291
|
-
}
|
292
|
-
|
293
|
-
protected function addAsync(handler:Function = null, duration:Number=DEFAULT_TIMEOUT):Function {
|
294
|
-
if(handler == null) {
|
295
|
-
handler = function(args:*):* {};
|
296
|
-
}
|
297
|
-
methodIsAsynchronous = true;
|
298
|
-
timeout = new Timer(duration, 1);
|
299
|
-
timeout.addEventListener(TimerEvent.TIMER_COMPLETE, getTimeoutComplete(duration));
|
300
|
-
timeout.start();
|
301
|
-
// try ..args
|
302
|
-
var context:TestCase = this;
|
303
|
-
return function(args:*):* {
|
304
|
-
context.timeout.stop();
|
305
|
-
try {
|
306
|
-
handler.apply(context, arguments);
|
307
|
-
}
|
308
|
-
catch(e:AssertionFailedError) {
|
309
|
-
context.getResult().addFailure(context, e);
|
310
|
-
}
|
311
|
-
catch(ioe:IllegalOperationError) {
|
312
|
-
context.getResult().addError(context, ioe);
|
313
|
-
}
|
314
|
-
finally {
|
315
|
-
context.runTearDown();
|
316
|
-
}
|
317
|
-
}
|
318
|
-
}
|
319
|
-
|
320
|
-
private function getTimeoutComplete(duration:Number):Function {
|
321
|
-
var context:TestCase = this;
|
322
|
-
return function(event:Event):void {
|
323
|
-
context.getResult().addError(context, new IllegalOperationError("TestCase.timeout (" + duration + "ms) exceeded on an asynchronous test method."));
|
324
|
-
context.runTearDown();
|
325
|
-
}
|
326
|
-
}
|
327
|
-
|
328
|
-
protected function runTearDown():void {
|
329
|
-
if(isComplete) {
|
330
|
-
return;
|
331
|
-
}
|
332
|
-
if(!runSingle) {
|
333
|
-
tearDown();
|
334
|
-
layoutManager.resetAll();
|
335
|
-
}
|
336
|
-
setTimeout(runBare, 5);
|
337
|
-
}
|
338
|
-
|
339
|
-
protected function addChild(child:DisplayObject):DisplayObject {
|
340
|
-
return getContext().addChild(child);
|
341
|
-
}
|
342
|
-
|
343
|
-
protected function removeChild(child:DisplayObject):DisplayObject {
|
344
|
-
if(child == null) {
|
345
|
-
throw new IllegalOperationError("TestCase.removeChild must have non-null parameter child");
|
346
|
-
}
|
347
|
-
return getContext().removeChild(child);
|
348
|
-
}
|
349
|
-
|
350
|
-
// public function fail(message:String):void {
|
351
|
-
// result.addFailure(this, new AssertionFailedError(message));
|
352
|
-
// }
|
353
|
-
}
|
354
|
-
}
|