asproject 0.1.92 → 0.1.118

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/lib/asclass_arguments.rb +1 -1
  2. data/lib/asproject.rb +3 -1
  3. data/lib/asproject/version.rb +1 -1
  4. data/lib/asproject_arguments.rb +5 -5
  5. data/lib/path_finder.rb +17 -7
  6. data/lib/tasks/asunit.rb +8 -0
  7. data/lib/tasks/flash_log.rb +2 -1
  8. data/lib/tasks/flash_player.rb +10 -6
  9. data/lib/tasks/mxmlc.rb +13 -2
  10. data/lib/tasks/remote_file_loader.rb +144 -0
  11. data/lib/tasks/remote_file_task.rb +2 -128
  12. data/lib/tasks/remote_library_task.rb +75 -0
  13. data/templates/asclass/as2/Class.as +1 -1
  14. data/templates/asproject/as2/{art → assets}/.crap_file +0 -0
  15. data/templates/asproject/as2/project/rakefile.rb +3 -2
  16. data/templates/asproject/as3/{art → assets}/.crap_file +0 -0
  17. data/templates/asproject/as3/project/rakefile.rb +3 -3
  18. data/templates/asproject/fdt/project/.as2_classpath +1 -1
  19. metadata +9 -129
  20. data/templates/asproject/asunit2/project/lib/asunit/AsUnitUi.swf +0 -0
  21. data/templates/asproject/asunit2/project/lib/asunit/Sys.as +0 -70
  22. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanel.as +0 -182
  23. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTest.as +0 -84
  24. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextArea.as +0 -111
  25. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextAreaTest.as +0 -26
  26. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTitleBar.as +0 -81
  27. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ResizeHandle.as +0 -35
  28. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollArrow.as +0 -34
  29. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollHandle.as +0 -43
  30. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollListener.as +0 -10
  31. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/TextScroller.as +0 -169
  32. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Rectangle.as +0 -29
  33. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Triangle.as +0 -27
  34. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/AsUnit.as +0 -19
  35. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assert.as +0 -408
  36. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assertion.as +0 -27
  37. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as +0 -68
  38. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Test.as +0 -3
  39. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCase.as +0 -191
  40. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCaseXml.as +0 -31
  41. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestFailure.as +0 -15
  42. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestResult.as +0 -15
  43. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestRunner.as +0 -41
  44. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSetup.as +0 -19
  45. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSuite.as +0 -22
  46. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/Main.as +0 -325
  47. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/RemoteVersion.as +0 -24
  48. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/SuccessMeter.as +0 -32
  49. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Comparable.as +0 -7
  50. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventListener.as +0 -29
  51. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventSource.as +0 -89
  52. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnClient.as +0 -42
  53. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnGateway.as +0 -47
  54. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnServer.as +0 -61
  55. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalMessageBroker.as +0 -58
  56. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Observable.as +0 -11
  57. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/TextFile.as +0 -30
  58. data/templates/asproject/asunit25/project/lib/asunit/AsUnitTestRunner.as +0 -13
  59. data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionFailedError.as +0 -7
  60. data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionPassedError.as +0 -7
  61. data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/ClassNotFoundError.as +0 -7
  62. data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/IllegalOperationError.as +0 -7
  63. data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +0 -7
  64. data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InvocationTargetError.as +0 -7
  65. data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +0 -7
  66. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Assert.as +0 -376
  67. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertMock.as +0 -15
  68. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertTest.as +0 -59
  69. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/ITestListener.as +0 -13
  70. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Test.as +0 -11
  71. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCase.as +0 -278
  72. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseMock.as +0 -23
  73. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseTest.as +0 -29
  74. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseXml.as +0 -38
  75. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestFailure.as +0 -47
  76. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestResult.as +0 -168
  77. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestSuite.as +0 -102
  78. data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/BaseTestRunner.as +0 -101
  79. data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/IResultPrinter.as +0 -8
  80. data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/ResultPrinter.as +0 -254
  81. data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/SuccessBar.as +0 -41
  82. data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/TestRunner.as +0 -17
  83. data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIterator.as +0 -24
  84. data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIteratorTest.as +0 -52
  85. data/templates/asproject/asunit25/project/lib/asunit/asunit/util/Iterator.as +0 -5
  86. data/templates/asproject/asunit3/project/lib/asunit/AsUnitTestRunner.as +0 -10
  87. data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AbstractMemberCalledError.as +0 -10
  88. data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AssertionFailedError.as +0 -10
  89. data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/ClassNotFoundError.as +0 -10
  90. data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +0 -10
  91. data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +0 -10
  92. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Assert.as +0 -271
  93. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCase.as +0 -52
  94. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCaseExample.as +0 -71
  95. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Test.as +0 -15
  96. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCase.as +0 -354
  97. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCaseExample.as +0 -73
  98. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestFailure.as +0 -47
  99. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestListener.as +0 -22
  100. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestResult.as +0 -158
  101. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestSuite.as +0 -115
  102. data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/BaseTestRunner.as +0 -15
  103. data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/TestSuiteLoader.as +0 -9
  104. data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/Version.as +0 -11
  105. data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexRunner.as +0 -19
  106. data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexTestRunner.as +0 -55
  107. data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/ResultPrinter.as +0 -245
  108. data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/TestRunner.as +0 -121
  109. data/templates/asproject/asunit3/project/lib/asunit/asunit/util/ArrayIterator.as +0 -26
  110. data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Iterator.as +0 -9
  111. data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Properties.as +0 -30
@@ -1,27 +0,0 @@
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
- }
@@ -1,68 +0,0 @@
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
- }
@@ -1,3 +0,0 @@
1
-
2
- interface com.asunit.framework.Test {
3
- }
@@ -1,191 +0,0 @@
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
- }
@@ -1,31 +0,0 @@
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
- }
@@ -1,15 +0,0 @@
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
- }
@@ -1,15 +0,0 @@
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
- }
@@ -1,41 +0,0 @@
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
- }
@@ -1,19 +0,0 @@
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
- }
@@ -1,22 +0,0 @@
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
- }
@@ -1,325 +0,0 @@
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
- }