You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by go...@apache.org on 2013/01/12 00:13:53 UTC
svn commit: r1432326 - in
/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags:
MXMLComponentTagTests.java MXMLDefinitionTagTests.java
Author: gordonsmith
Date: Fri Jan 11 23:13:53 2013
New Revision: 1432326
URL: http://svn.apache.org/viewvc?rev=1432326&view=rev
Log:
Falcon: Added feature tests for the <Component> and <Definition> tags.
Added:
flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLComponentTagTests.java (with props)
flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLDefinitionTagTests.java (with props)
Added: flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLComponentTagTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLComponentTagTests.java?rev=1432326&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLComponentTagTests.java (added)
+++ flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLComponentTagTests.java Fri Jan 11 23:13:53 2013
@@ -0,0 +1,74 @@
+/*
+ *
+ * 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 mxml.tags;
+
+import org.junit.Test;
+
+/**
+ * Feature tests for the MXML {@code <Component>} tag.
+ *
+ * @author Gordon Smith
+ */
+public class MXMLComponentTagTests extends MXMLInstanceTagTestsBase
+{
+ // This <Script> function is used by some of the asserts in the tests below
+ // to count the number of properties of an Object.
+ private static String[] scriptDeclarations = new String[]
+ {
+ "private function countProperties(o:Object):int",
+ "{",
+ " var count:int = 0;",
+ " for (var p:String in o)",
+ " {",
+ " count++;",
+ " }",
+ " return count;",
+ "}"
+ };
+
+ // Note: <Component> creates an instance of mx.core.ClassFactory
+ // and therefore must be compiled against framework.swc.
+
+ @Test
+ public void MXMLComponentTag_basic()
+ {
+ String[] declarations = new String[]
+ {
+ "<fx:Component id='c1' className='MySprite'>",
+ " <d:Sprite name='s1'/>",
+ "</fx:Component>"
+ };
+ String[] asserts = new String[]
+ {
+ "import mx.core.ClassFactory", // TODO Should this have to be imported? And should c1 be type IFactory or ClassFactory?
+ "assertEqual('c1', c1 is ClassFactory, true);",
+ "var generator = ClassFactory(c1).generator;",
+ "assertEqual('new generator() is Sprite', new generator() is Sprite, true);",
+ "var properties = ClassFactory(c1).properties;",
+ "assertEqual('countProperties(properties)', countProperties(properties), 1);",
+ "assertEqual('properties.outerDocument', properties.outerDocument, this);",
+ "assertEqual('c1.newInstance() is Sprite', c1.newInstance() is Sprite, true);",
+ "assertEqual('c1.newInstance().name', c1.newInstance().name, 's1');",
+ "assertEqual('c1.newInstance().outerDocument', c1.newInstance().outerDocument, this);",
+ };
+ String mxml = getMXML(declarations, scriptDeclarations, asserts);
+ compileAndRun(mxml, true, false, false, null);
+ }
+}
Propchange: flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLComponentTagTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLDefinitionTagTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLDefinitionTagTests.java?rev=1432326&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLDefinitionTagTests.java (added)
+++ flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLDefinitionTagTests.java Fri Jan 11 23:13:53 2013
@@ -0,0 +1,93 @@
+/*
+ *
+ * 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 mxml.tags;
+
+import org.apache.flex.utils.StringUtils;
+import org.junit.Test;
+
+/**
+ * Feature tests for the MXML {@code <Definition>} tag.
+ *
+ * @author Gordon Smith
+ */
+public class MXMLDefinitionTagTests extends MXMLInstanceTagTestsBase
+{
+ /**
+ * Combines various code snippets to make a complete one-file MXML Sprite-based application.
+ */
+ protected String getMXML(String[] definitions, String[] declarations, String[] asserts)
+ {
+ String[] template = new String[]
+ {
+ "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*' ",
+ " enterFrame='enterFrameHandler(event)'>",
+ " <fx:Library>",
+ " %1",
+ " </fx:Library>",
+ " <fx:Declarations>",
+ " %2",
+ " </fx:Declarations>",
+ " <fx:Script>",
+ " <![CDATA[",
+ " private function assertEqual(message:String, actualValue:*, expectedValue:*):void",
+ " {",
+ " if (actualValue !== expectedValue)",
+ " {",
+ " trace(message, actualValue, expectedValue);",
+ " System.exit(1);",
+ " }",
+ " }",
+ " private function enterFrameHandler(event:Event):void",
+ " {",
+ " %3",
+ " System.exit(0);",
+ " }",
+ " ]]>",
+ " </fx:Script>",
+ "</d:Sprite>"
+ };
+ String mxml = StringUtils.join(template, "\n");
+ mxml = mxml.replace("%1", StringUtils.join(definitions, "\n "));
+ mxml = mxml.replace("%2", StringUtils.join(declarations, "\n "));
+ mxml = mxml.replace("%3", StringUtils.join(asserts, "\n "));
+ return mxml;
+ }
+
+ @Test
+ public void MXMLDefinitionTag_basic()
+ {
+ String[] definitions = new String[]
+ {
+ "<fx:Definition name='MySprite'>",
+ " <d:Sprite/>",
+ "</fx:Definition>"
+ };
+ String[] declarations = new String[]
+ {
+ "<fx:MySprite id='s1'/>"
+ };
+ String[] asserts = new String[]
+ {
+ "assertEqual('s1 is Sprite', s1 is Sprite, true);",
+ };
+ String mxml = getMXML(definitions, declarations, asserts);
+ compileAndRun(mxml);
+ }
+}
Propchange: flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLDefinitionTagTests.java
------------------------------------------------------------------------------
svn:eol-style = native