asproject 0.1.21
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +0 -0
- data/History.txt +0 -0
- data/MIT-LICENSE.txt +20 -0
- data/Manifest.txt +16 -0
- data/README.txt +3 -0
- data/TODO.txt +10 -0
- data/bin/asclass +16 -0
- data/bin/asproject +16 -0
- data/lib/asclass.rb +254 -0
- data/lib/asclass_arguments.rb +147 -0
- data/lib/asproject.rb +248 -0
- data/lib/asproject/version.rb +9 -0
- data/lib/asproject_arguments.rb +175 -0
- data/lib/asproject_base.rb +43 -0
- data/lib/asproject_utils.rb +57 -0
- data/lib/eclipse_project.rb +32 -0
- data/lib/path_finder.rb +286 -0
- data/lib/platform.rb +107 -0
- data/lib/project.rb +82 -0
- data/lib/template_resolver.rb +144 -0
- data/lib/test_suite_generator.rb +128 -0
- data/rakefile.rb +85 -0
- data/setup.rb +1585 -0
- data/templates/asclass/as2/Class.as +11 -0
- data/templates/asclass/as2/Component.as +8 -0
- data/templates/asclass/as2/Interface.as +3 -0
- data/templates/asclass/as2/TestCase.as +30 -0
- data/templates/asclass/as2/TestSuite.as +15 -0
- data/templates/asclass/as3/Class.as +9 -0
- data/templates/asclass/as3/Component.as +9 -0
- data/templates/asclass/as3/Component.mxml +1 -0
- data/templates/asclass/as3/Interface.as +6 -0
- data/templates/asclass/as3/TestCase.as +30 -0
- data/templates/asclass/as3/TestSuite.as +18 -0
- data/templates/asproject/as2/project/rakefile.rb +18 -0
- data/templates/asproject/as2/project/src/AsProject.as +13 -0
- data/templates/asproject/as2/project/test/AsProjectRunner.as +12 -0
- data/templates/asproject/as3/project/rakefile.rb +18 -0
- data/templates/asproject/as3/project/src/AsProject.as +9 -0
- data/templates/asproject/as3/project/src/AsProjectRunner.as +11 -0
- data/templates/asproject/asunit2/project/lib/asunit/AsUnitUi.swf +0 -0
- data/templates/asproject/asunit2/project/lib/asunit/Sys.as +70 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanel.as +182 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTest.as +84 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextArea.as +111 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextAreaTest.as +26 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTitleBar.as +81 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ResizeHandle.as +35 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollArrow.as +34 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollHandle.as +43 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollListener.as +10 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/TextScroller.as +169 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Rectangle.as +29 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Triangle.as +27 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/AsUnit.as +19 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assert.as +408 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assertion.as +27 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as +68 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Test.as +3 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCase.as +191 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCaseXml.as +31 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestFailure.as +15 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestResult.as +15 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestRunner.as +41 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSetup.as +19 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSuite.as +22 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/Main.as +325 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/RemoteVersion.as +24 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/SuccessMeter.as +32 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Comparable.as +7 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventListener.as +29 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventSource.as +89 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnClient.as +42 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnGateway.as +47 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnServer.as +61 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalMessageBroker.as +58 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Observable.as +11 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/TextFile.as +30 -0
- data/templates/asproject/asunit25/project/lib/asunit/AsUnitTestRunner.as +13 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionFailedError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionPassedError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/ClassNotFoundError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/IllegalOperationError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InvocationTargetError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Assert.as +376 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertMock.as +15 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertTest.as +59 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/ITestListener.as +13 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Test.as +11 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCase.as +277 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseMock.as +23 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseTest.as +29 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseXml.as +38 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestFailure.as +47 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestResult.as +168 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestSuite.as +102 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/BaseTestRunner.as +101 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/IResultPrinter.as +8 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/ResultPrinter.as +254 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/SuccessBar.as +41 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/TestRunner.as +17 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIterator.as +24 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIteratorTest.as +52 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/Iterator.as +5 -0
- data/templates/asproject/asunit3/project/lib/asunit/AsUnitTestRunner.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AbstractMemberCalledError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AssertionFailedError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/ClassNotFoundError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Assert.as +271 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCase.as +52 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCaseExample.as +71 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Test.as +15 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCase.as +351 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCaseExample.as +73 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestFailure.as +47 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestListener.as +22 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestResult.as +158 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestSuite.as +115 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/BaseTestRunner.as +15 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/TestSuiteLoader.as +9 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/Version.as +11 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexRunner.as +19 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexTestRunner.as +55 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/ResultPrinter.as +245 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/TestRunner.as +121 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/ArrayIterator.as +26 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Iterator.as +9 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Properties.as +30 -0
- data/templates/asproject/asunit3/project/lib/asunit/mx/managers/LayoutManager.as +945 -0
- data/templates/asproject/config/project/config/asclass_config.rb +58 -0
- data/templates/asproject/fb2as/project/.actionScriptProperties +21 -0
- data/templates/asproject/fb2as/project/.project +29 -0
- data/templates/asproject/fdt/project/.as2_classpath +6 -0
- data/templates/asproject/fdt/project/.project +19 -0
- data/templates/ide/mate/Create Class.tmCommand +37 -0
- data/templates/ide/mate/Rebuild Test Suites.tmCommand +33 -0
- data/templates/ide/mate/Run Rake Task.tmCommand +127 -0
- metadata +266 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
|
2
|
+
import asunit.framework.Assert;
|
3
|
+
import asunit.framework.TestCase;
|
4
|
+
import asunit.errors.AssertionFailedError;
|
5
|
+
import asunit.framework.AssertMock;
|
6
|
+
import asunit.errors.IllegalOperationError;
|
7
|
+
|
8
|
+
class asunit.framework.AssertTest extends TestCase {
|
9
|
+
private var className:String = "asunit.framework.AssertTest";
|
10
|
+
private var instance:AssertMock;
|
11
|
+
|
12
|
+
public function AssertTest(testMethod:String) {
|
13
|
+
super(testMethod);
|
14
|
+
}
|
15
|
+
|
16
|
+
public function setUp():Void {
|
17
|
+
instance = new AssertMock();
|
18
|
+
}
|
19
|
+
|
20
|
+
public function tearDown():Void {
|
21
|
+
delete instance;
|
22
|
+
}
|
23
|
+
|
24
|
+
public function testAssertTrueFailureA():Void {
|
25
|
+
try {
|
26
|
+
instance.assertTrue(false);
|
27
|
+
fail("assertTrue(false) should throw");
|
28
|
+
}
|
29
|
+
catch(e) {
|
30
|
+
if(!(e instanceof AssertionFailedError)) {
|
31
|
+
fail("assertTrue should have thrown an AssertionFailedError");
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
// instance.assertTrue("faux message", false);
|
37
|
+
|
38
|
+
public function testAssertTrueTooManyArgs():Void {
|
39
|
+
try {
|
40
|
+
instance.assertTrue("faux message", false, false);
|
41
|
+
fail("assertTrue should have failed with too many args");
|
42
|
+
}
|
43
|
+
catch(e) {
|
44
|
+
if(!(e instanceof IllegalOperationError)) {
|
45
|
+
fail(e.toString());
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
public function testAssertTrueSuccess():Void {
|
51
|
+
try {
|
52
|
+
instance.assertTrue(true);
|
53
|
+
instance.assertTrue("faux message", true);
|
54
|
+
}
|
55
|
+
catch(e) {
|
56
|
+
fail("assertTrue should not have thrown");
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import asunit.errors.AssertionFailedError;
|
2
|
+
import asunit.framework.Test;
|
3
|
+
|
4
|
+
interface asunit.framework.ITestListener {
|
5
|
+
// A test started.
|
6
|
+
public function startTest(test:Test):Void;
|
7
|
+
// An error occurred.
|
8
|
+
public function addError(test:Test, e:Error):Void;
|
9
|
+
// A failure occurred.
|
10
|
+
public function addFailure(test:Test, e:AssertionFailedError):Void;
|
11
|
+
// A test ended.
|
12
|
+
public function endTest(test:Test):Void;
|
13
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import asunit.framework.TestResult;
|
2
|
+
|
3
|
+
interface asunit.framework.Test {
|
4
|
+
|
5
|
+
public function testsComplete():Boolean;
|
6
|
+
public function setResult(result:TestResult):Void;
|
7
|
+
public function setContext(context:MovieClip):Void;
|
8
|
+
public function run():Void;
|
9
|
+
public function countTestCases():Number;
|
10
|
+
public function toString():String;
|
11
|
+
}
|
@@ -0,0 +1,277 @@
|
|
1
|
+
import asunit.framework.Assert;
|
2
|
+
import asunit.framework.Test;
|
3
|
+
import asunit.framework.TestResult;
|
4
|
+
import asunit.errors.AssertionFailedError;
|
5
|
+
|
6
|
+
class asunit.framework.TestCase extends Assert implements Test {
|
7
|
+
private var className:String = "[default]";
|
8
|
+
|
9
|
+
private var testMethodsExecuted:Number = 0;
|
10
|
+
private var result:TestResult;
|
11
|
+
private var context:MovieClip;
|
12
|
+
private var currentMethod:String;
|
13
|
+
private var runSingle:Boolean;
|
14
|
+
private var isComplete:Boolean;
|
15
|
+
|
16
|
+
public function TestCase(testMethod:String) {
|
17
|
+
if(testMethod != undefined) {
|
18
|
+
runSingle = true;
|
19
|
+
currentMethod = testMethod;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
/*
|
24
|
+
* You can choose to override this method when implementing
|
25
|
+
* asynchronous test cases.
|
26
|
+
* By default, the TestCaseXml object will call back to this
|
27
|
+
* method and begin execution of the test case.
|
28
|
+
*/
|
29
|
+
public function onXmlLoaded(node:XMLNode):Void {
|
30
|
+
runNow();
|
31
|
+
}
|
32
|
+
|
33
|
+
/*
|
34
|
+
* By default, this method will be triggered from
|
35
|
+
* a TestCaseXml instance. If there is a problem
|
36
|
+
* an error will be shown in the output.
|
37
|
+
*/
|
38
|
+
public function onXmlFailure(node:XML):Void {
|
39
|
+
currentMethod = "onXmlFailure";
|
40
|
+
getResult().addError(this, new Error("TestCaseXml failed to load successfully: " + node.toString()));
|
41
|
+
runNow();
|
42
|
+
}
|
43
|
+
|
44
|
+
public function testsComplete():Boolean {
|
45
|
+
return (getTestMethods().length == testMethodsExecuted);
|
46
|
+
}
|
47
|
+
|
48
|
+
public function countTestCases():Number {
|
49
|
+
return getTestMethods().length;
|
50
|
+
}
|
51
|
+
|
52
|
+
/*
|
53
|
+
* setUp() is called before each method that begins with "test*"
|
54
|
+
* This method should used to instantiate common fixtures
|
55
|
+
*/
|
56
|
+
private function setUp():Void {
|
57
|
+
}
|
58
|
+
|
59
|
+
/*
|
60
|
+
* tearDown() is called after each method that begins with "test*"
|
61
|
+
* This method should be used to destroy any objects created from
|
62
|
+
* the setUp() method call
|
63
|
+
*/
|
64
|
+
private function tearDown():Void {
|
65
|
+
}
|
66
|
+
|
67
|
+
/* cleanUp() is called one time after all test methods have completed
|
68
|
+
* in a single TestCase. This is typically overridden and used to
|
69
|
+
* clean up after an Asynchronous TestCase has completed.
|
70
|
+
*/
|
71
|
+
private function cleanUp():Void {
|
72
|
+
}
|
73
|
+
|
74
|
+
public function setResult(result:TestResult):Void {
|
75
|
+
this.result = result;
|
76
|
+
}
|
77
|
+
|
78
|
+
private function getResult():TestResult {
|
79
|
+
return result;
|
80
|
+
}
|
81
|
+
|
82
|
+
public function setContext(context:MovieClip):Void {
|
83
|
+
this.context = context;
|
84
|
+
}
|
85
|
+
|
86
|
+
public function getContext():MovieClip {
|
87
|
+
return context;
|
88
|
+
}
|
89
|
+
|
90
|
+
public function run():Void {
|
91
|
+
runNow();
|
92
|
+
}
|
93
|
+
|
94
|
+
private function runNow():Void {
|
95
|
+
var result:TestResult = getResult();
|
96
|
+
result.run(this);
|
97
|
+
}
|
98
|
+
|
99
|
+
public function runBare():Void {
|
100
|
+
var methods:Array = getTestMethods();
|
101
|
+
var name:String;
|
102
|
+
try {
|
103
|
+
var len:Number = methods.length;
|
104
|
+
for(var i:Number = 0; i < len; i++) {
|
105
|
+
name = methods[i];
|
106
|
+
try {
|
107
|
+
runMethod(name);
|
108
|
+
}
|
109
|
+
catch(e:Error) {
|
110
|
+
if(e instanceof AssertionFailedError) {
|
111
|
+
result.addFailure(this, AssertionFailedError(e));
|
112
|
+
}
|
113
|
+
else {
|
114
|
+
result.addError(this, e);
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
finally {
|
120
|
+
if(!runSingle) {
|
121
|
+
cleanUp();
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
isComplete = true;
|
126
|
+
}
|
127
|
+
|
128
|
+
private function runMethod(methodName:String):Void {
|
129
|
+
currentMethod = methodName;
|
130
|
+
try {
|
131
|
+
setUp();
|
132
|
+
this[methodName]();
|
133
|
+
}
|
134
|
+
finally {
|
135
|
+
if(!runSingle) {
|
136
|
+
tearDown();
|
137
|
+
}
|
138
|
+
testMethodsExecuted++;
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
private function getTestMethods():Array {
|
143
|
+
if(runSingle) {
|
144
|
+
return new Array(currentMethod);
|
145
|
+
}
|
146
|
+
var methods:Array = new Array();
|
147
|
+
_global.ASSetPropFlags(this.__proto__, null, 6, true);
|
148
|
+
for(var i:String in this) {
|
149
|
+
if(i.indexOf("test") == 0 && this[i] instanceof Function) {
|
150
|
+
methods.push(i);
|
151
|
+
}
|
152
|
+
}
|
153
|
+
_global.ASSetPropFlags(this.__proto__, null, 1, true);
|
154
|
+
methods.reverse();
|
155
|
+
return methods;
|
156
|
+
}
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Returns the name of the currently running test method. This
|
160
|
+
* method is intended for use by the AsUnit framework and should never
|
161
|
+
* have to be called directly.
|
162
|
+
*
|
163
|
+
* @return
|
164
|
+
* A method name. Ex. <code>"testGetValue"</code>.
|
165
|
+
*/
|
166
|
+
public function getCurrentMethod():String {
|
167
|
+
return currentMethod;
|
168
|
+
}
|
169
|
+
|
170
|
+
public function toString():String {
|
171
|
+
return getName() + "." + getCurrentMethod() + "()";
|
172
|
+
}
|
173
|
+
|
174
|
+
public function getName():String {
|
175
|
+
return className;
|
176
|
+
}
|
177
|
+
|
178
|
+
private function createEmptyMovieClip(name:String, depth:Number):MovieClip {
|
179
|
+
return getContext().createEmptyMovieClip(name, depth);
|
180
|
+
}
|
181
|
+
|
182
|
+
private function createTextField(name:String, depth:Number, x:Number, y:Number, width:Number, height:Number):TextField {
|
183
|
+
getContext().createTextField(name, depth, x, y, width, height);
|
184
|
+
return TextField(getContext()[name]);
|
185
|
+
}
|
186
|
+
|
187
|
+
private function getNextHighestDepth():Number {
|
188
|
+
return getContext().getNextHighestDepth();
|
189
|
+
}
|
190
|
+
|
191
|
+
/*
|
192
|
+
* This helper method will support the following method signatures:
|
193
|
+
*
|
194
|
+
* attachMovie(linkageId:String):MovieClip;
|
195
|
+
* attachMovie(linkageId:String, initObject:Object):MovieClip;
|
196
|
+
* attachMovie(linkageId:String, name:String, depth:Number):MovieClip;
|
197
|
+
* attachMovie(linkageId:String, name:String, depth:Number, initObject:Object):MovieClip;
|
198
|
+
*
|
199
|
+
* @return
|
200
|
+
* MovieClip
|
201
|
+
*/
|
202
|
+
private function attachMovie():MovieClip {
|
203
|
+
var linkageId:String = arguments[0];
|
204
|
+
var name:String;
|
205
|
+
var depth:Number;
|
206
|
+
var initObj:Object = new Object();
|
207
|
+
|
208
|
+
switch(arguments.length) {
|
209
|
+
case 1 :
|
210
|
+
case 2 :
|
211
|
+
name = getValidName(getContext(), name);
|
212
|
+
depth = getValidDepth(getContext());
|
213
|
+
initObj = arguments[1];
|
214
|
+
break;
|
215
|
+
case 3 :
|
216
|
+
case 4 :
|
217
|
+
name = arguments[1];
|
218
|
+
depth = arguments[2];
|
219
|
+
initObj = arguments[3];
|
220
|
+
break;
|
221
|
+
}
|
222
|
+
return getContext().attachMovie(linkageId, name, depth, initObj);
|
223
|
+
}
|
224
|
+
|
225
|
+
public function getUpperEmptyDepth(parent:MovieClip, depth:Number):Number {
|
226
|
+
if(depth == undefined || !isValidDepth(parent, depth)) {
|
227
|
+
var high:Number = (depth == undefined) ? 1 : depth;
|
228
|
+
for(var i:String in parent) {
|
229
|
+
if(parent[i] instanceof MovieClip && parent[i].getDepth() != undefined) {
|
230
|
+
high = Math.max(parent[i].getDepth()+1, high);
|
231
|
+
}
|
232
|
+
}
|
233
|
+
return high;
|
234
|
+
}
|
235
|
+
return depth;
|
236
|
+
}
|
237
|
+
|
238
|
+
private function getValidName(parent:MovieClip, nm:Object):String {
|
239
|
+
var incr:Number = 1;
|
240
|
+
|
241
|
+
var name:String = (nm == undefined || nm instanceof Object) ? "item" : nm.toString();
|
242
|
+
var ref:MovieClip = parent[name];
|
243
|
+
|
244
|
+
var name2:String = name;
|
245
|
+
while(ref != undefined && incr < 100) {
|
246
|
+
name2 = name + "-" + (incr++);
|
247
|
+
ref = parent[name2];
|
248
|
+
}
|
249
|
+
return name2;
|
250
|
+
}
|
251
|
+
|
252
|
+
private function isValidDepth(parent:MovieClip, depth:Number):Boolean {
|
253
|
+
var item:MovieClip = getItemByDepth(parent, depth);
|
254
|
+
return (item == null) ? true : false;
|
255
|
+
}
|
256
|
+
|
257
|
+
private function getItemByDepth(parent:MovieClip, depth:Number):MovieClip {
|
258
|
+
for(var i:String in parent) {
|
259
|
+
if(parent[i].getDepth() == depth) {
|
260
|
+
return parent[i];
|
261
|
+
}
|
262
|
+
}
|
263
|
+
return null;
|
264
|
+
}
|
265
|
+
|
266
|
+
private function getValidDepth(mc:MovieClip):Number {
|
267
|
+
var mcDepth:Number;
|
268
|
+
var dp:Number = nextDepth();
|
269
|
+
for(var i:String in mc) {
|
270
|
+
mcDepth = mc[i].getDepth();
|
271
|
+
if(mc[i] instanceof MovieClip && mcDepth < 10000) {
|
272
|
+
dp = Math.max(mcDepth, dp);
|
273
|
+
}
|
274
|
+
}
|
275
|
+
return ++dp;
|
276
|
+
}
|
277
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
class asunit.framework.TestCaseMock extends MovieClip {
|
3
|
+
public static var linkageId:String = "__Packages.asunit.framework.TestCaseMock";
|
4
|
+
public static var classRef:Function = TestCaseMock;
|
5
|
+
|
6
|
+
public function TestCaseMock() {
|
7
|
+
draw();
|
8
|
+
}
|
9
|
+
|
10
|
+
public function draw():Void {
|
11
|
+
var w:Number = 100;
|
12
|
+
var h:Number = 100;
|
13
|
+
clear();
|
14
|
+
beginFill(0xFFCC00);
|
15
|
+
lineTo(w, 0);
|
16
|
+
lineTo(w, h);
|
17
|
+
lineTo(0, h);
|
18
|
+
lineTo(0, 0);
|
19
|
+
endFill();
|
20
|
+
}
|
21
|
+
|
22
|
+
public static var serializable:Boolean = Object.registerClass(linkageId, classRef);
|
23
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
import asunit.framework.TestCaseMock;
|
3
|
+
import asunit.framework.TestCase;
|
4
|
+
|
5
|
+
class asunit.framework.TestCaseTest extends TestCase {
|
6
|
+
private var className:String = "asunit.framework.TestCaseTest";
|
7
|
+
private var instance:TestCaseMock;
|
8
|
+
|
9
|
+
public function TestCaseTest(testMethod:String) {
|
10
|
+
super(testMethod);
|
11
|
+
}
|
12
|
+
|
13
|
+
public function setUp():Void {
|
14
|
+
var initObj:Object = new Object();
|
15
|
+
instance = TestCaseMock(attachMovie(TestCaseMock.linkageId, initObj));
|
16
|
+
}
|
17
|
+
|
18
|
+
public function tearDown():Void {
|
19
|
+
instance.removeMovieClip();
|
20
|
+
delete instance;
|
21
|
+
}
|
22
|
+
|
23
|
+
public function testInstantiated():Void {
|
24
|
+
assertTrue("TestCaseMock instantiated", instance instanceof TestCaseMock);
|
25
|
+
}
|
26
|
+
|
27
|
+
public function testView():Void {
|
28
|
+
}
|
29
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
import asunit.framework.TestCase;
|
3
|
+
|
4
|
+
class asunit.framework.TestCaseXml extends XML {
|
5
|
+
public static var linkageId:String = "asunit.framework.TestCaseXml";
|
6
|
+
public static var classRef:Function = TestCaseXml;
|
7
|
+
|
8
|
+
private var source:String;
|
9
|
+
private var callback:TestCase;
|
10
|
+
|
11
|
+
public function TestCaseXml(src:String, cb:TestCase) {
|
12
|
+
source = src;
|
13
|
+
callback = cb;
|
14
|
+
ignoreWhite = true;
|
15
|
+
if(src != undefined) {
|
16
|
+
load(source);
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
public function onData(data:String):Void {
|
21
|
+
if(data == "" || data == undefined) {
|
22
|
+
callback.onXmlFailure(this);
|
23
|
+
}
|
24
|
+
else {
|
25
|
+
super.onData(data);
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
public function onLoad(success:Boolean):Void {
|
30
|
+
if(success) {
|
31
|
+
callback.onXmlLoaded(this.firstChild);
|
32
|
+
} else {
|
33
|
+
callback.onXmlFailure(this);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
public static var serializable:Boolean = Object.registerClass(linkageId, classRef);
|
38
|
+
}
|