flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gregd...@apache.org
Subject [2/4] git commit: [flex-asjs] [refs/heads/develop] - Setup for side-by-side Unit test view of swf and js, with flexuint shim, added Reflection tests
Date Tue, 27 Sep 2016 08:14:45 GMT
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/438cb014/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass2.as
----------------------------------------------------------------------
diff --git a/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass2.as b/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass2.as
new file mode 100644
index 0000000..bcc7988
--- /dev/null
+++ b/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass2.as
@@ -0,0 +1,103 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package flexUnitTests.reflection.support
+{
+
+
+	[TestMeta(foo="class")]
+	public class TestClass2 
+	{
+		//Note: do not change this test class unless you change the related tests to 
+		//support any changes that might appear when testing reflection into it
+		
+		public function TestClass2(blah:String){
+
+		}
+		
+		
+		[TestMeta(foo="instanceMethod")]
+		public function testMethod():void{
+			_testReadWrite = "testMethod was called";
+		}
+		
+		[TestMeta(foo="instanceMethod")]
+		public function testMethodWithArgs(mandatory:String,optional:Boolean=true):Boolean{
+			_testReadWrite = "testMethodWithArgs was called";
+			return optional;
+		}
+		
+		[TestMeta(foo="instanceVariable")]
+		public var testVar:String = "testVar_val";
+		
+		[TestMeta(foo="instanceAccessor")]
+		public function get testReadOnly():String{
+			return _testReadWrite
+		}
+		
+		[TestMeta(foo="instanceAccessor")]
+		public function set testWriteOnly(value:String):void{
+			_testReadWrite=value;
+		}
+		
+		[TestMeta(foo="instanceAccessor")]
+		public function get testReadWrite():String{
+			return _testReadWrite
+		}
+		public function set testReadWrite(value:String):void{
+			_testReadWrite=value;
+		}
+		
+		[TestMeta(foo="staticMethod")]
+		public static function testStaticMethod():void{
+			_testStaticReadWrite = "testStaticMethod was called";
+		}
+		
+		[TestMeta(foo="staticMethod")]
+		public static function testStaticMethodWithArgs(mandatory:String,optional:Boolean=true):Boolean{
+			_testStaticReadWrite = "testStaticMethodWithArgs was called";
+			return optional;
+		}
+		
+		[TestMeta(foo="staticVariable")]
+		public static var testStaticVar:String = "testStaticVar_val";
+		
+		[TestMeta(foo="staticAccessor")]
+		public static function get testStaticReadOnly():String{
+			return _testStaticReadWrite
+		}
+		
+		[TestMeta(foo="staticAccessor")]
+		public static function set testStaticWriteOnly(value:String):void{
+			_testStaticReadWrite = value;
+		}
+		
+		[TestMeta(foo="staticAccessor")]
+		public static function get testStaticReadWrite():String{
+			return _testStaticReadWrite;
+		}
+		public static function set testStaticReadWrite(value:String):void{
+			_testStaticReadWrite = value;
+		}
+		
+		
+		
+		private static var _testStaticReadWrite:String = "staticAccessor_initial_value";
+		private var _testReadWrite:String = "instanceAccessor_initial_value";
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/438cb014/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass3.as
----------------------------------------------------------------------
diff --git a/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass3.as b/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass3.as
new file mode 100644
index 0000000..0b4c59b
--- /dev/null
+++ b/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass3.as
@@ -0,0 +1,39 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package flexUnitTests.reflection.support
+{
+
+
+
+	public class TestClass3 extends TestClass1 implements ITestInterface2, ITestInterface3
+	{
+		
+		public var something:String;
+		
+		
+		public function someMethod2(compulsoryArg:int, optArg:String=null):TestClass1
+		{
+			return null;
+		}
+		
+		public function get someValue2():Boolean {
+			return false;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/438cb014/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass4.as
----------------------------------------------------------------------
diff --git a/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass4.as b/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass4.as
new file mode 100644
index 0000000..5d0a28f
--- /dev/null
+++ b/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass4.as
@@ -0,0 +1,95 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package flexUnitTests.reflection.support
+{
+
+
+
+	public class TestClass4 extends TestClass2
+	{
+		//Note: do not change this test class unless you change the related tests to 
+		//support any changes that might appear when testing reflection into it
+		
+		public function TestClass4(){
+			super("");
+		}
+		
+		
+		[TestMeta(foo="instanceMethod")]
+		public function testMethod2():void{
+		
+		}
+		
+		[TestMeta(foo="instanceMethod")]
+		public function testMethodWithArgs2(mandatory:String,optional:Boolean=true):void{
+		
+		}
+		
+		[TestMeta(foo="instanceVariable")]
+		public var testVar2:String;
+		
+		[TestMeta(foo="instanceAccessor")]
+		public function get testReadonly2():String{
+			return null
+		}
+		
+		[TestMeta(foo="instanceAccessor")]
+		public function set testWriteonly2(value:String):void{
+			
+		}
+		
+		[TestMeta(foo="instanceAccessor")]
+		public function get testReadeWrite2():String{
+			return null
+		}
+		public function set testReadeWrite2(value:String):void{
+			
+		}
+		
+		[TestMeta(foo="staticMethod")]
+		public static function testStaticMethod():void{
+		}
+		
+		[TestMeta(foo="staticMethod")]
+		public static function testStaticMethodWithArgs(mandatory:String,optional:Boolean=true):void{
+		}
+		
+		[TestMeta(foo="staticVariable")]
+		public static var testStaticVar:String;
+		
+		[TestMeta(foo="staticAccessor")]
+		public static function get testStaticReadonly():String{
+			return null
+		}
+		
+		[TestMeta(foo="staticAccessor")]
+		public static function set testStaticWriteonly(value:String):void{
+			
+		}
+		
+		[TestMeta(foo="staticAccessor")]
+		public static function get testStaticReadeWrite():String{
+			return null
+		}
+		public static function set testStaticReadeWrite(value:String):void{
+			
+		}
+
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/438cb014/manualtests/GenericTests/src/flexunit/framework/Assert.as
----------------------------------------------------------------------
diff --git a/manualtests/GenericTests/src/flexunit/framework/Assert.as b/manualtests/GenericTests/src/flexunit/framework/Assert.as
new file mode 100644
index 0000000..171f695
--- /dev/null
+++ b/manualtests/GenericTests/src/flexunit/framework/Assert.as
@@ -0,0 +1,305 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package flexunit.framework
+{
+	//import flexunit.framework.AssertionFailedError;
+ 	
+	/**
+	 * A set of assert methods.  Messages are only displayed when an assert fails.
+	 */
+	public class Assert
+	{
+		/**
+		 * @private
+		 */
+		public static var _assertCount:uint = 0;
+		
+		/**
+		 * Returns the number of assertions that have been made
+		 */
+		public static function get assertionsMade() : uint {
+			return _assertCount;
+		}
+		
+		
+		/**
+		 * Resets the count for the number of assertions that have been made back to zero
+		 */
+		public static function resetAssertionsFields() : void {
+			_assertCount = 0;
+		}
+		
+		/**
+		 * @private
+		 */
+		public static function assertWithApply( asserter:Function, args:Array ):void {
+			_assertCount++;
+			asserter.apply( null, args );
+		}
+
+		/**
+		 * @private
+		 */
+		public static function assertWith( asserter:Function, ...rest ):void {
+			_assertCount++;
+			asserter.apply( null, rest );
+		}
+
+		/**
+		 * Asserts that two provided values are equal.
+		 * 
+		 * @param asserter The function to use for assertion. 
+		 * @param rest
+		 * 			Must be passed at least 2 arguments of type Object to compare for equality.
+		 * 			If three arguments are passed, the first argument must be a String
+		 * 			and will be used as the error message.
+		 *          The first of the comparison arguments represents the expected result
+		 *          The second is the actual result to compare with the expected result.
+		 * 
+		 * 			<code>assertEquals( String, Object, Object );</code>
+		 * 			<code>assertEquals( Object, Object );</code>
+		 */
+		public static function assertEquals(... rest):void
+		{
+			_assertCount++;
+			if ( rest.length == 3 )
+				failNotEquals( rest[0], rest[1], rest[2] );
+			else
+				failNotEquals( "", rest[0], rest[1] );
+		}
+	
+        /**
+         * @private
+         */
+		public static function failNotEquals( message:String, expected:Object, actual:Object ):void
+		{
+			if ( expected != actual )
+			   failWithUserMessage( message, "expected:<" + expected + "> but was:<" + actual
+ ">" );
+		}
+	
+		/**
+		 * /**
+		 * Asserts that the provided values are strictly equal.
+		 * 
+		 * @param rest
+		 * 			Must be passed at least 2 arguments of type Object to compare for strict equality.
+		 * 			If three arguments are passed, the first argument must be a String
+		 * 			and will be used as the error message.
+		 *          The first of the comparison arguments represents the expected result
+		 *          The second is the actual result to compare with the expected result.
+		 * 
+		 * 			<code>assertStrictlyEquals( String, Object, Object );</code>
+		 * 			<code>assertStrictlyEquals( Object, Object );</code>
+		 */
+		public static function assertStrictlyEquals(... rest):void
+		{
+			_assertCount++;
+			if ( rest.length == 3 )
+				failNotStrictlyEquals( rest[0], rest[1], rest[2] );
+			else
+				failNotStrictlyEquals( "", rest[0], rest[1] );
+		}
+	
+        /**
+         * @private
+         */
+		public static function failNotStrictlyEquals( message:String, expected:Object, actual:Object
):void
+		{
+			if ( expected !== actual )
+			   failWithUserMessage( message, "expected:<" + expected + "> but was:<" + actual
+ ">" );
+		}
+	
+		/**
+		 * Asserts that a condition is true.
+		 * 
+		 * @param rest
+		 * 			Accepts an argument of type Boolean.
+		 * 			If two arguments are passed the first argument must be a String 
+		 * 			and will be used as the error message.
+		 * 			
+		 * 			<code>assertTrue( String, Boolean );</code>
+		 * 			<code>assertTrue( Boolean );</code>
+		 */
+		public static function assertTrue(... rest):void
+		{
+			_assertCount++;
+			if ( rest.length == 2 )
+				failNotTrue( rest[0], rest[1] );
+			else
+				failNotTrue( "", rest[0] );
+		}
+	
+        /**
+         * Asserts that a condition is not true.
+		 * 
+		 * @param rest
+		 * 			Accepts an argument of type Boolean.
+		 * 			If two arguments are passed the first argument must be a String 
+		 * 			and will be used as the error message.
+		 * 			
+		 * 			<code>assertTrue( String, Boolean );</code>
+		 * 			<code>assertTrue( Boolean );</code>
+         */
+		public static function failNotTrue( message:String, condition:Boolean ):void
+		{
+			if ( !condition )
+			   failWithUserMessage( message, "expected true but was false" );
+		}
+	
+		/**
+         * Asserts that a condition is false.
+		 * 
+		 * @param rest
+		 * 			Accepts an argument of type Boolean.
+		 * 			If two arguments are passed the first argument must be a String
+		 * 			and will be used as the error message.
+		 * 			
+		 * 			<code>assertFalse( String, Boolean );</code>
+		 * 			<code>assertFalse( Boolean );</code>
+		 */
+		public static function assertFalse(... rest):void
+		{
+			_assertCount++;
+			if ( rest.length == 2 )
+				failTrue( rest[0], rest[1] );
+			else
+				failTrue( "", rest[0] );
+		}
+	
+        /**
+         * Asserts that a condition is false. 
+		 * 
+		 * @param rest
+		 * 			Accepts an argument of type Boolean.
+		 * 			If two arguments are passed the first argument must be a String 
+		 * 			and will be used as the error message.
+		 * 			
+		 * 			<code>assertTrue( String, Boolean );</code>
+		 * 			<code>assertTrue( Boolean );</code>
+         */
+		public static function failTrue( message:String, condition:Boolean ):void
+		{
+			if ( condition )
+			   failWithUserMessage( message, "expected false but was true" );
+		}
+	
+		//TODO:  (<code>null</code> okay) needs removal?
+		/**
+		 * Asserts that an object is null.
+		 * 
+		 * @param rest
+		 * 			Accepts an argument of type Object.
+		 * 			If two arguments are passed the first argument must be a String
+		 * 			and will be used as the error message.
+		 * 			
+		 * 			<code>assertNull( String, Object );</code>
+		 * 			<code>assertNull( Object );</code>
+		 * 
+		 */
+		public static function assertNull(... rest):void
+		{
+			_assertCount++;
+			if ( rest.length == 2 )
+				failNotNull( rest[0], rest[1] );
+			else
+				failNotNull( "", rest[0] );
+		}
+	
+        /**
+         * Asserts that an object is not null. 
+		 * 
+		 * @param rest
+		 * 			Accepts an argument of type Boolean.
+		 * 			If two arguments are passed the first argument must be a String 
+		 * 			and will be used as the error message.
+		 * 			
+		 * 			<code>assertTrue( String, Boolean );</code>
+		 * 			<code>assertTrue( Boolean );</code>
+         */
+		public static function failNull( message:String, object:Object ):void
+		{
+			if ( object == null )
+			   failWithUserMessage( message, "object was null: " + object );
+		}
+	
+		//TODO:  (<code>null</code> okay) needs removal?
+		/**
+		 * Asserts that an object is not null.
+		 * 
+		 * @param rest
+		 * 			Accepts an argument of type Object.
+		 * 			If two arguments are passed the first argument must be a String
+		 * 			and will be used as the error message.
+		 * 			
+		 * 			<code>assertNotNull( String, Object );</code>
+		 * 			<code>assertNotNull( Object );</code>
+		 */
+		public static function assertNotNull(... rest):void
+		{
+			_assertCount++;
+			if ( rest.length == 2 )
+				failNull( rest[0], rest[1] );
+			else
+				failNull( "", rest[0] );
+		}
+	
+        /**
+         * Asserts that an object is not null.
+		 * 
+		 * @param rest
+		 * 			Accepts an argument of type Boolean.
+		 * 			If two arguments are passed the first argument must be a String 
+		 * 			and will be used as the error message.
+		 * 			
+		 * 			<code>assertTrue( String, Boolean );</code>
+		 * 			<code>assertTrue( Boolean );</code>
+         */
+		public static function failNotNull( message:String, object:Object ):void
+		{
+			if ( object != null )
+			   failWithUserMessage( message, "object was not null: " + object );
+		}
+		//TODO:  (<code>null</code> okay) needs removal?
+		/**
+		 * Fails a test with the argument message.
+		 * 
+		 * @param failMessage
+		 *            the identifying message for the <code> AssertionFailedError</code>
(<code>null</code>
+		 *            okay)
+		 * @see AssertionFailedError
+		 */
+		public static function fail( failMessage:String = ""):void
+		{
+			var error:AssertionFailedError = new AssertionFailedError(failMessage);
+			//this seems necessary for js:
+			if (error.message!=failMessage) error.message = failMessage;
+			throw error;
+		}
+	
+
+        /**
+         * @private
+         */
+		private static function failWithUserMessage( userMessage:String, failMessage:String ):void
+		{
+			if ( userMessage.length > 0 )
+				userMessage = userMessage + " - ";
+			failMessage = userMessage + failMessage;
+			fail(failMessage);
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/438cb014/manualtests/GenericTests/src/flexunit/framework/AssertionFailedError.as
----------------------------------------------------------------------
diff --git a/manualtests/GenericTests/src/flexunit/framework/AssertionFailedError.as b/manualtests/GenericTests/src/flexunit/framework/AssertionFailedError.as
new file mode 100644
index 0000000..359361f
--- /dev/null
+++ b/manualtests/GenericTests/src/flexunit/framework/AssertionFailedError.as
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package flexunit.framework
+{
+	/**
+	 * <code>Error</code> class used for failures in assertions
+	 * 
+	 * @see Assert
+	 */
+	public class AssertionFailedError extends Error
+	{
+		/**
+		 * Throws a new <code>Error</code> of type <code>AssertionError</code>
+		 * with the passed in message
+		 * 
+		 * @param message The message associated with the error (<code>null</code>
okay)
+		 * @param id The id of the error if desired (<code>null</code> okay)
+		 */
+		public function AssertionFailedError(message:String="", id:int=0)
+		{
+			super(message, id);
+		}
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/438cb014/manualtests/GenericTests/src/testshim/FlexJSUnitTestRunner.as
----------------------------------------------------------------------
diff --git a/manualtests/GenericTests/src/testshim/FlexJSUnitTestRunner.as b/manualtests/GenericTests/src/testshim/FlexJSUnitTestRunner.as
new file mode 100644
index 0000000..7494963
--- /dev/null
+++ b/manualtests/GenericTests/src/testshim/FlexJSUnitTestRunner.as
@@ -0,0 +1,186 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package testshim {
+
+import org.apache.flex.reflection.MetaDataArgDefinition;
+import org.apache.flex.reflection.MetaDataDefinition;
+import org.apache.flex.reflection.MethodDefinition;
+import org.apache.flex.reflection.TypeDefinition;
+import org.apache.flex.reflection.describeType;
+
+import flexunit.framework.Assert;
+public class FlexJSUnitTestRunner {
+
+
+    public function FlexJSUnitTestRunner(testerClass:Class, notificationReceiver:Function)
{
+        this.testerClass = testerClass;
+        this.callback = notificationReceiver;
+        prepare();
+    }
+
+    private var testerClass:Class;
+    private var callback:Function;
+
+    private var _testingName:String;
+    public function get testingName():String{
+        return _testingName;
+    }
+    private var _successCount:uint=0;
+    public function get successCount():uint {
+        return _successCount;
+    }
+
+    private var _failCount:uint=0;
+    public function get failCount():uint {
+        return _failCount;
+    }
+
+    private var _successfulAssertions:uint=0;
+    public function get successfulAssertions():uint {
+        return _successfulAssertions;
+    }
+
+    private var beforeClassFunc:Function;
+    private var afterClassFunc:Function;
+    private var setupFunc:MethodDefinition;
+    private var tearDownFunc:MethodDefinition;
+
+    private var testMethods:Array=[];
+
+    private function prepare():void{
+        var typeDef:TypeDefinition = describeType(testerClass);
+        _testingName = typeDef.name;
+        var staticMethods:Array = typeDef.staticMethods;
+        for each (var methodDef:MethodDefinition in staticMethods) {
+            var beforeClass:Array = methodDef.retrieveMetaDataByName("BeforeClass");
+            var afterClass:Array = methodDef.retrieveMetaDataByName("AfterClass");
+            if ( beforeClass.length ) {
+                if (beforeClassFunc!=null) throw new Error("BeforeClass used more than once
in "+typeDef.qualifiedName);
+                beforeClassFunc = testerClass[methodDef.name];
+            }
+            if ( afterClass.length ) {
+                if (afterClassFunc!=null) throw new Error("AfterClass used more than once
in "+typeDef.qualifiedName);
+                afterClassFunc = testerClass[methodDef.name];
+            }
+        }
+        var methods:Array = typeDef.methods;
+        for each (methodDef in methods) {
+            var beforeTests:Array = methodDef.retrieveMetaDataByName("Before");
+            var afterTests:Array = methodDef.retrieveMetaDataByName("After");
+            if ( beforeTests.length ) {
+                if (setupFunc!=null) throw new Error("Before used more than once in "+typeDef.qualifiedName);
+                setupFunc = methodDef;
+            }
+            if ( afterTests.length ) {
+                if (tearDownFunc!=null) throw new Error("After used more than once in "+typeDef.qualifiedName);
+                tearDownFunc = methodDef;
+            }
+            var test:Array = methodDef.retrieveMetaDataByName("Test");
+            if (test.length) {
+                testMethods.push(methodDef);
+            }
+            testMethods.sortOn("name");
+        }
+
+        if (testMethods.length == 0) {
+            throw new Error("Zero test methods detected in "+typeDef.qualifiedName+", check
to make sure -keep-as3-metadata is configured");
+        }
+    }
+
+    private function begin():void {
+        if (beforeClassFunc!=null) beforeClassFunc();
+    }
+
+    public function runTests():void{
+        begin();
+        var testInstance:Object = new testerClass();
+        if (setupFunc!=null) {
+            testInstance[setupFunc.name]();
+        }
+        var i:uint=0, l:uint=testMethods.length;
+
+        for(;i<l;i++) {
+            runFlexJSTest(_testingName,testInstance,testMethods[i],callback);
+        }
+
+        if (tearDownFunc!=null) {
+            testInstance[tearDownFunc.name]();
+        }
+        end();
+    }
+
+    private function end():void{
+        if (afterClassFunc!=null) afterClassFunc();
+    }
+
+
+    private function runFlexJSTest(testClass:String,instance:Object,methodDef:MethodDefinition,callback:Function=null):void{
+        var methodName:String = methodDef.name;
+        trace('running test in '+testClass+":"+methodName);
+        var varianceMetas:Array = methodDef.retrieveMetaDataByName("TestVariance");
+        
+        var method:Function = instance[methodName];
+        var preAssertCount:uint = Assert.assertionsMade;
+        var result:TestResult = new TestResult();
+        result.assertions = 0;
+        result.pass = true;
+        result.error = null;
+        result.testClass = testClass;
+        result.testMethod = methodName;
+
+        while (varianceMetas.length) {
+            var varianceMeta:MetaDataDefinition = varianceMetas.shift();
+            var varianceArgs:Array = varianceMeta.getArgsByKey("variance");
+            var i:uint=0, l:uint= varianceArgs.length;
+            if (l) {
+                result.hasVariance=true;
+                for(;i<l;i++) varianceArgs[i] = varianceArgs[i].value;
+                result.varianceTarget = varianceArgs.join(",");
+            }
+            if (result.hasVariance) {
+                var descriptionArgs:Array= varianceMeta.getArgsByKey("description");
+                if (descriptionArgs.length) result.varianceDescription = "";
+                while(descriptionArgs.length) {
+                    var description:MetaDataArgDefinition = descriptionArgs.shift();
+                    result.varianceDescription +=description.value;
+                    if (descriptionArgs.length) result.varianceDescription += ", ";
+                }
+            }
+        }
+        //run the test method
+        try {
+            method();
+        } catch (e:Error) {
+            result.pass=false;
+            result.error = e.name+":" + e.message;
+        }
+        result.assertions = Assert.assertionsMade - preAssertCount;
+        if (preAssertCount == Assert.assertionsMade) {
+            result.warning = "WARNING: This test method appears to have zero Assertions";
+        }
+        if (result.pass) _successCount++;
+        else _failCount++;
+        _successfulAssertions += result.assertions;
+        if (callback!=null) {
+            callback(result);
+        }
+    }
+
+}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/438cb014/manualtests/GenericTests/src/testshim/TestResult.as
----------------------------------------------------------------------
diff --git a/manualtests/GenericTests/src/testshim/TestResult.as b/manualtests/GenericTests/src/testshim/TestResult.as
new file mode 100644
index 0000000..d9bc514
--- /dev/null
+++ b/manualtests/GenericTests/src/testshim/TestResult.as
@@ -0,0 +1,56 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package testshim {
+public class TestResult {
+    public function TestResult() {
+    }
+
+    public var testClass:String;
+
+    public var testMethod:String;
+
+    public var pass:Boolean;
+
+    public var assertions:uint;
+
+    public var error:String;
+
+    public var hasVariance:Boolean;
+
+    public var varianceTarget:String;
+
+    public var varianceDescription:String;
+    
+    public var warning:String;
+
+    public function toString(newline:String=null):String {
+        if (newline==null) newline="\n";
+        var s:String="";
+        var postFix:String = testMethod+" in "+testClass;
+        if (pass) {
+           s += "PASSED ("+assertions+" assertions made) ["+postFix+"]";
+        } else {
+            s += "FAILED ( at assertion "+assertions+" in test method) ["+postFix+"]"+newline;
+            s += "["+error+"]";
+        }
+        return s;
+    }
+
+}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/438cb014/manualtests/GenericTests/testsview/image/Flex.png
----------------------------------------------------------------------
diff --git a/manualtests/GenericTests/testsview/image/Flex.png b/manualtests/GenericTests/testsview/image/Flex.png
new file mode 100644
index 0000000..cb68fec
Binary files /dev/null and b/manualtests/GenericTests/testsview/image/Flex.png differ

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/438cb014/manualtests/GenericTests/testsview/index.html
----------------------------------------------------------------------
diff --git a/manualtests/GenericTests/testsview/index.html b/manualtests/GenericTests/testsview/index.html
new file mode 100644
index 0000000..f90813a
--- /dev/null
+++ b/manualtests/GenericTests/testsview/index.html
@@ -0,0 +1,112 @@
+<!DOCTYPE html>
+<html>
+<head>
+	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+	<style>
+		.boxLeft { 
+			display:inline-block; 
+			width:50% ;
+			position:absolute; 
+			top:100px; 
+			bottom:15px; 
+			left:0px
+		}
+		.boxRight { 
+			display:inline-block; 
+			width:50% ;
+			position:absolute; 
+			top:100px; 
+			bottom:15px; 
+			right:0px
+		}
+		.pageStyles {
+			font-family: Arial,sans-serif;
+			color: #333;
+			background: #f5f5f5;
+			font-size: 14px;
+			line-height: 1.5;
+		}
+		h1 {
+			font-size: 28px;
+			line-height: 1.25;
+			font-weight: normal;
+		}
+		em {
+		  font-weight: bold;
+		}
+		.logo {
+			margin-right: 10px;
+			float: left;
+			width: 48px;
+			height: 48px;
+			border-radius: 50%;
+			border: 0;
+			margin: 0;
+			padding: 0;
+		}
+		.titleContent {
+			white-space:nowrap;
+		}
+	</style>
+	<script type="text/javascript">
+	
+	console.API;
+
+	if (typeof console._commandLineAPI !== 'undefined') {
+		console.API = console._commandLineAPI; //chrome
+	} else if (typeof console._inspectorCommandLineAPI !== 'undefined') {
+		console.API = console._inspectorCommandLineAPI; //Safari
+	} else if (typeof console.clear !== 'undefined') {
+		console.API = console;
+	}
+
+	function swapJSBuild() {
+		var button = document.getElementById("swapJsButton");
+		var JS_RELEASE = "JS-Release";
+		var JS_DEBUG = "JS-Debug";
+		var SWAP_TO_RELEASE = "Swap To "+JS_RELEASE;
+		var SWAP_TO_DEBUG = "Swap To "+JS_DEBUG;
+		var debug = "../bin/js-debug/index.html";
+		var release = "../bin/js-release/index.html";
+		var jsIframe = document.getElementById("jsIframe");
+		var status = document.getElementById("jsStatus");
+		if (button && jsIframe) {
+			var current = button.innerHTML;
+			switch (current) {
+				case SWAP_TO_RELEASE:
+					console.API.clear();
+					button.innerHTML = SWAP_TO_DEBUG;
+					jsIframe.src = release;		
+					status.innerHTML = "Currently showing <em>"+JS_RELEASE+"</em>";;				
+				break;
+				case SWAP_TO_DEBUG:
+					console.API.clear();
+					button.innerHTML = SWAP_TO_RELEASE;
+					jsIframe.src = debug;	
+					status.innerHTML = "Currently showing <em>"+JS_DEBUG+"</em>";	
+				break;
+			}
+		}
+	}
+	</script>
+</head>
+<body class="pageStyles">
+	<div>
+		<div >
+			<img class="logo" src="image/Flex.png" alt="Apache Flex logo">
+			<div class="titleContent">
+				<h1>FlexJS Framework Development Unit Tests</h1>
+			</div>
+		<div id="jsStatus" style="position: relative; display: inline-block;">Currently showing
<em>JS-Debug</em></div>
+			<button id="swapJsButton" onclick="swapJSBuild()" type="button" class="quoteButton
TextButton" style="position: relative; display: inline-block;">Swap To JS-Release</button>
+		</div>
+		<div class="boxLeft">
+			<iframe id="jsIframe" src="../bin/js-debug/index.html" frameborder="1" scrolling="no"
height="100%" width="100%" align="left" ></iframe>
+		</div>
+		<div class="boxRight">
+			<iframe id="swfIframe"  src="../bin-debug/GenericTests.html" frameborder="1" scrolling="no"
height="100%" width="100%" align="left" ></iframe>
+		</div>
+	</div>
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/438cb014/manualtests/GenericTests/testsview/src/GenericTestsContainer.mxml
----------------------------------------------------------------------
diff --git a/manualtests/GenericTests/testsview/src/GenericTestsContainer.mxml b/manualtests/GenericTests/testsview/src/GenericTestsContainer.mxml
new file mode 100644
index 0000000..9f86bb6
--- /dev/null
+++ b/manualtests/GenericTests/testsview/src/GenericTestsContainer.mxml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!---
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+-->
+<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
+				   xmlns:local="*"
+				   xmlns:js="library://ns.apache.org/flexjs/basic" 
+				   >
+	
+	<js:valuesImpl>
+		<js:SimpleCSSValuesImpl />
+	</js:valuesImpl>
+	<js:initialView>
+		<local:MyInitialView />
+	</js:initialView>
+</js:Application>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/438cb014/manualtests/GenericTests/testsview/src/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/manualtests/GenericTests/testsview/src/MyInitialView.mxml b/manualtests/GenericTests/testsview/src/MyInitialView.mxml
new file mode 100644
index 0000000..bee6823
--- /dev/null
+++ b/manualtests/GenericTests/testsview/src/MyInitialView.mxml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<js:View xmlns:fx="http://ns.adobe.com/mxml/2009"
+				xmlns:js="library://ns.apache.org/flexjs/basic"
+				xmlns:local="*" 
+				xmlns:acc="org.apache.flex.html.accessories.*"
+				className="viewStyles">
+	
+	<fx:Style>
+		.title {
+			font-size: 14pt;
+			font-weight: bold;
+		}
+		
+		.viewStyles {
+			font-family: Arial,sans-serif;
+			color: #333;
+			background: #f5f5f5;
+			font-size: 14px;
+			line-height: 1.5;
+		}
+
+		.h1 {
+			font-size: 28px;
+			line-height: 1.25;
+			font-weight: normal;
+		}
+
+	</fx:Style>
+	
+	<fx:Script>
+		<![CDATA[			
+			import org.apache.flex.core.IPopUpHost;
+			import org.apache.flex.events.Event;
+			import org.apache.flex.utils.UIUtils;
+			import org.apache.flex.events.EventDispatcher;
+						
+            import org.apache.flex.reflection.describeType;
+			import org.apache.flex.reflection.getDefinitionByName;
+            import org.apache.flex.reflection.MetaDataArgDefinition;
+            import org.apache.flex.reflection.MetaDataDefinition;
+            import org.apache.flex.reflection.MethodDefinition;
+            import org.apache.flex.reflection.TypeDefinition;
+			import org.apache.flex.reflection.VariableDefinition;
+			
+			import testclasses.TestClass1;
+			import testclasses.TestClass2;
+			import testclasses.ITestInterface;
+			import testclasses.ITestInterface2;
+			import testclasses.ITestInterface3;
+		
+			
+			
+	
+		]]>
+	</fx:Script>
+	<js:beads>
+        <js:ViewDataBinding/>
+		<js:HorizontalLayout />
+    </js:beads>
+	<js:Container id="cont" width="100%" height="700" x="0" y="0">
+		<js:beads>
+			<js:VerticalLayout />
+		</js:beads>
+		<js:Container id="header" width="100%" height="100" x="0" y="0">
+			<js:beads>
+				<js:HorizontalLayout />
+			</js:beads>
+			<js:Label text="FlexJS Framework Development Unit Tests" className="h1" />
+		</js:Container>
+		<js:Container id="tests" width="100%" height="100%" x="0" y="100">
+			<js:beads>
+				<js:HorizontalLayout />
+			</js:beads>
+			
+		</js:Container>
+	</js:Container>
+	
+</js:View>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/438cb014/manualtests/GenericTests/testsview/src/controllers/MyController.as
----------------------------------------------------------------------
diff --git a/manualtests/GenericTests/testsview/src/controllers/MyController.as b/manualtests/GenericTests/testsview/src/controllers/MyController.as
new file mode 100644
index 0000000..43622ff
--- /dev/null
+++ b/manualtests/GenericTests/testsview/src/controllers/MyController.as
@@ -0,0 +1,52 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package controllers
+{
+	import org.apache.flex.events.Event;
+	
+	import org.apache.flex.core.Application;
+	import org.apache.flex.core.IDocument;
+    
+    import models.MyModel;
+    	
+	public class MyController implements IDocument
+	{
+		public function MyController(app:Application = null)
+		{
+			if (app)
+			{
+				this.app = app as GenericTests;
+				app.addEventListener("viewChanged", viewChangeHandler);
+			}
+		}
+		
+		private var app:GenericTests;
+		
+		private function viewChangeHandler(event:Event):void
+		{
+		}
+		        
+		public function setDocument(document:Object, id:String = null):void
+		{
+			this.app = document as GenericTests;
+			app.addEventListener("viewChanged", viewChangeHandler);
+		}
+
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/438cb014/manualtests/GenericTests/testsview/src/models/MyModel.as
----------------------------------------------------------------------
diff --git a/manualtests/GenericTests/testsview/src/models/MyModel.as b/manualtests/GenericTests/testsview/src/models/MyModel.as
new file mode 100644
index 0000000..5a16d02
--- /dev/null
+++ b/manualtests/GenericTests/testsview/src/models/MyModel.as
@@ -0,0 +1,125 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package models
+{
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.EventDispatcher;
+	
+	public class MyModel extends EventDispatcher
+	{
+		public function MyModel()
+		{
+		}
+		
+		private var _requestedField:String = "Ask";
+		
+		[Bindable("requestedFieldChanged")]
+		public function get requestedField():String
+		{
+			return _requestedField;
+		}
+		
+		public function set requestedField(value:String):void
+		{
+			if (value != _requestedField)
+			{
+				_requestedField = value;
+				dispatchEvent(new Event("requestedFieldChanged"));
+				if (_responseData)
+					dispatchEvent(new Event("responseTextChanged"));
+			}
+		}
+		
+		[Bindable("responseTextChanged")]
+		public function get responseText():String
+		{
+			if (_responseData == null)
+				return "";
+			if (_responseData == "No Data")
+				return _responseData as String;
+			var s:String = _responseData[_requestedField];
+			if (s == null)
+			{
+				if (_requestedField == "Ask")
+					s = _responseData["Bid"];
+			}
+			return s;
+		}
+		
+		private var _responseData:Object;
+		
+		[Bindable("responseDataChanged")]
+		public function get responseData():Object
+		{
+			return _responseData;
+		}
+		
+		public function set responseData(value:Object):void
+		{
+			if (value != _responseData)
+			{
+				_responseData = value;
+				_allData = "";
+				dispatchEvent(new Event("responseDataChanged"));
+				dispatchEvent(new Event("responseTextChanged"));
+			}
+		}
+		
+		private var _allData:String = "";
+		
+		[Bindable("responseDataChanged")]
+		public function get allData():String
+		{
+			if (_allData == "" && _responseData != null)
+			{
+				for (var p:String in _responseData)
+				{
+					_allData += p + ": " + _responseData[p] + "\n";
+				}
+			}
+			return _allData;
+		}
+		
+		
+		private var _stockSymbol:String;
+		
+		[Bindable("stockSymbolChanged")]
+		public function get stockSymbol():String
+		{
+			return _stockSymbol;
+		}
+		
+		public function set stockSymbol(value:String):void
+		{
+			if (value != _stockSymbol)
+			{
+				_stockSymbol = value;
+				dispatchEvent(new Event("stockSymbolChanged"));
+			}
+		}
+
+        private var _strings:Array = ["AAPL", "ADBE", "GOOG", "MSFT", "YHOO"];
+        [Bindable("__NoChangeEvent__")]
+        public function get strings():Array
+        {
+            return _strings;
+        }
+
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/438cb014/manualtests/GenericTests/testsview/src/models/TestResultsModel.as
----------------------------------------------------------------------
diff --git a/manualtests/GenericTests/testsview/src/models/TestResultsModel.as b/manualtests/GenericTests/testsview/src/models/TestResultsModel.as
new file mode 100644
index 0000000..eedbf54
--- /dev/null
+++ b/manualtests/GenericTests/testsview/src/models/TestResultsModel.as
@@ -0,0 +1,40 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package models
+{
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.EventDispatcher;
+	
+	public class TestResultsModel extends EventDispatcher
+	{
+		public function TestResultsModel()
+		{
+		}
+		
+		[Bindable]
+		public var completedTests:ArrayList = new ArrayList([]);
+		
+		public function addCompletedTest(testObj:Object):void{
+			completedTests.
+		}
+		
+		
+
+	}
+}
\ No newline at end of file


Mime
View raw message