asproject 0.1.92 → 0.1.118
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,47 +0,0 @@
|
|
1
|
-
//import flash.util.StringBuilder;
|
2
|
-
import asunit.errors.AssertionFailedError;
|
3
|
-
import asunit.framework.Test;
|
4
|
-
|
5
|
-
/**
|
6
|
-
* A <code>TestFailure</code> collects a failed test together with
|
7
|
-
* the caught exception.
|
8
|
-
* @see TestResult
|
9
|
-
*/
|
10
|
-
class asunit.framework.TestFailure {
|
11
|
-
private var fFailedTest:String;
|
12
|
-
private var fThrownException:Error;
|
13
|
-
|
14
|
-
/**
|
15
|
-
* Constructs a TestFailure with the given test and exception.
|
16
|
-
*/
|
17
|
-
public function TestFailure(failedTest:Test, thrownException:Error) {
|
18
|
-
fFailedTest = failedTest.toString();
|
19
|
-
fThrownException = thrownException;
|
20
|
-
}
|
21
|
-
/**
|
22
|
-
* Gets the failed test.
|
23
|
-
*/
|
24
|
-
public function failedTest():String {
|
25
|
-
return fFailedTest;
|
26
|
-
}
|
27
|
-
/**
|
28
|
-
* Gets the thrown exception.
|
29
|
-
*/
|
30
|
-
public function thrownException():Error {
|
31
|
-
return fThrownException;
|
32
|
-
}
|
33
|
-
/**
|
34
|
-
* Returns a short description of the failure.
|
35
|
-
*/
|
36
|
-
public function toString():String {
|
37
|
-
return "";
|
38
|
-
}
|
39
|
-
|
40
|
-
public function exceptionMessage():String {
|
41
|
-
return thrownException().message;
|
42
|
-
}
|
43
|
-
|
44
|
-
public function isFailure():Boolean {
|
45
|
-
return thrownException() instanceof AssertionFailedError;
|
46
|
-
}
|
47
|
-
}
|
@@ -1,168 +0,0 @@
|
|
1
|
-
import asunit.errors.AssertionFailedError;
|
2
|
-
import asunit.errors.InstanceNotFoundError;
|
3
|
-
import asunit.framework.Test;
|
4
|
-
import asunit.framework.TestCase;
|
5
|
-
import asunit.framework.TestFailure;
|
6
|
-
import asunit.framework.ITestListener;
|
7
|
-
|
8
|
-
/**
|
9
|
-
* A <code>TestResult</code> collects the results of executing
|
10
|
-
* a test case. It is an instance of the Collecting Parameter pattern.
|
11
|
-
* The test framework distinguishes between <i>failures</i> and <i>errors</i>.
|
12
|
-
* A failure is anticipated and checked for with assertions. Errors are
|
13
|
-
* unanticipated problems like an <code>ArrayIndexOutOfBoundsException</code>.
|
14
|
-
*
|
15
|
-
* @see Test
|
16
|
-
*/
|
17
|
-
class asunit.framework.TestResult {
|
18
|
-
private var fFailures:Array;
|
19
|
-
private var fErrors:Array;
|
20
|
-
private var fListeners:Array;
|
21
|
-
private var fRunTests:Number;
|
22
|
-
private var fStop:Boolean;
|
23
|
-
|
24
|
-
public function TestResult() {
|
25
|
-
fFailures = new Array();
|
26
|
-
fErrors = new Array();
|
27
|
-
fListeners = new Array();
|
28
|
-
fRunTests = 0;
|
29
|
-
fStop = false;
|
30
|
-
}
|
31
|
-
/**
|
32
|
-
* Adds an error to the list of errors. The passed in exception
|
33
|
-
* caused the error.
|
34
|
-
*/
|
35
|
-
public function addError(test:Test, t:Error):Void {
|
36
|
-
fErrors.push(new TestFailure(test, t));
|
37
|
-
var len:Number = fListeners.length;
|
38
|
-
var item:ITestListener;
|
39
|
-
for(var i:Number = 0; i < len; i++) {
|
40
|
-
item = ITestListener(fListeners[i]);
|
41
|
-
item.addError(test, t);
|
42
|
-
}
|
43
|
-
}
|
44
|
-
/**
|
45
|
-
* Adds a failure to the list of failures. The passed in exception
|
46
|
-
* caused the failure.
|
47
|
-
*/
|
48
|
-
public function addFailure(test:Test, t:AssertionFailedError):Void {
|
49
|
-
fFailures.push(new TestFailure(test, t));
|
50
|
-
var len:Number = fListeners.length;
|
51
|
-
var item:ITestListener;
|
52
|
-
for(var i:Number = 0; i < len; i++) {
|
53
|
-
item = ITestListener(fListeners[i]);
|
54
|
-
item.addFailure(test, t);
|
55
|
-
}
|
56
|
-
}
|
57
|
-
/**
|
58
|
-
* Registers a ITestListener
|
59
|
-
*/
|
60
|
-
public function addListener(listener:ITestListener):Void {
|
61
|
-
fListeners.push(listener);
|
62
|
-
}
|
63
|
-
/**
|
64
|
-
* Unregisters a ITestListener
|
65
|
-
*/
|
66
|
-
public function removeListener(listener:ITestListener):Void {
|
67
|
-
var len:Number = fListeners.length;
|
68
|
-
for(var i:Number = 0; i < len; i++) {
|
69
|
-
if(fListeners[i] == listener) {
|
70
|
-
fListeners.splice(i, 1);
|
71
|
-
return;
|
72
|
-
}
|
73
|
-
}
|
74
|
-
throw new InstanceNotFoundError("removeListener called without listener in list");
|
75
|
-
}
|
76
|
-
/**
|
77
|
-
* Gets the number of detected errors.
|
78
|
-
*/
|
79
|
-
public function errorCount():Number {
|
80
|
-
return fErrors.length;
|
81
|
-
}
|
82
|
-
/**
|
83
|
-
* Returns an Enumeration for the errors
|
84
|
-
*/
|
85
|
-
public function errors():Array {
|
86
|
-
return fErrors;
|
87
|
-
}
|
88
|
-
/**
|
89
|
-
* Gets the number of detected failures.
|
90
|
-
*/
|
91
|
-
public function failureCount():Number {
|
92
|
-
return fFailures.length;
|
93
|
-
}
|
94
|
-
/**
|
95
|
-
* Returns an Enumeration for the failures
|
96
|
-
*/
|
97
|
-
public function failures():Array {
|
98
|
-
return fFailures;
|
99
|
-
}
|
100
|
-
|
101
|
-
/**
|
102
|
-
* Runs a TestCase.
|
103
|
-
*/
|
104
|
-
public function run(test:TestCase):Void {
|
105
|
-
startTest(test);
|
106
|
-
try {
|
107
|
-
test.runBare();
|
108
|
-
}
|
109
|
-
catch(afe:AssertionFailedError) {
|
110
|
-
addFailure(test, afe);
|
111
|
-
}
|
112
|
-
catch(e:Error) {
|
113
|
-
addError(test, e);
|
114
|
-
}
|
115
|
-
finally {
|
116
|
-
endTest(test);
|
117
|
-
}
|
118
|
-
}
|
119
|
-
/**
|
120
|
-
* Gets the number of run tests.
|
121
|
-
*/
|
122
|
-
public function runCount():Number {
|
123
|
-
return fRunTests;
|
124
|
-
}
|
125
|
-
/**
|
126
|
-
* Checks whether the test run should stop
|
127
|
-
*/
|
128
|
-
public function shouldStop():Boolean {
|
129
|
-
return fStop;
|
130
|
-
}
|
131
|
-
/**
|
132
|
-
* Informs the result that a test will be started.
|
133
|
-
*/
|
134
|
-
public function startTest(test:Test):Void {
|
135
|
-
var count:Number = test.countTestCases();
|
136
|
-
fRunTests += count;
|
137
|
-
|
138
|
-
var len:Number = fListeners.length;
|
139
|
-
var item:ITestListener;
|
140
|
-
for(var i:Number = 0; i < len; i++) {
|
141
|
-
item = ITestListener(fListeners[i]);
|
142
|
-
item.startTest(test);
|
143
|
-
}
|
144
|
-
}
|
145
|
-
/**
|
146
|
-
* Informs the result that a test was completed.
|
147
|
-
*/
|
148
|
-
public function endTest(test:Test):Void {
|
149
|
-
var len:Number = fListeners.length;
|
150
|
-
var item:ITestListener;
|
151
|
-
for(var i:Number = 0; i < len; i++) {
|
152
|
-
item = ITestListener(fListeners[i]);
|
153
|
-
item.endTest(test);
|
154
|
-
}
|
155
|
-
}
|
156
|
-
/**
|
157
|
-
* Marks that the test run should stop.
|
158
|
-
*/
|
159
|
-
public function stop():Void {
|
160
|
-
fStop = true;
|
161
|
-
}
|
162
|
-
/**
|
163
|
-
* Returns whether the entire test was successful or not.
|
164
|
-
*/
|
165
|
-
public function wasSuccessful():Boolean {
|
166
|
-
return (failureCount() == 0 && errorCount() == 0);
|
167
|
-
}
|
168
|
-
}
|
@@ -1,102 +0,0 @@
|
|
1
|
-
import asunit.framework.TestCase;
|
2
|
-
import asunit.framework.Test;
|
3
|
-
import asunit.framework.TestResult;
|
4
|
-
import asunit.util.Iterator;
|
5
|
-
import asunit.util.ArrayIterator;
|
6
|
-
|
7
|
-
class asunit.framework.TestSuite extends TestCase {
|
8
|
-
private var fTests:Array = new Array();
|
9
|
-
|
10
|
-
public function TestSuite() {
|
11
|
-
super();
|
12
|
-
fTests = new Array();
|
13
|
-
}
|
14
|
-
|
15
|
-
private function getTestMethods():Array {
|
16
|
-
return new Array();
|
17
|
-
}
|
18
|
-
|
19
|
-
public function testsComplete():Boolean {
|
20
|
-
var completed:Boolean;
|
21
|
-
var len:Number = fTests.length;
|
22
|
-
for(var i:Number = 0; i < len; i++) {
|
23
|
-
if(!fTests[i].testsComplete()) {
|
24
|
-
return false;
|
25
|
-
}
|
26
|
-
}
|
27
|
-
return true;
|
28
|
-
}
|
29
|
-
|
30
|
-
/**
|
31
|
-
* Adds a test to the suite.
|
32
|
-
*/
|
33
|
-
public function addTest(test:Test):Void {
|
34
|
-
fTests.push(test);
|
35
|
-
}
|
36
|
-
|
37
|
-
/**
|
38
|
-
* Counts the number of tests that will be run by this Suite.
|
39
|
-
*/
|
40
|
-
public function countTestCases():Number {
|
41
|
-
var count:Number;
|
42
|
-
var len:Number = fTests.length;
|
43
|
-
for(var i:Number = 0; i < len; i++) {
|
44
|
-
count = count + fTests[i].countTestCases();
|
45
|
-
}
|
46
|
-
return count;
|
47
|
-
}
|
48
|
-
|
49
|
-
/**
|
50
|
-
* Runs the tests and collects their result in a TestResult.
|
51
|
-
*/
|
52
|
-
public function run():Void {
|
53
|
-
var result:TestResult = getResult();
|
54
|
-
runTests(fTests, result);
|
55
|
-
}
|
56
|
-
|
57
|
-
public function runTests(tests:Array, result:TestResult):Void {
|
58
|
-
var itr:Iterator = new ArrayIterator(tests);
|
59
|
-
var test:TestCase;
|
60
|
-
if(itr.hasNext()) {
|
61
|
-
test = TestCase(itr.next());
|
62
|
-
runTest(itr, test, result);
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
public function runTest(itr:Iterator, test:TestCase, result:TestResult):Void {
|
67
|
-
test.setResult(result);
|
68
|
-
test.run();
|
69
|
-
if(itr.hasNext()) {
|
70
|
-
_global.setTimeout(this, "runTest", 10, itr, itr.next(), result);
|
71
|
-
}
|
72
|
-
}
|
73
|
-
|
74
|
-
/**
|
75
|
-
* Returns the number of tests in this suite
|
76
|
-
*/
|
77
|
-
public function testCount():Number {
|
78
|
-
return fTests.length;
|
79
|
-
}
|
80
|
-
|
81
|
-
public function toString():String {
|
82
|
-
return getName();
|
83
|
-
}
|
84
|
-
|
85
|
-
public function getIsComplete():Boolean {
|
86
|
-
var len:Number = fTests.length;
|
87
|
-
for(var i:Number = 0; i < len; i++) {
|
88
|
-
if(!fTests[i].getIsComplete()) {
|
89
|
-
return false;
|
90
|
-
}
|
91
|
-
}
|
92
|
-
return true;
|
93
|
-
}
|
94
|
-
|
95
|
-
public function setContext(context:MovieClip):Void {
|
96
|
-
super.setContext(context);
|
97
|
-
var len:Number = fTests.length;
|
98
|
-
for(var i:Number = 0; i < len; i++) {
|
99
|
-
fTests[i].setContext(context);
|
100
|
-
}
|
101
|
-
}
|
102
|
-
}
|
@@ -1,101 +0,0 @@
|
|
1
|
-
import asunit.runner.IResultPrinter;
|
2
|
-
import asunit.framework.Test;
|
3
|
-
import asunit.framework.TestResult;
|
4
|
-
import asunit.framework.Assert;
|
5
|
-
import asunit.textui.ResultPrinter;
|
6
|
-
|
7
|
-
class asunit.runner.BaseTestRunner {
|
8
|
-
private static var instance:BaseTestRunner;
|
9
|
-
private static var clipContext:MovieClip;
|
10
|
-
private var printer:IResultPrinter;
|
11
|
-
private var intervalId:Number;
|
12
|
-
|
13
|
-
public function BaseTestRunner(printerReference:Function) {
|
14
|
-
if(printerReference == undefined) {
|
15
|
-
throw new Error("BaseTestRunner instantiated without a ResultPrinter");
|
16
|
-
}
|
17
|
-
Stage.scaleMode = "noscale";
|
18
|
-
Stage.align = "TL";
|
19
|
-
instance = this;
|
20
|
-
setClipContext(_root);
|
21
|
-
setPrinter(createResultPrinter(printerReference));
|
22
|
-
}
|
23
|
-
|
24
|
-
public static function getFilteredTrace(stack:String):String {
|
25
|
-
return stack;
|
26
|
-
}
|
27
|
-
|
28
|
-
public function start(testCase:Function, testMethod:String, showTrace:Boolean):TestResult {
|
29
|
-
try {
|
30
|
-
var suite:Test = Test(new testCase(testMethod));
|
31
|
-
return doRun(suite, showTrace);
|
32
|
-
}
|
33
|
-
catch(e:Error) {
|
34
|
-
trace("ERROR: Failed to create and run test suite with: \n" + e.toString());
|
35
|
-
}
|
36
|
-
}
|
37
|
-
|
38
|
-
public function doRun(suite:Test, showTrace:Boolean):TestResult {
|
39
|
-
try {
|
40
|
-
var result:TestResult = new TestResult();
|
41
|
-
result.addListener(getPrinter());
|
42
|
-
var startTime:Number = getTimer();
|
43
|
-
suite.setResult(result);
|
44
|
-
suite.setContext(getClipContext());
|
45
|
-
suite.run();
|
46
|
-
clearInterval(intervalId);
|
47
|
-
intervalId = setInterval(this, "completionHandler", 1, suite, result, startTime);
|
48
|
-
return result;
|
49
|
-
}
|
50
|
-
catch(e:Error) {
|
51
|
-
trace(e.toString());
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
|
-
private function completionHandler(suite:Test, result:TestResult, startTime:Number):Void {
|
56
|
-
if(suite.testsComplete()) {
|
57
|
-
clearInterval(intervalId);
|
58
|
-
getPrinter().printResult(result, (getTimer() - startTime));
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
|
-
public static function trace(msg:String):Void {
|
63
|
-
getInstance().getPrinter().trace(msg);
|
64
|
-
}
|
65
|
-
|
66
|
-
public static function getInstance():BaseTestRunner {
|
67
|
-
if(instance == undefined) {
|
68
|
-
return instance = new BaseTestRunner(ResultPrinter);
|
69
|
-
}
|
70
|
-
return instance;
|
71
|
-
}
|
72
|
-
|
73
|
-
public function setPrinter(printer:IResultPrinter):Void {
|
74
|
-
this.printer = printer;
|
75
|
-
}
|
76
|
-
|
77
|
-
public function getPrinter():IResultPrinter {
|
78
|
-
return IResultPrinter(printer);
|
79
|
-
}
|
80
|
-
|
81
|
-
public function setClipContext(context:MovieClip):Void {
|
82
|
-
BaseTestRunner.clipContext = context;
|
83
|
-
}
|
84
|
-
/*
|
85
|
-
* This function should return a reference to the
|
86
|
-
* MovieClip that all test cases will attach items
|
87
|
-
* to. This MovieClip should probably *not* be _root.
|
88
|
-
*/
|
89
|
-
public function getClipContext():MovieClip {
|
90
|
-
return BaseTestRunner.clipContext;
|
91
|
-
}
|
92
|
-
|
93
|
-
private static function createResultPrinter(reference:Function):IResultPrinter {
|
94
|
-
var printer:IResultPrinter;
|
95
|
-
if(printer == undefined) {
|
96
|
-
var context:MovieClip = BaseTestRunner.clipContext;
|
97
|
-
printer = IResultPrinter(context.attachMovie(reference.linkageId, "asUnitResultPrinter_" + 9000, Assert.nextDepth()));
|
98
|
-
}
|
99
|
-
return printer;
|
100
|
-
}
|
101
|
-
}
|
@@ -1,254 +0,0 @@
|
|
1
|
-
import asunit.runner.IResultPrinter;
|
2
|
-
import asunit.errors.AssertionFailedError;
|
3
|
-
import asunit.framework.Test;
|
4
|
-
import asunit.framework.TestResult;
|
5
|
-
import asunit.framework.TestFailure;
|
6
|
-
import asunit.runner.BaseTestRunner;
|
7
|
-
import asunit.textui.SuccessBar;
|
8
|
-
import asunit.framework.ITestListener;
|
9
|
-
|
10
|
-
class asunit.textui.ResultPrinter extends MovieClip implements IResultPrinter, ITestListener {
|
11
|
-
public static var linkageId:String = "__Packages.asunit.textui.ResultPrinter";
|
12
|
-
public static var classRef:Function = ResultPrinter;
|
13
|
-
private static var instance:ResultPrinter;
|
14
|
-
|
15
|
-
private var fColumn:Number = 0;
|
16
|
-
private var showTrace:Boolean;
|
17
|
-
private var barHeight:Number = 3;
|
18
|
-
private var bgColor:Number = 0x333333;
|
19
|
-
private var fontColor:Number = 0xFFFFFF;
|
20
|
-
private var spacing:Number = 5;
|
21
|
-
private var textArea:TextField;
|
22
|
-
private var traceOutput:TextField;
|
23
|
-
private var successMeter:MovieClip;
|
24
|
-
private var bar:SuccessBar;
|
25
|
-
|
26
|
-
public function ResultPrinter() {
|
27
|
-
init();
|
28
|
-
configureAssets();
|
29
|
-
println("AsUnit 2.5 by Luke Bayes and Ali Mills");
|
30
|
-
// If you can't see clips that you think should be
|
31
|
-
// attached... Perhaps it's behind this runner?
|
32
|
-
//_alpha = 50;
|
33
|
-
}
|
34
|
-
|
35
|
-
private function init():Void {
|
36
|
-
if(instance != undefined) {
|
37
|
-
throw new Error("Resultprinter instantiated twice in one session, this will likely cause problems");
|
38
|
-
}
|
39
|
-
instance = this;
|
40
|
-
Stage.addListener(this);
|
41
|
-
}
|
42
|
-
|
43
|
-
private function onLoad():Void {
|
44
|
-
onResize();
|
45
|
-
}
|
46
|
-
|
47
|
-
private function configureAssets():Void {
|
48
|
-
createTextArea();
|
49
|
-
createOutput();
|
50
|
-
createSuccessBar();
|
51
|
-
}
|
52
|
-
|
53
|
-
public function trace():Void {
|
54
|
-
traceOutput._visible = true;
|
55
|
-
traceOutput.text += arguments.toString() + "\n";
|
56
|
-
traceOutput.scroll = traceOutput.maxscroll;
|
57
|
-
}
|
58
|
-
|
59
|
-
public function println():Void {
|
60
|
-
textArea.text += arguments.toString() + "\n";
|
61
|
-
}
|
62
|
-
|
63
|
-
public function printf():Void {
|
64
|
-
textArea.text += arguments.toString();
|
65
|
-
}
|
66
|
-
|
67
|
-
public function startTest(test:Test):Void {
|
68
|
-
var count:Number = test.countTestCases();
|
69
|
-
for(var i:Number = 0; i < count; i++) {
|
70
|
-
printf(".");
|
71
|
-
if (fColumn++ >= 80) {
|
72
|
-
println();
|
73
|
-
fColumn = 0;
|
74
|
-
}
|
75
|
-
}
|
76
|
-
}
|
77
|
-
|
78
|
-
public function addError(test:Test, e:Error):Void {
|
79
|
-
printf("E");
|
80
|
-
}
|
81
|
-
|
82
|
-
public function addFailure(test:Test, e:AssertionFailedError):Void {
|
83
|
-
printf("F");
|
84
|
-
}
|
85
|
-
|
86
|
-
public function endTest(test:Test):Void {
|
87
|
-
}
|
88
|
-
|
89
|
-
private function createTextArea():Void {
|
90
|
-
textArea = getTextField("textArea", 2);
|
91
|
-
}
|
92
|
-
|
93
|
-
private function createOutput():Void {
|
94
|
-
traceOutput = getTextField("output", 4);
|
95
|
-
traceOutput._visible = false;
|
96
|
-
var format:TextFormat = traceOutput.getTextFormat();
|
97
|
-
format.align = "right";
|
98
|
-
traceOutput.setNewTextFormat(format);
|
99
|
-
}
|
100
|
-
|
101
|
-
private function getTextField(name:String, depth:Number):TextField {
|
102
|
-
this.createTextField(name, depth, 0, 0, 100, 100);
|
103
|
-
var textField:TextField = this[name];
|
104
|
-
textField.wordWrap = true;
|
105
|
-
textField.multiline = true;
|
106
|
-
var format:TextFormat = new TextFormat();
|
107
|
-
format.font = "Verdana";
|
108
|
-
format.color = fontColor;
|
109
|
-
format.size = 11;
|
110
|
-
format.leftMargin = spacing/2;
|
111
|
-
format.rightMargin = spacing/2;
|
112
|
-
textField.setNewTextFormat(format);
|
113
|
-
return textField;
|
114
|
-
}
|
115
|
-
|
116
|
-
private function createSuccessBar():Void {
|
117
|
-
bar = SuccessBar(attachMovie(SuccessBar.linkageId, "bar", 3));
|
118
|
-
}
|
119
|
-
|
120
|
-
private function onResize():Void {
|
121
|
-
draw();
|
122
|
-
}
|
123
|
-
|
124
|
-
public function draw():Void {
|
125
|
-
var w:Number = Stage.width;
|
126
|
-
var h:Number = Stage.height;
|
127
|
-
drawBackground(w, h);
|
128
|
-
drawTextArea(w, h);
|
129
|
-
drawOutput(w, h);
|
130
|
-
drawBar(w, h);
|
131
|
-
}
|
132
|
-
|
133
|
-
private function drawBackground(w:Number, h:Number):Void {
|
134
|
-
clear();
|
135
|
-
beginFill(bgColor);
|
136
|
-
lineTo(w, 0);
|
137
|
-
lineTo(w, h);
|
138
|
-
lineTo(0, h);
|
139
|
-
lineTo(0, 0);
|
140
|
-
endFill();
|
141
|
-
}
|
142
|
-
|
143
|
-
private function drawTextArea(w:Number, h:Number):Void {
|
144
|
-
drawTextField(textArea, w, h);
|
145
|
-
}
|
146
|
-
|
147
|
-
private function drawOutput(w:Number, h:Number):Void {
|
148
|
-
drawTextField(traceOutput, w, h);
|
149
|
-
}
|
150
|
-
|
151
|
-
private function drawTextField(ref:TextField, w:Number, h:Number):Void {
|
152
|
-
ref._width = w - (spacing*2);
|
153
|
-
ref._height = h - (barHeight + (spacing*2));
|
154
|
-
ref._x = spacing;
|
155
|
-
ref._y = spacing;
|
156
|
-
}
|
157
|
-
|
158
|
-
private function drawBar(w:Number, h:Number):Void {
|
159
|
-
bar._x = 0;
|
160
|
-
bar._y = h - (barHeight);
|
161
|
-
bar.width = w;
|
162
|
-
bar.height = barHeight;
|
163
|
-
}
|
164
|
-
|
165
|
-
public function printResult(result:TestResult, runTime:Number):Void {
|
166
|
-
printHeader(runTime);
|
167
|
-
printErrors(result);
|
168
|
-
printFailures(result);
|
169
|
-
printFooter(result);
|
170
|
-
|
171
|
-
bar.setSuccess(result.wasSuccessful());
|
172
|
-
if(showTrace) {
|
173
|
-
trace(textArea.text);
|
174
|
-
}
|
175
|
-
}
|
176
|
-
|
177
|
-
private function printHeader(runTime:Number):Void {
|
178
|
-
println();
|
179
|
-
println();
|
180
|
-
println("Time: " + elapsedTimeAsString(runTime));
|
181
|
-
}
|
182
|
-
|
183
|
-
/**
|
184
|
-
* Returns the formatted string of the elapsed time.
|
185
|
-
* Duplicated from BaseTestRunner. Fix it.
|
186
|
-
*/
|
187
|
-
private function elapsedTimeAsString(runTime:Number):String {
|
188
|
-
return Number(runTime/1000).toString();
|
189
|
-
}
|
190
|
-
|
191
|
-
private function printErrors(result:TestResult):Void {
|
192
|
-
printDefects(result.errors(), result.errorCount(), "error");
|
193
|
-
}
|
194
|
-
|
195
|
-
private function printFailures(result:TestResult):Void {
|
196
|
-
printDefects(result.failures(), result.failureCount(), "failure");
|
197
|
-
}
|
198
|
-
|
199
|
-
private function printDefects(booBoos:Array, count:Number, type:String):Void {
|
200
|
-
if (count == 0) {
|
201
|
-
return;
|
202
|
-
}
|
203
|
-
if (count == 1) {
|
204
|
-
println("There was " + count + " " + type + ":");
|
205
|
-
}
|
206
|
-
else {
|
207
|
-
println("There were " + count + " " + type + "s:");
|
208
|
-
}
|
209
|
-
var item:TestFailure;
|
210
|
-
var len:Number = booBoos.length;
|
211
|
-
for(var i:Number = 0; i < len; i++) {
|
212
|
-
printDefect(TestFailure(booBoos[i]), i);
|
213
|
-
}
|
214
|
-
}
|
215
|
-
|
216
|
-
public function printDefect(booBoo:TestFailure, count:Number ):Void { // only public for testing purposes
|
217
|
-
printDefectHeader(booBoo, count);
|
218
|
-
printDefectTrace(booBoo);
|
219
|
-
}
|
220
|
-
|
221
|
-
private function printDefectTrace(booBoo:TestFailure):Void {
|
222
|
-
println(BaseTestRunner.getFilteredTrace(booBoo.thrownException().toString()));
|
223
|
-
}
|
224
|
-
|
225
|
-
private function printDefectHeader(booBoo:TestFailure, count:Number):Void {
|
226
|
-
// I feel like making this a println, then adding a line giving the throwable a chance to print something
|
227
|
-
// before we get to the stack trace.
|
228
|
-
var startIndex:Number = textArea.text.length;
|
229
|
-
println(count + ") " + booBoo.failedTest());
|
230
|
-
var endIndex:Number = textArea.text.length;
|
231
|
-
|
232
|
-
var format:TextFormat = textArea.getTextFormat();
|
233
|
-
format.bold = true;
|
234
|
-
|
235
|
-
// GROSS HACK because of bug in flash player - TextField isn't accepting formats...
|
236
|
-
// setTimeout(onFormatTimeout, 1, format, startIndex, endIndex);
|
237
|
-
}
|
238
|
-
|
239
|
-
private function printFooter(result:TestResult):Void {
|
240
|
-
println();
|
241
|
-
if (result.wasSuccessful()) {
|
242
|
-
printf("OK");
|
243
|
-
println (" (" + result.runCount() + " test" + (result.runCount() == 1 ? "": "s") + ")");
|
244
|
-
} else {
|
245
|
-
println("FAILURES!!!");
|
246
|
-
println("Tests run: " + result.runCount()+
|
247
|
-
", Failures: "+result.failureCount()+
|
248
|
-
", Errors: "+result.errorCount());
|
249
|
-
}
|
250
|
-
println();
|
251
|
-
}
|
252
|
-
|
253
|
-
public static var serializable:Boolean = Object.registerClass(linkageId, classRef);
|
254
|
-
}
|