incubator-flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gordonsm...@apache.org
Subject svn commit: r1425209 - /incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLModelTagTests.java
Date Sat, 22 Dec 2012 00:20:45 GMT
Author: gordonsmith
Date: Sat Dec 22 00:20:44 2012
New Revision: 1425209

URL: http://svn.apache.org/viewvc?rev=1425209&view=rev
Log:
Falcon: Added some functional tests for the <Model> tag.

Added:
    incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLModelTagTests.java
  (with props)

Added: incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLModelTagTests.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLModelTagTests.java?rev=1425209&view=auto
==============================================================================
--- incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLModelTagTests.java
(added)
+++ incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLModelTagTests.java
Sat Dec 22 00:20:44 2012
@@ -0,0 +1,161 @@
+/*
+ *
+ *  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 <Model>} tag.
+ * 
+ * @author Gordon Smith
+ */
+public class MXMLModelTagTests 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;",
+        "}"
+	};
+	
+	//@Ignore
+    @Test
+    public void MXMLModelTag_empty()
+    {
+        String[] declarations = new String[]
+        {
+            "<fx:Model id='m1'>",
+            "</fx:Model>"
+        };
+        String[] asserts = new String[]
+        {
+        	"import mx.utils.ObjectProxy;",
+            "assertEqual('m1 is ObjectProxy', m1 is ObjectProxy, true);",
+            "assertEqual('countProperties(m1)', countProperties(m1), 0);"
+        };
+        String mxml = getMXML(declarations, scriptDeclarations, asserts);
+        compileAndRun(mxml, true, false, false, null);
+    }
+	
+    @Test
+    public void MXMLModelTag_emptyRoot()
+    {
+        String[] declarations = new String[]
+        {
+            "<fx:Model id='m1'>",
+            "    <root/>",
+            "</fx:Model>"
+        };
+        String[] asserts = new String[]
+        {
+            "import mx.utils.ObjectProxy;",
+            "assertEqual('m1 is ObjectProxy', m1 is ObjectProxy, true);",
+            "assertEqual('countProperties(m1)', countProperties(m1), 0);"
+        };
+        String mxml = getMXML(declarations, scriptDeclarations, asserts);
+        compileAndRun(mxml, true, false, false, null);
+    }
+    
+    @Test
+    public void MXMLModelTag_oneTag()
+    {
+        String[] declarations = new String[]
+        {
+            "<fx:Model id='m1'>",
+            "    <root>",
+            "        <a>xxx</a>",
+            "    </root>",
+            "</fx:Model>"
+        };
+        String[] asserts = new String[]
+        {
+            "import mx.utils.ObjectProxy;",
+            "assertEqual('m1 is ObjectProxy', m1 is ObjectProxy, true);",
+            "assertEqual('countProperties(m1)', countProperties(m1), 1);",
+            "assertEqual('m1.a', m1.a, 'xxx');"
+        };
+        String mxml = getMXML(declarations, scriptDeclarations, asserts);
+        compileAndRun(mxml, true, false, false, null);
+    }
+    
+    @Test
+    public void MXMLModelTag_fourTags()
+    {
+        String[] declarations = new String[]
+        {
+            "<fx:Model id='m1'>",
+            "    <root>",
+            "        <a>1</a>",
+            "        <b>2</b>",
+            "        <a>3</a>",
+            "        <b>4</b>",
+            "    </root>",
+            "</fx:Model>"
+        };
+        String[] asserts = new String[]
+        {
+            "import mx.utils.ObjectProxy;",
+            "assertEqual('m1 is ObjectProxy', m1 is ObjectProxy, true);",
+            "assertEqual('countProperties(m1)', countProperties(m1), 2);",
+            "assertEqual('m1.a.length', m1.a.length, 2);",
+            "assertEqual('m1.a[0]', m1.a[0], 1);",
+            "assertEqual('m1.a[1]', m1.a[1], 3);",
+            "assertEqual('m1.b.length', m1.b.length, 2);",
+            "assertEqual('m1.b[0]', m1.b[0], 2);",
+            "assertEqual('m1.b[1]', m1.b[1], 4);"
+        };
+        String mxml = getMXML(declarations, scriptDeclarations, asserts);
+        compileAndRun(mxml, true, false, false, null);
+    }
+    
+    @Test
+    public void MXMLModelTag_attributes()
+    {
+        String[] declarations = new String[]
+        {
+            "<fx:Model id='m1'>",
+            "    <root>",
+            "        <a b='1' c='2'/>",
+            "    </root>",
+            "</fx:Model>"
+        };
+        String[] asserts = new String[]
+        {
+            "import mx.utils.ObjectProxy;",
+            "assertEqual('m1 is ObjectProxy', m1 is ObjectProxy, true);",
+            "assertEqual('countProperties(m1)', countProperties(m1), 1);",
+            "assertEqual('countProperties(m1.a)', countProperties(m1.a), 2);",
+            "assertEqual('m1.a.b', m1.a.b, 1);",
+            "assertEqual('m1.a.c', m1.a.c, 2);"
+        };
+        String mxml = getMXML(declarations, scriptDeclarations, asserts);
+        compileAndRun(mxml, true, false, false, null);
+    }
+    
+
+}

Propchange: incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLModelTagTests.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message