Author: czadra
Date: Sat Dec  1 23:09:44 2012
New Revision: 1416076

URL: http://svn.apache.org/viewvc?rev=1416076&view=rev
Log:
added new css tests for Selector, SelectorCondition and Rule

Added:
    
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSRuleTests.java
   (with props)
    
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSSelectorConditionTests.java
   (with props)
    
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSSelectorTests.java
   (with props)
Modified:
    
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSBaseTests.java

Modified: 
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSBaseTests.java
URL: 
http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSBaseTests.java?rev=1416076&r1=1416075&r2=1416076&view=diff
==============================================================================
--- 
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSBaseTests.java
 (original)
+++ 
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSBaseTests.java
 Sat Dec  1 23:09:44 2012
@@ -1,6 +1,8 @@
 package org.apache.flex.compiler.internal.css;
 
+import static org.hamcrest.core.IsNot.not;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -8,6 +10,7 @@ import java.util.List;
 import org.apache.flex.compiler.css.ICSSDocument;
 import org.apache.flex.compiler.css.ICSSProperty;
 import org.apache.flex.compiler.css.ICSSRule;
+import org.apache.flex.compiler.css.ICSSSelector;
 import org.apache.flex.compiler.internal.tree.mxml.MXMLNodeBaseTests;
 import org.apache.flex.compiler.problems.ICompilerProblem;
 import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
@@ -53,8 +56,20 @@ public class CSSBaseTests extends MXMLNo
                for (ICSSRule icssRule : rules) {
                        properties.addAll( icssRule.getProperties() );
                }
-               
+               assertThat("properties", properties,  not( (List<ICSSProperty>) 
null) );
+
                return properties;
        }
+       
+       protected List<ICSSSelector> getCSSSelectors(String code) {
+               ImmutableList<ICSSRule> rules =  getCSSNodeBase( code 
).getRules();
+               assertThat("rules", rules,  not( (ImmutableList<ICSSRule>) 
null) );
+               List<ICSSSelector> selectors = new ArrayList<ICSSSelector>();
+               for (ICSSRule icssRule : rules) {
+                       selectors.addAll( icssRule.getSelectorGroup() );
+               }
+               assertThat("selectors", selectors,  not( (List<ICSSSelector>) 
null) );
+               return selectors;
+       }
 
 }

Added: 
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSRuleTests.java
URL: 
http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSRuleTests.java?rev=1416076&view=auto
==============================================================================
--- 
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSRuleTests.java
 (added)
+++ 
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSRuleTests.java
 Sat Dec  1 23:09:44 2012
@@ -0,0 +1,153 @@
+/*
+ *
+ *  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 org.apache.flex.compiler.internal.css;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.apache.flex.compiler.css.ICSSRule;
+import org.junit.Test;
+
+/**
+ * JUnit tests for {@link CSSRule}.
+ * 
+ * @author Gordon Smith
+ */
+public class CSSRuleTests extends CSSBaseTests {
+       
+       private static final String EOL = "\n\t\t";
+       
+       
+       protected List<ICSSRule> getCSSRules(String code) {
+               return getCSSNodeBase( code ).getRules();
+       }
+       
+       @Test
+       public void CSSRulesTests_properties()
+       {
+               String code =        
+                           " s|VBox { " + EOL + 
+                           "   fontWeight:bold; " + EOL + 
+                           "} ";
+               
+               List<ICSSRule> rules = getCSSRules(code);
+               assertThat("rules.size()" , rules.size(), is(1) );      
+               
+               CSSRule rule = (CSSRule) rules.get(0);
+               assertThat("rule.getMediaQueryConditions().size()" , 
rule.getMediaQueryConditions().size(), is( 0 ) );
+               assertThat("rule.getProperties().size()" , 
rule.getProperties().size(), is( 1 ) );
+               assertThat("rule.getSelectorGroup().size()" , 
rule.getSelectorGroup().size(), is( 1 ) );
+       }
+       
+       @Test
+       public void CSSRulesTests_multiple_properties()
+       {
+               String code =        
+                           " s|VBox { " + EOL + 
+                           "   fontWeight:bold; " + EOL +
+                           "   fontSize:16; " + EOL +
+                           "} ";
+               
+               List<ICSSRule> rules = getCSSRules(code);
+               assertThat("rules.size()" , rules.size(), is(1) );      
+               
+               CSSRule rule = (CSSRule) rules.get(0);
+               assertThat("rule.getMediaQueryConditions().size()" , 
rule.getMediaQueryConditions().size(), is( 0 ) );
+               assertThat("rule.getProperties().size()" , 
rule.getProperties().size(), is( 2 ) );
+               assertThat("rule.getSelectorGroup().size()" , 
rule.getSelectorGroup().size(), is( 1 ) );
+       }
+       
+       @Test
+       public void CSSRulesTests_selecterGroup1()
+       {
+               String code =        
+                               " s|HBox .rounded s|Label.big, " + EOL +
+                           " s|VBox .rounded s|Label.small { " + EOL + 
+                           "   fontWeight:bold; " + EOL + 
+                           "} ";
+               
+               List<ICSSRule> rules = getCSSRules(code);
+               assertThat("rules.size()" , rules.size(), is(1) );      
+               
+               CSSRule rule = (CSSRule) rules.get(0);
+               assertThat("rule.getMediaQueryConditions().size()" , 
rule.getMediaQueryConditions().size(), is( 0 ) );
+               assertThat("rule.getProperties().size()" , 
rule.getProperties().size(), is( 1 ) );
+               assertThat("rule.getSelectorGroup().size()" , 
rule.getSelectorGroup().size(), is( 2 ) );
+       }
+       
+       @Test
+       public void CSSRulesTests_selecterGroup2()
+       {
+               String code =        
+                               " s|HBox, .rounded, s|Label.big, " + EOL +
+                           " s|VBox, .rounded, s|Label.small { " + EOL + 
+                           "   fontWeight:bold; " + EOL + 
+                           "} ";
+               
+               List<ICSSRule> rules = getCSSRules(code);
+               assertThat("rules.size()" , rules.size(), is(1) );      
+               
+               CSSRule rule = (CSSRule) rules.get(0);
+               assertThat("rule.getMediaQueryConditions().size()" , 
rule.getMediaQueryConditions().size(), is( 0 ) );
+               assertThat("rule.getProperties().size()" , 
rule.getProperties().size(), is( 1 ) );
+               assertThat("rule.getSelectorGroup().size()" , 
rule.getSelectorGroup().size(), is( 6 ) );
+
+       }
+       
+       @Test
+       public void CSSRulesTests_mediaQueryCondition1()
+       {
+               
+               String code = 
+                               "@media all and (application-dpi: 240) and 
(os-platform: \"Android\") { " + EOL +
+                           "           s|Label { fontWeight:bold; } " + EOL +
+                           "}";
+               
+               List<ICSSRule> rules = getCSSRules(code);
+               assertThat("rules.size()" , rules.size(), is(1) );      
+               
+               CSSRule rule = (CSSRule) rules.get(0);
+               assertThat("rule.getMediaQueryConditions().size()" , 
rule.getMediaQueryConditions().size(), is( 3 ) );
+               assertThat("rule.getProperties().size()" , 
rule.getProperties().size(), is( 1 ) );
+               assertThat("rule.getSelectorGroup().size()" , 
rule.getSelectorGroup().size(), is( 1 ) );
+       }
+       
+       @Test
+       public void CSSRulesTests_mediaQueryCondition2()
+       {
+               
+               String code = 
+                               "@media all { " + EOL +
+                           "           s|Label { fontWeight:bold; } " + EOL +
+                           "}";
+               
+               List<ICSSRule> rules = getCSSRules(code);
+               assertThat("rules.size()" , rules.size(), is(1) );      
+               
+               CSSRule rule = (CSSRule) rules.get(0);
+               assertThat("rule.getMediaQueryConditions().size()" , 
rule.getMediaQueryConditions().size(), is( 1 ) );
+               assertThat("rule.getProperties().size()" , 
rule.getProperties().size(), is( 1 ) );
+               assertThat("rule.getSelectorGroup().size()" , 
rule.getSelectorGroup().size(), is( 1 ) );
+
+       }
+
+}

Propchange: 
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSRuleTests.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSSelectorConditionTests.java
URL: 
http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSSelectorConditionTests.java?rev=1416076&view=auto
==============================================================================
--- 
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSSelectorConditionTests.java
 (added)
+++ 
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSSelectorConditionTests.java
 Sat Dec  1 23:09:44 2012
@@ -0,0 +1,127 @@
+/*
+ *
+ *  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 org.apache.flex.compiler.internal.css;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flex.compiler.css.ConditionType;
+import org.apache.flex.compiler.css.ICSSDocument;
+import org.apache.flex.compiler.css.ICSSSelector;
+import org.apache.flex.compiler.css.ICSSSelectorCondition;
+import org.junit.Test;
+
+/**
+ * JUnit tests for {@link CSSSelectorCondition}.
+ * 
+ * @author Gordon Smith
+ */
+public class CSSSelectorConditionTests extends CSSBaseTests {
+               
+    private String getPostfix()
+    {
+       return " { } ";
+    }
+    
+       @Override
+       public ICSSDocument getCSSNodeBase(String code) {
+               return super.getCSSNodeBase(code + getPostfix());
+       }
+       
+       
+       protected List<ICSSSelectorCondition> getCSSSelectorConditions(String 
code) {
+               List<ICSSSelector> selectors =  getCSSSelectors( code );
+               assertThat("selectors", selectors,  not( (List<ICSSSelector>) 
null) );
+               List<ICSSSelectorCondition> conditions =  new 
ArrayList<ICSSSelectorCondition>();
+
+               for (ICSSSelector icssSelector : selectors) {
+                       conditions.addAll( icssSelector.getConditions() );
+               }
+               assertThat("conditions", conditions,  not( 
(List<ICSSSelectorCondition>) null) );
+               return conditions;
+       }
+
+       
+       @Test
+       public void CSSSelectorConditionTests_pseudo_condtion()
+       {
+               String code = " s|Button:up "; 
+               
+               List<ICSSSelectorCondition> conditions = 
getCSSSelectorConditions(code);
+               assertThat("conditions.size()" , conditions.size(), is(1) );    
+               
+               CSSSelectorCondition condition = (CSSSelectorCondition) 
conditions.get(0);
+               assertThat("condition.getConditionType()" , 
condition.getConditionType() , is( ConditionType.PSEUDO ) );
+               assertThat("condition.getValue()" , condition.getValue(), is( 
"up" ) );
+       }
+       
+       @Test
+       public void CSSSelectorConditionTests_class_condtion()
+       {
+               String code = " s|Button.rounded "; 
+               
+               List<ICSSSelectorCondition> conditions = 
getCSSSelectorConditions(code);
+               assertThat("conditions.size()" , conditions.size(), is(1) );    
+               
+               CSSSelectorCondition condition = (CSSSelectorCondition) 
conditions.get(0);
+               assertThat("condition.getConditionType()" , 
condition.getConditionType() , is( ConditionType.CLASS ) );
+               assertThat("condition.getValue()" , condition.getValue(), is( 
"rounded" ) );
+       }
+       
+       @Test
+       public void CSSSelectorConditionTests_id_condtion()
+       {
+               String code = " s|Button#main "; 
+               
+               List<ICSSSelectorCondition> conditions = 
getCSSSelectorConditions(code);
+               assertThat("conditions.size()" , conditions.size(), is(1) );    
+               
+               CSSSelectorCondition condition = (CSSSelectorCondition) 
conditions.get(0);
+               assertThat("condition.getConditionType()" , 
condition.getConditionType() , is( ConditionType.ID ) );
+               assertThat("condition.getValue())" , condition.getValue(), is( 
"main" ) );
+       }
+       
+       @Test
+       public void CSSSelectorConditionTests_combined_condtions()
+       {
+               String code = " s|Button.rounded#main:up "; 
+               
+               List<ICSSSelectorCondition> conditions = 
getCSSSelectorConditions(code);
+               assertThat("conditions.size()" , conditions.size(), is(3) );    
+               
+               CSSSelectorCondition condition1 = (CSSSelectorCondition) 
conditions.get(0);
+               assertThat("condition.getConditionType()" , 
condition1.getConditionType() , is( ConditionType.CLASS ) );
+               assertThat("condition.getValue()" , condition1.getValue(), is( 
"rounded" ) );
+               
+               CSSSelectorCondition condition2 = (CSSSelectorCondition) 
conditions.get(1);
+               assertThat("condition.getConditionType()" , 
condition2.getConditionType() , is( ConditionType.ID ) );
+               assertThat("condition.getValue()" , condition2.getValue(), is( 
"main" ) );
+               
+               CSSSelectorCondition condition3 = (CSSSelectorCondition) 
conditions.get(2);
+               assertThat("condition.getConditionType()" , 
condition3.getConditionType() , is( ConditionType.PSEUDO ) );
+               assertThat("condition.getValue()" , condition3.getValue(), is( 
"up" ) );
+       }
+       
+
+}

Propchange: 
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSSelectorConditionTests.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSSelectorTests.java
URL: 
http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSSelectorTests.java?rev=1416076&view=auto
==============================================================================
--- 
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSSelectorTests.java
 (added)
+++ 
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSSelectorTests.java
 Sat Dec  1 23:09:44 2012
@@ -0,0 +1,195 @@
+/*
+ *
+ *  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 org.apache.flex.compiler.internal.css;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.apache.flex.compiler.css.ICSSCombinator;
+import org.apache.flex.compiler.css.ICSSDocument;
+import org.apache.flex.compiler.css.ICSSSelector;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * JUnit tests for {@link CSSSelector}.
+ * 
+ * @author Gordon Smith
+ */
+public class CSSSelectorTests extends CSSBaseTests {
+       
+       private static final String EOL = "\n\t\t";
+       
+    private String getPostfix()
+    {
+       return " { " + EOL + 
+                   "   fontWeight:bold; " + EOL + 
+                   "} ";
+    }
+    
+       @Override
+       public ICSSDocument getCSSNodeBase(String code) {
+               return super.getCSSNodeBase(code + getPostfix());
+       }
+       
+       private ICSSSelector getCSSFirstSelector(String code) {         
+               return getCSSSelectors(code).get(0);
+       }
+       
+       @Test
+       public void CSSSelectorTests_selector1()
+       {
+               String code = " s|VBox "; 
+               
+               List<ICSSSelector> selectors = getCSSSelectors(code);
+               assertThat("selectors.size()" , selectors.size(), is(1) );      
+               
+               CSSSelector selector = (CSSSelector) selectors.get(0);
+               assertThat("selector.getCombinator()" , 
selector.getCombinator() , is( (ICSSCombinator) null ) );
+               assertThat("selector.getConditions().size()" , 
selector.getConditions().size(), is( 0 ) );
+               assertThat("selector.getCSSSyntax()" , selector.getCSSSyntax(), 
is( "s|VBox" ) );               
+               assertThat("selector.getElementName()" , 
selector.getElementName(), is( "VBox" ) );
+               assertThat("selector.getNamespacePrefix()" , 
selector.getNamespacePrefix(), is( "s" ) );
+               assertThat("selector.isAdvanced()" , selector.isAdvanced(), is( 
true ) );
+       }
+       
+       @Test
+       public void CSSSelectorTests_duplicate_selector()
+       {
+               String code = " s|VBox, s|VBox "; 
+               
+               List<ICSSSelector> selectors = getCSSSelectors(code);
+               assertThat("selectors.size()" , selectors.size(), is(2) );      
+               
+               CSSSelector selector1 = (CSSSelector) selectors.get(0);
+               assertThat("selector.getCombinator()" , 
selector1.getCombinator() , is( (ICSSCombinator) null ) );
+               assertThat("selector1.getConditions().size()" , 
selector1.getConditions().size(), is( 0 ) );
+               assertThat("selector1.getCSSSyntax()" , 
selector1.getCSSSyntax(), is( "s|VBox" ) );             
+               assertThat("selector1.getElementName()" , 
selector1.getElementName(), is( "VBox" ) );
+               assertThat("selector1.getNamespacePrefix()" , 
selector1.getNamespacePrefix(), is( "s" ) );
+               assertThat("selector1.isAdvanced()" , selector1.isAdvanced(), 
is( true ) );
+               
+               CSSSelector selector2 = (CSSSelector) selectors.get(0);
+               assertThat("selector.getCombinator()" , 
selector2.getCombinator() , is( (ICSSCombinator) null ) );
+               assertThat("selector2.getConditions().size()" , 
selector2.getConditions().size(), is( 0 ) );
+               assertThat("selector2.getCSSSyntax()" , 
selector2.getCSSSyntax(), is( "s|VBox" ) );             
+               assertThat("selector2.getElementName()" , 
selector2.getElementName(), is( "VBox" ) );
+               assertThat("selector2.getNamespacePrefix()" , 
selector2.getNamespacePrefix(), is( "s" ) );
+               assertThat("selector2.isAdvanced()" , selector2.isAdvanced(), 
is( true ) );
+       }
+       
+       @Test
+       public void CSSSelectorTests_selector_combination()
+       {
+               String code = " s|VBox .test"; 
+               
+               List<ICSSSelector> selectors = getCSSSelectors(code);
+               assertThat("selectors.size()" , selectors.size(), is(1) );      
+               
+               CSSSelector selector = (CSSSelector) selectors.get(0);
+               assertThat("selector.getCombinator()" , 
selector.getCombinator() , not( (ICSSCombinator) null ) );
+               assertThat("selector.getConditions().size()" , 
selector.getConditions().size(), is( 1 ) );
+               assertThat("selector.getCSSSyntax()" , selector.getCSSSyntax(), 
is( "s|VBox .test" ) );         
+               assertThat("selector.getElementName()" , 
selector.getElementName(), is( (String) null ) );
+               assertThat("selector.getNamespacePrefix()" , 
selector.getNamespacePrefix(), is( (String) null ) );
+               assertThat("selector.isAdvanced()" , selector.isAdvanced(), is( 
true ) );
+       }
+       
+       @Test
+       public void CSSSelectorTests_selector_conditions()
+       {
+               String code = " s|Button.rounded#main:up"; 
+               
+               List<ICSSSelector> selectors = getCSSSelectors(code);
+               assertThat("selectors.size()" , selectors.size(), is(1) );      
+               
+               CSSSelector selector = (CSSSelector) selectors.get(0);
+               assertThat("selector.getCombinator()" , 
selector.getCombinator() , is( (ICSSCombinator) null ) );
+               assertThat("selector.getConditions().size()" , 
selector.getConditions().size(), is( 3 ) );
+               assertThat("selector.getCSSSyntax()" , selector.getCSSSyntax(), 
is( "s|Button.rounded#main:up" ) );             
+               assertThat("selector.getElementName()" , 
selector.getElementName(), is( "Button" ) );
+               assertThat("selector.getNamespacePrefix()" , 
selector.getNamespacePrefix(), is( "s" ) );
+               assertThat("selector.isAdvanced()" , selector.isAdvanced(), is( 
true ) );
+
+       }
+       
+       @Test
+       public void CSSSelectorTests_selector_combinator()
+       {
+               String code = " s|VBox s|Label .test"; 
+               
+               List<ICSSSelector> selectors = getCSSSelectors(code);
+               assertThat("selectors.size()" , selectors.size(), is(1) );      
+               
+               CSSSelector selector = (CSSSelector) selectors.get(0);
+               assertThat("selector.getCombinator()" , 
selector.getCombinator() , not( (ICSSCombinator) null ) );
+               assertThat("selector.getConditions().size()" , 
selector.getConditions().size(), is( 1 ) );
+               assertThat("selector.getCSSSyntax()" , selector.getCSSSyntax(), 
is( "s|VBox s|Label .test" ) );         
+               assertThat("selector.getElementName()" , 
selector.getElementName(), is( (String) null ) );
+               assertThat("selector.getNamespacePrefix()" , 
selector.getNamespacePrefix(), is( (String) null ) );
+               assertThat("selector.isAdvanced()" , selector.isAdvanced(), is( 
true ) );
+
+       }
+       
+       @Test
+       public void CSSSelectorTests_selector_combinator_conditions()
+       {
+               String code = " s|VBox , s|HBox s|Button.rounded#main:up "; 
+               
+               List<ICSSSelector> selectors = getCSSSelectors(code);
+               assertThat("selectors.size()" , selectors.size(), is(2) );      
+               
+               CSSSelector selector1 = (CSSSelector) selectors.get(0);
+               assertThat("selector.getCombinator()" , 
selector1.getCombinator() , is( (ICSSCombinator) null ) );
+               assertThat("selector1.getConditions().size()" , 
selector1.getConditions().size(), is( 0 ) );
+               assertThat("selector1.getCSSSyntax()" , 
selector1.getCSSSyntax(), is( "s|VBox" ) );             
+               assertThat("selector1.getElementName()" , 
selector1.getElementName(), is( "VBox") );
+               assertThat("selector1.getNamespacePrefix()" , 
selector1.getNamespacePrefix(), is( "s" ) );
+               assertThat("selector1.isAdvanced()" , selector1.isAdvanced(), 
is( true ) );
+               
+               CSSSelector selector2 = (CSSSelector) selectors.get(1);
+               assertThat("selector.getCombinator()" , 
selector2.getCombinator() , not( (ICSSCombinator) null ) );
+               assertThat("selector2.getConditions().size()" , 
selector2.getConditions().size(), is( 3 ) );
+               assertThat("selector2.getCSSSyntax()" , 
selector2.getCSSSyntax(), is( "s|HBox s|Button.rounded#main:up" ) );            
+               assertThat("selector2.getElementName()" , 
selector2.getElementName(), is( "Button" ) );
+               assertThat("selector2.getNamespacePrefix()" , 
selector2.getNamespacePrefix(), is( "s") );
+               assertThat("selector2.isAdvanced()" , selector2.isAdvanced(), 
is( true ) );
+       }
+       
+       
+       @Test
+       public void CSSSelectorTests_static_getCombinedSelectorList()
+       {
+               ImmutableList<ICSSSelector> combinedSelectors1 = 
CSSSelector.getCombinedSelectorList( getCSSFirstSelector("s|Label .test #Name") 
);
+               assertThat("combinedSelectors1.size()" , 
combinedSelectors1.size(), is( 3 ) );
+               ImmutableList<ICSSSelector> combinedSelectors2 = 
CSSSelector.getCombinedSelectorList( getCSSFirstSelector("#Name") );
+               assertThat("combinedSelectors2.size()" , 
combinedSelectors2.size(), is( 1 ) );
+               ImmutableList<ICSSSelector> combinedSelectors3 = 
CSSSelector.getCombinedSelectorList( getCSSFirstSelector("s|Label") );
+               assertThat("combinedSelectors3.size()" , 
combinedSelectors3.size(), is( 1 ) );
+               ImmutableList<ICSSSelector> combinedSelectors4 = 
CSSSelector.getCombinedSelectorList( null );
+               assertThat("combinedSelectors4.size()" , 
combinedSelectors4.size(), is( 0 ) );
+       }
+
+
+}

Propchange: 
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSSelectorTests.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to