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,27 @@
|
|
1
|
+
|
2
|
+
class com.asunit.framework.Assertion {
|
3
|
+
private var className:String;
|
4
|
+
private var methodName:String;
|
5
|
+
private var message:String;
|
6
|
+
private var assertion:String;
|
7
|
+
private var passed:Boolean;
|
8
|
+
|
9
|
+
private function Assertion(cName:String, mName:String, msg:String, assert:String)
|
10
|
+
{
|
11
|
+
className = cName;
|
12
|
+
methodName = mName;
|
13
|
+
message = msg;
|
14
|
+
assertion = assert;
|
15
|
+
}
|
16
|
+
|
17
|
+
public function toString():String
|
18
|
+
{
|
19
|
+
var str:String = "";
|
20
|
+
for(var i:String in this) {
|
21
|
+
if(!(this[i] instanceof Function)) {
|
22
|
+
str += i + " : " + this[i] + "\n";
|
23
|
+
}
|
24
|
+
}
|
25
|
+
return str;
|
26
|
+
}
|
27
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
|
2
|
+
import com.asunit.framework.*;
|
3
|
+
|
4
|
+
class com.asunit.framework.Reflection {
|
5
|
+
private var visitedObjects:Array;
|
6
|
+
private var qualifiedName:String;
|
7
|
+
|
8
|
+
public static function getQualifiedName(ref:Object)
|
9
|
+
{
|
10
|
+
return new Reflection(ref).toString();
|
11
|
+
}
|
12
|
+
|
13
|
+
// Use static Constructor / getQualifiedName
|
14
|
+
private function Reflection(ref:Object)
|
15
|
+
{
|
16
|
+
visitedObjects = new Array();
|
17
|
+
qualifiedName = getNameSpace("", _global, ref);
|
18
|
+
}
|
19
|
+
|
20
|
+
public function toString()
|
21
|
+
{
|
22
|
+
return qualifiedName;
|
23
|
+
}
|
24
|
+
|
25
|
+
public function beenVisited(obj:Object):Boolean
|
26
|
+
{
|
27
|
+
for(var i in visitedObjects) {
|
28
|
+
if(visitedObjects[i] == obj) {
|
29
|
+
return true;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
return false;
|
33
|
+
}
|
34
|
+
|
35
|
+
public function openMember(ref:Object)
|
36
|
+
{
|
37
|
+
_global.ASSetPropFlags(ref, null, 6, true);
|
38
|
+
}
|
39
|
+
|
40
|
+
public function closeMember(ref:Object)
|
41
|
+
{
|
42
|
+
_global.ASSetPropFlags(ref, null, 0, true);
|
43
|
+
}
|
44
|
+
|
45
|
+
public function getNameSpace(name:String, ref:Object, obj:Object)
|
46
|
+
{
|
47
|
+
if(!beenVisited(ref)) {
|
48
|
+
var str = name;
|
49
|
+
openMember(ref);
|
50
|
+
visitedObjects.push(ref);
|
51
|
+
for(var i in ref) {
|
52
|
+
if(i == "prototype" || i == "__proto__" || i == "toLocaleString" || i == "constructor") {
|
53
|
+
continue;
|
54
|
+
}
|
55
|
+
str += ((str == "") ? "" :".") + i;
|
56
|
+
if(ref[i] == obj) {
|
57
|
+
closeMember(ref);
|
58
|
+
return str;
|
59
|
+
}
|
60
|
+
closeMember(ref);
|
61
|
+
// check here so that looping continues if result is invalid...
|
62
|
+
return getNameSpace(str, ref[i], obj);
|
63
|
+
}
|
64
|
+
closeMember(ref);
|
65
|
+
return str;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
@@ -0,0 +1,191 @@
|
|
1
|
+
|
2
|
+
import com.asunit.framework.*;
|
3
|
+
import com.asunit.util.*;
|
4
|
+
|
5
|
+
class com.asunit.framework.TestCase extends Assert implements Test {
|
6
|
+
private var methods:Array;
|
7
|
+
private var className:String = "[ClassName Unknown]";
|
8
|
+
|
9
|
+
// Abstract Class
|
10
|
+
private function TestCase()
|
11
|
+
{
|
12
|
+
init();
|
13
|
+
}
|
14
|
+
|
15
|
+
private function init()
|
16
|
+
{
|
17
|
+
checkClassName(className);
|
18
|
+
run();
|
19
|
+
}
|
20
|
+
|
21
|
+
private function checkClassName(name:String)
|
22
|
+
{
|
23
|
+
}
|
24
|
+
|
25
|
+
private function getClassName():String
|
26
|
+
{
|
27
|
+
return className;
|
28
|
+
}
|
29
|
+
|
30
|
+
private function getHiddenMembers():Object
|
31
|
+
{
|
32
|
+
var obj:Object = new Object();
|
33
|
+
obj.testFailed = true;
|
34
|
+
obj.testSucceeded = true;
|
35
|
+
obj.testMembers = true;
|
36
|
+
return obj;
|
37
|
+
}
|
38
|
+
|
39
|
+
private function getMethods():Array
|
40
|
+
{
|
41
|
+
var arr:Array = new Array();
|
42
|
+
var hiddenMembers:Object = getHiddenMembers();
|
43
|
+
|
44
|
+
_global.ASSetPropFlags(this.__proto__, null, 6, true);
|
45
|
+
for(var i:String in this) {
|
46
|
+
if(i.indexOf("test") == 0 && !hiddenMembers[i] && this[i] instanceof Function) {
|
47
|
+
arr.push(i);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
_global.ASSetPropFlags(this.__proto__, null, 1, true);
|
51
|
+
arr.reverse();
|
52
|
+
return arr;
|
53
|
+
}
|
54
|
+
|
55
|
+
private function runMethod(method:String)
|
56
|
+
{
|
57
|
+
setUp();
|
58
|
+
setCurrentMethod(method);
|
59
|
+
this[method]();
|
60
|
+
tearDown();
|
61
|
+
}
|
62
|
+
|
63
|
+
private function createEmptyMovieClip(name:String, depth:Number):MovieClip {
|
64
|
+
return _root.createEmptyMovieClip(name, depth);
|
65
|
+
}
|
66
|
+
|
67
|
+
private function createTextField(name:String, depth:Number, x:Number, y:Number, width:Number, height:Number):TextField {
|
68
|
+
_root.createTextField(name, depth, x, y, width, height);
|
69
|
+
return TextField(_root[name]);
|
70
|
+
}
|
71
|
+
|
72
|
+
private function getNextHighestDepth():Number {
|
73
|
+
return _root.getNextHighestDepth();
|
74
|
+
}
|
75
|
+
|
76
|
+
// This helper method will support the following method signatures:
|
77
|
+
// attachMovie(linkageId:String):MovieClip;
|
78
|
+
// attachMovie(linkageId:String, initObject:Object):MovieClip;
|
79
|
+
// attachMovie(linkageId:String, name:String, depth:Number):MovieClip;
|
80
|
+
// attachMovie(linkageId:String, name:String, depth:Number, initObject:Object):MovieClip;
|
81
|
+
private function attachMovie():MovieClip {
|
82
|
+
var linkageId:String = arguments[0];
|
83
|
+
var name:String;
|
84
|
+
var depth:Number;
|
85
|
+
var initObj:Object = new Object();
|
86
|
+
|
87
|
+
switch(arguments.length) {
|
88
|
+
case 1 :
|
89
|
+
case 2 :
|
90
|
+
name = getValidName(_root, name);
|
91
|
+
depth = getValidDepth(_root);
|
92
|
+
initObj = arguments[1];
|
93
|
+
break;
|
94
|
+
case 3 :
|
95
|
+
case 4 :
|
96
|
+
name = arguments[1];
|
97
|
+
depth = arguments[2];
|
98
|
+
initObj = arguments[3];
|
99
|
+
break;
|
100
|
+
}
|
101
|
+
return _root.attachMovie(linkageId, name, depth, initObj);
|
102
|
+
}
|
103
|
+
|
104
|
+
public function getUpperEmptyDepth(parent:MovieClip, depth:Number):Number {
|
105
|
+
if(depth == undefined || !isValidDepth(parent, depth)) {
|
106
|
+
var high:Number = (depth == undefined) ? 1 : depth;
|
107
|
+
for(var i:String in parent) {
|
108
|
+
if(parent[i] instanceof MovieClip && parent[i].getDepth() != undefined) {
|
109
|
+
high = Math.max(parent[i].getDepth()+1, high);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
return high;
|
113
|
+
}
|
114
|
+
return depth;
|
115
|
+
}
|
116
|
+
|
117
|
+
private function getValidName(parent:MovieClip, nm:Object):String {
|
118
|
+
var incr:Number = 1;
|
119
|
+
|
120
|
+
var name:String = (nm == undefined || nm instanceof Object) ? "item" : nm.toString();
|
121
|
+
var ref:MovieClip = parent[name];
|
122
|
+
|
123
|
+
var name2:String = name;
|
124
|
+
while(ref != undefined && incr < 100) {
|
125
|
+
name2 = name + "-" + (incr++);
|
126
|
+
ref = parent[name2];
|
127
|
+
}
|
128
|
+
return name2;
|
129
|
+
}
|
130
|
+
|
131
|
+
private function isValidDepth(parent:MovieClip, depth:Number):Boolean {
|
132
|
+
var item:MovieClip = getItemByDepth(parent, depth);
|
133
|
+
return (item == null) ? true : false;
|
134
|
+
}
|
135
|
+
|
136
|
+
private function getItemByDepth(parent:MovieClip, depth:Number):MovieClip {
|
137
|
+
for(var i:String in parent) {
|
138
|
+
if(parent[i].getDepth() == depth) {
|
139
|
+
return parent[i];
|
140
|
+
}
|
141
|
+
}
|
142
|
+
return null;
|
143
|
+
}
|
144
|
+
|
145
|
+
private function getValidDepth(mc:MovieClip):Number {
|
146
|
+
var mcDepth:Number;
|
147
|
+
var dp:Number = nextDepth();
|
148
|
+
for(var i:String in mc) {
|
149
|
+
mcDepth = mc[i].getDepth();
|
150
|
+
if(mc[i] instanceof MovieClip && mcDepth < 10000) {
|
151
|
+
dp = Math.max(mcDepth, dp);
|
152
|
+
}
|
153
|
+
}
|
154
|
+
return ++dp;
|
155
|
+
}
|
156
|
+
|
157
|
+
private function run():Void
|
158
|
+
{
|
159
|
+
setCurrentClassName(className);
|
160
|
+
var mList:Array = getMethods();
|
161
|
+
for(var i:Number=0; i<mList.length; i++) {
|
162
|
+
runMethod(mList[i]);
|
163
|
+
}
|
164
|
+
cleanUp();
|
165
|
+
}
|
166
|
+
|
167
|
+
public function cleanUp():Void {
|
168
|
+
}
|
169
|
+
|
170
|
+
public function onXmlLoaded(node:XMLNode):Void {
|
171
|
+
}
|
172
|
+
|
173
|
+
public function onTextFileLoaded(obj:TextFile):Void {
|
174
|
+
}
|
175
|
+
|
176
|
+
private function testFailed():Void
|
177
|
+
{
|
178
|
+
}
|
179
|
+
|
180
|
+
private function testSucceeded():Void
|
181
|
+
{
|
182
|
+
}
|
183
|
+
|
184
|
+
public function setUp():Void
|
185
|
+
{
|
186
|
+
}
|
187
|
+
|
188
|
+
public function tearDown():Void
|
189
|
+
{
|
190
|
+
}
|
191
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
import com.asunit.framework.*;
|
3
|
+
|
4
|
+
class com.asunit.framework.TestCaseXml extends XML {
|
5
|
+
|
6
|
+
public static var linkageId:String = "com.asunit.framework.TestCaseXml";
|
7
|
+
public static var classRef:Function = TestCaseXml;
|
8
|
+
|
9
|
+
private var source:String;
|
10
|
+
private var callback:TestCase;
|
11
|
+
|
12
|
+
public function TestCaseXml(src:String, cb:TestCase) {
|
13
|
+
source = src;
|
14
|
+
callback = cb;
|
15
|
+
ignoreWhite = true;
|
16
|
+
onLoad = doLoad;
|
17
|
+
if(src != undefined) {
|
18
|
+
load(source);
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
public function doLoad(success:Boolean):Void {
|
23
|
+
if(success) {
|
24
|
+
callback.onXmlLoaded(this.firstChild);
|
25
|
+
} else {
|
26
|
+
Sys.println(">> there was an error loading XML at : " + source);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
public static var serializable:Boolean = Object.registerClass(linkageId, classRef);
|
31
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
import com.asunit.framework.*;
|
3
|
+
|
4
|
+
class com.asunit.framework.TestFailure extends Assertion implements Test {
|
5
|
+
|
6
|
+
public var output:String = "F";
|
7
|
+
public var success:Boolean = false;
|
8
|
+
|
9
|
+
public function TestFailure(cName:String, mName:String, msg:String, assertion:String)
|
10
|
+
{
|
11
|
+
super(cName, mName, msg, assertion);
|
12
|
+
output = "F";
|
13
|
+
success = false;
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
import com.asunit.framework.*;
|
3
|
+
|
4
|
+
class com.asunit.framework.TestResult extends Assertion implements Test {
|
5
|
+
|
6
|
+
public var output:String;
|
7
|
+
public var success:Boolean;
|
8
|
+
|
9
|
+
public function TestResult(cName:String, mName:String, msg:String, assertion:String)
|
10
|
+
{
|
11
|
+
super(cName, mName, msg, assertion);
|
12
|
+
output = ".";
|
13
|
+
success = true;
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
import com.asunit.framework.*;
|
3
|
+
import com.asunit.util.*;
|
4
|
+
|
5
|
+
class com.asunit.framework.TestRunner extends Array {
|
6
|
+
public static var localConn:LocalConnClient;
|
7
|
+
private var intervalId:Number;
|
8
|
+
private var interval:Number = 10;
|
9
|
+
private var tests:Array;
|
10
|
+
|
11
|
+
private static function getLocalConn():LocalConnClient {
|
12
|
+
if(localConn == null) {
|
13
|
+
localConn = LocalConnGateway.createClient("_AsUnitTestRunner");
|
14
|
+
localConn["clearTestDisplay"]();
|
15
|
+
}
|
16
|
+
return localConn;
|
17
|
+
}
|
18
|
+
|
19
|
+
public function TestRunner() {
|
20
|
+
tests = new Array();
|
21
|
+
}
|
22
|
+
|
23
|
+
public function push(item:Object):Number {
|
24
|
+
var num:Number = tests.push(item);
|
25
|
+
clearInterval(intervalId);
|
26
|
+
|
27
|
+
if(num > 100) {
|
28
|
+
renderTests();
|
29
|
+
} else {
|
30
|
+
intervalId = setInterval(this, "renderTests", interval);
|
31
|
+
}
|
32
|
+
return num;
|
33
|
+
}
|
34
|
+
|
35
|
+
public function renderTests():Void {
|
36
|
+
clearInterval(intervalId);
|
37
|
+
var lc:LocalConnClient = getLocalConn();
|
38
|
+
lc["addTests"](tests);
|
39
|
+
tests = new Array();
|
40
|
+
}
|
41
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
import com.asunit.framework.*;
|
3
|
+
|
4
|
+
class com.asunit.framework.TestSetup extends TestCase {
|
5
|
+
|
6
|
+
private function runMethod(method:String):Void {
|
7
|
+
setCurrentMethod(method);
|
8
|
+
this[method]();
|
9
|
+
}
|
10
|
+
|
11
|
+
private function run():Void {
|
12
|
+
var mList:Array = getMethods();
|
13
|
+
setUp();
|
14
|
+
for(var i:Number=0; i<mList.length; i++) {
|
15
|
+
runMethod(mList[i]);
|
16
|
+
}
|
17
|
+
tearDown();
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
import com.asunit.framework.*;
|
3
|
+
|
4
|
+
class com.asunit.framework.TestSuite extends TestCase {
|
5
|
+
|
6
|
+
public function TestSuite()
|
7
|
+
{
|
8
|
+
super();
|
9
|
+
}
|
10
|
+
|
11
|
+
public function addTest(test:Test):Void
|
12
|
+
{
|
13
|
+
}
|
14
|
+
|
15
|
+
public function addTestSuite(test:TestSuite):Void
|
16
|
+
{
|
17
|
+
}
|
18
|
+
|
19
|
+
public function run(result:TestResult):Void
|
20
|
+
{
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,325 @@
|
|
1
|
+
|
2
|
+
import com.asunit.ui.*;
|
3
|
+
import com.asunit.framework.*;
|
4
|
+
import com.asunit.util.*;
|
5
|
+
import mx.controls.*;
|
6
|
+
|
7
|
+
class Main extends MovieClip {
|
8
|
+
public static var linkageId:String = "com.asunit.ui.Main";
|
9
|
+
|
10
|
+
var version:String = "2.8.0";
|
11
|
+
var flashIsTextEditorResult:Boolean;
|
12
|
+
var remoteVersionObj:RemoteVersion;
|
13
|
+
var localConn:LocalConnServer;
|
14
|
+
var outputLine:LocalConnServer;
|
15
|
+
var tResult:TestResult;
|
16
|
+
var tFailure:TestFailure;
|
17
|
+
var test:Test;
|
18
|
+
var intervalId:Number;
|
19
|
+
|
20
|
+
var items:Array;
|
21
|
+
var gutter:Number = 10;
|
22
|
+
var successes:Number = 0;
|
23
|
+
var failures:Number = 0;
|
24
|
+
var totalTests:Number = 0;
|
25
|
+
|
26
|
+
var output_txt:TextArea;
|
27
|
+
var clearAll:Button;
|
28
|
+
var reload:Button;
|
29
|
+
var outputPanel:TextArea;
|
30
|
+
var showSys:CheckBox;
|
31
|
+
var showSysSo:SharedObject;
|
32
|
+
|
33
|
+
var bar_mc:SuccessMeter;
|
34
|
+
|
35
|
+
public function Main() {
|
36
|
+
configureAssets();
|
37
|
+
items = new Array();
|
38
|
+
showSysSo = SharedObject.getLocal("showSysSoId");
|
39
|
+
_visible = false;
|
40
|
+
onEnterFrame = function() {
|
41
|
+
_visible = true;
|
42
|
+
remoteVersionObj = new RemoteVersion(this);
|
43
|
+
showSys.clickHandler = onShowClicked;
|
44
|
+
showSys.setSelected(showSysSo.data.isSelected);
|
45
|
+
onResize();
|
46
|
+
Stage.addListener(this);
|
47
|
+
|
48
|
+
delete onEnterFrame;
|
49
|
+
}
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
public function checkRemoteVersion(remoteVersion:String):Void {
|
54
|
+
var remNumber:Number = Number(remoteVersion.split(".").join(""));
|
55
|
+
var vers:Number = Number(getVersionNumber().split(".").join("").split(" [Release Candidate]").join(""));
|
56
|
+
if(remNumber > vers) {
|
57
|
+
var obj:Object = new Object();
|
58
|
+
obj.success = false;
|
59
|
+
obj.message = ">> There is a newer version of AsUnit (" + remoteVersion + ") available for download at: <a href='http://www.asunit.com'><u>http://www.asunit.com</u></a>";
|
60
|
+
addTests([obj]);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
// Attached as clickHandler to the CheckBox
|
65
|
+
public function onShowClicked():Void {
|
66
|
+
_parent.onResize();
|
67
|
+
}
|
68
|
+
|
69
|
+
public function getVersionNumber():String {
|
70
|
+
return version;
|
71
|
+
}
|
72
|
+
|
73
|
+
public function onUnload():Void {
|
74
|
+
localConn.close();
|
75
|
+
outputLine.close();
|
76
|
+
saveTraceChoice();
|
77
|
+
}
|
78
|
+
|
79
|
+
public function saveTraceChoice():Void {
|
80
|
+
var success:Object = showSysSo.flush();
|
81
|
+
}
|
82
|
+
|
83
|
+
public function configureAssets() {
|
84
|
+
output_txt.vScrollPolicy = "auto";
|
85
|
+
|
86
|
+
reload.onRelease = function() {
|
87
|
+
_parent.onReload();
|
88
|
+
}
|
89
|
+
|
90
|
+
clearAll.onRelease = function() {
|
91
|
+
_parent.onClear();
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
public function clearTestDisplay():Void {
|
96
|
+
items = new Array();
|
97
|
+
refreshOutput();
|
98
|
+
}
|
99
|
+
|
100
|
+
public function onClear() {
|
101
|
+
MMExecute("fl.outputPanel.clear();");
|
102
|
+
clearTestDisplay();
|
103
|
+
}
|
104
|
+
|
105
|
+
public function onReload():Void {
|
106
|
+
_root.loadUi();
|
107
|
+
}
|
108
|
+
|
109
|
+
public function onLoad():Void {
|
110
|
+
init();
|
111
|
+
}
|
112
|
+
|
113
|
+
public function onResizeNoTrace():Void {
|
114
|
+
var w:Number = Stage.width-gutter*2;
|
115
|
+
var h:Number = Stage.height-(bar_mc._height + gutter*3);
|
116
|
+
outputPanel._visible = false;
|
117
|
+
|
118
|
+
output_txt.setSize(w, h);
|
119
|
+
output_txt._x = gutter;
|
120
|
+
showSys._x = gutter;
|
121
|
+
reload._x = showSys._x + showSys._width + gutter;
|
122
|
+
bar_mc._x = reload._x + reload._width + gutter;
|
123
|
+
output_txt._y = gutter;
|
124
|
+
bar_mc.setSize(w - (reload._x + reload._width), bar_mc._height);
|
125
|
+
reload._y = clearAll._y = bar_mc._y = output_txt._y + output_txt.height + gutter;
|
126
|
+
showSys._y = reload._y;
|
127
|
+
}
|
128
|
+
|
129
|
+
public function onResizeWithTrace():Void {
|
130
|
+
var w:Number = Stage.width-gutter*2;
|
131
|
+
var h:Number = Stage.height-(bar_mc._height + gutter*4);
|
132
|
+
outputPanel._visible = true;
|
133
|
+
|
134
|
+
outputPanel._x = gutter;
|
135
|
+
outputPanel._y = gutter;
|
136
|
+
outputPanel.setSize(w, h/2);
|
137
|
+
output_txt.setSize(w, h/2);
|
138
|
+
output_txt._y = outputPanel._y + outputPanel._height + gutter;
|
139
|
+
output_txt._x = gutter;
|
140
|
+
clearAll._x = output_txt._x;
|
141
|
+
showSys._x = gutter;
|
142
|
+
reload._x = showSys._x + showSys._width + gutter;
|
143
|
+
bar_mc._x = reload._x + reload._width + gutter;
|
144
|
+
bar_mc.setSize(w - (reload._x + reload._width), bar_mc._height);
|
145
|
+
reload._y = clearAll._y = bar_mc._y = output_txt._y + output_txt.height + gutter;
|
146
|
+
showSys._y = reload._y;
|
147
|
+
}
|
148
|
+
|
149
|
+
public function onResize():Void {
|
150
|
+
showSysSo.data.isSelected = showSys.selected;
|
151
|
+
showSysSo.flush();
|
152
|
+
|
153
|
+
if(showSys.selected) {
|
154
|
+
onResizeWithTrace();
|
155
|
+
} else {
|
156
|
+
onResizeNoTrace();
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
public function init():Void {
|
161
|
+
localConn = LocalConnGateway.createServer(this, "_AsUnitTestRunner");
|
162
|
+
outputLine = LocalConnGateway.createServer(this, "_outputLineLc");
|
163
|
+
output_txt.wordWrap = true;
|
164
|
+
refreshOutput();
|
165
|
+
}
|
166
|
+
|
167
|
+
public function onShowEcho(msg, category) {
|
168
|
+
msg = unescape(msg);
|
169
|
+
if(showSys.selected) {
|
170
|
+
outputPanel.text += msg;
|
171
|
+
} else {
|
172
|
+
MMExecute("fl.trace('" + msg + "');");
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
public function getFirstLine():String {
|
177
|
+
var str:String = "Version : " + getVersionNumber() + "\n";
|
178
|
+
if(localConn.status) {
|
179
|
+
str += "Unit Test UI Loaded at LocalConnection ID: '" + localConn.getId() + "'\n";
|
180
|
+
} else {
|
181
|
+
str += "ALERT : Unit Test UI LocalConnection <b>Failed</b> at ID : '<b>" + localConn.getId() + "</b>'\n";
|
182
|
+
}
|
183
|
+
if(outputLine.status) {
|
184
|
+
str += "Echo Output Loaded at LocalConnection ID: '" + outputLine.getId() + "'\n";
|
185
|
+
} else {
|
186
|
+
str += "ALERT : Echo Output LocalConnection <b>Failed</b> at ID : '<b>" + outputLine.getId() + "</b>'\n";
|
187
|
+
}
|
188
|
+
return str;
|
189
|
+
}
|
190
|
+
|
191
|
+
public function getTestResultString():String {
|
192
|
+
successes = 0;
|
193
|
+
failures = 0;
|
194
|
+
var str = "";
|
195
|
+
var fStr = "";
|
196
|
+
for(var i=0; i<items.length; i++) {
|
197
|
+
str += items[i].output;
|
198
|
+
if(items[i].success) {
|
199
|
+
successes++;
|
200
|
+
} else {
|
201
|
+
failures++;
|
202
|
+
fStr += renderItemFailure(items[i]);
|
203
|
+
}
|
204
|
+
}
|
205
|
+
return str + "\n" + getTestNumberOutput() + "\n" + fStr;
|
206
|
+
}
|
207
|
+
|
208
|
+
public function osIsWin():Boolean {
|
209
|
+
var vs = $version;
|
210
|
+
vs = vs.split(" ");
|
211
|
+
vs = vs[0];
|
212
|
+
if(vs != "WIN") {
|
213
|
+
return false;
|
214
|
+
}
|
215
|
+
return true;
|
216
|
+
}
|
217
|
+
|
218
|
+
public function flashIsTextEditor():Boolean {
|
219
|
+
if(flashIsTextEditorResult == undefined) {
|
220
|
+
var doc = MMExecute("fl.getDocumentDOM().getDataFromDocument('lastFlashEditor');");
|
221
|
+
if(doc == "true" || doc == null) {
|
222
|
+
flashIsTextEditorResult = true;
|
223
|
+
} else {
|
224
|
+
flashIsTextEditorResult = false;
|
225
|
+
}
|
226
|
+
}
|
227
|
+
return flashIsTextEditorResult;
|
228
|
+
}
|
229
|
+
|
230
|
+
public function renderItemFailure(item:Object):String {
|
231
|
+
var str = "-----------------\nItem Failed at :\n";
|
232
|
+
var isWin:Boolean = osIsWin();
|
233
|
+
|
234
|
+
str += "assertion : " + item.assertion + "\n";
|
235
|
+
str += "message : " + item.message + "\n";
|
236
|
+
str += "methodName : " + item.methodName + "\n";
|
237
|
+
if(isWin) {
|
238
|
+
str += "className : " + "<a href=\"asfunction:_parent.classNameClicked," + item.className + "\"><u>" + item.className + "</u></a>\n";
|
239
|
+
} else {
|
240
|
+
str += "className : " + item.className + "\n";
|
241
|
+
}
|
242
|
+
|
243
|
+
// for(var i in item) {
|
244
|
+
// if(i == "className" && isWin) {
|
245
|
+
// str += i + " : " + "<a href=\"asfunction:_parent.classNameClicked," + item[i] + "\"><u>" + item[i] + "</u></a>\n";
|
246
|
+
// } else {
|
247
|
+
// str += i + " : " + item[i] + "\n";
|
248
|
+
// }
|
249
|
+
// }
|
250
|
+
return str;
|
251
|
+
}
|
252
|
+
|
253
|
+
public function classNameClicked(name:String):Void {
|
254
|
+
name = name.split(".").join("/") + ".as";
|
255
|
+
var uri:String = "";
|
256
|
+
if(MMExecute('fl.version.indexOf("MAC");') == -1) {
|
257
|
+
if(flashIsTextEditor()) {
|
258
|
+
uri = getMacPath(name);
|
259
|
+
MMExecute('fl.openScript("' + uri + '");');;
|
260
|
+
} else {
|
261
|
+
uri = getWinPath(name);
|
262
|
+
MMExecute("FileIo.open('" + uri + "');");
|
263
|
+
}
|
264
|
+
}
|
265
|
+
else {
|
266
|
+
uri = getMacPath(name);
|
267
|
+
MMExecute('fl.openScript("' + uri + '");');;
|
268
|
+
}
|
269
|
+
}
|
270
|
+
|
271
|
+
public function getWinPath(suffix:String):String {
|
272
|
+
var flaUri:String = MMExecute("fl.getDocumentDOM().path");
|
273
|
+
var dPath = flaUri.split(Sys.getFileSeparator());
|
274
|
+
var sPath = suffix.split("/");
|
275
|
+
dPath.pop();
|
276
|
+
dPath = dPath.join("\\\\") + "\\\\" + sPath.join("\\\\");
|
277
|
+
dPath = dPath.split(" ").join("\\ ");
|
278
|
+
return dPath;
|
279
|
+
}
|
280
|
+
|
281
|
+
public function getMacPath(suffix:String):String {
|
282
|
+
return getCurrentUri(suffix);
|
283
|
+
}
|
284
|
+
|
285
|
+
public function getCurrentUri(suffix:String):String {
|
286
|
+
var flaUri:String = MMExecute("fl.getDocumentDOM().path");
|
287
|
+
var dPath = flaUri.split(Sys.getFileSeparator());
|
288
|
+
dPath.pop();
|
289
|
+
dPath = dPath.join("/")
|
290
|
+
// Perform Windows Colonoscopy
|
291
|
+
if(dPath.charAt(1) == ":") {
|
292
|
+
dPath = dPath.substring(0,1) + "|" + dPath.substring(2);
|
293
|
+
}
|
294
|
+
return "file:///" + dPath + "/" + suffix;
|
295
|
+
}
|
296
|
+
|
297
|
+
public function getTestNumberOutput():String {
|
298
|
+
return successes + " out of " + items.length + " Asserts passed.\n";
|
299
|
+
}
|
300
|
+
|
301
|
+
public function refreshOutput() {
|
302
|
+
output_txt.text = getFirstLine();
|
303
|
+
output_txt.text += "\n" + getTestResultString();
|
304
|
+
bar_mc.setSuccess((failures == 0));
|
305
|
+
if(intervalId == undefined) {
|
306
|
+
intervalId = setInterval(this, "scrollDown", 100);
|
307
|
+
}
|
308
|
+
}
|
309
|
+
|
310
|
+
public function scrollDown():Void {
|
311
|
+
output_txt.vPosition = output_txt.maxVPosition;
|
312
|
+
clearInterval(intervalId);
|
313
|
+
delete intervalId;
|
314
|
+
}
|
315
|
+
|
316
|
+
public function addTests(arr:Array) {
|
317
|
+
if(items == undefined) {
|
318
|
+
items = new Array();
|
319
|
+
}
|
320
|
+
for(var i = 0; i < arr.length; i++) {
|
321
|
+
items.push(arr[i]);
|
322
|
+
}
|
323
|
+
refreshOutput();
|
324
|
+
}
|
325
|
+
}
|