You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cz...@apache.org on 2012/12/01 07:30:14 UTC
svn commit: r1415923 -
/incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/
Author: czadra
Date: Sat Dec 1 06:30:13 2012
New Revision: 1415923
URL: http://svn.apache.org/viewvc?rev=1415923&view=rev
Log:
added new css tests CSSFontFaceTests, CSSNamespaceDefinitionTests and CSSPropertyTests
Added:
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSFontFaceTests.java (with props)
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSNamespaceDefinitionTests.java (with props)
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSPropertyTests.java (with props)
Modified:
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSBaseTests.java
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSColorPropertyValueTests.java
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSFunctionCallPropertyValueTests.java
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSPropertyValueTests.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=1415923&r1=1415922&r2=1415923&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 06:30:13 2012
@@ -6,11 +6,15 @@ import java.util.ArrayList;
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.internal.tree.mxml.MXMLNodeBaseTests;
import org.apache.flex.compiler.problems.ICompilerProblem;
import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
import org.apache.flex.compiler.tree.mxml.IMXMLStyleNode;
+import com.google.common.collect.ImmutableList;
+
public class CSSBaseTests extends MXMLNodeBaseTests {
private static final String EOL = "\n\t\t";
@@ -40,5 +44,17 @@ public class CSSBaseTests extends MXMLNo
return styleNode.getCSSDocument(problems);
}
+
+ protected List<ICSSProperty> getCSSProperties(String code) {
+ ICSSDocument doc = getCSSNodeBase(code);
+
+ ImmutableList<ICSSRule> rules = doc.getRules();
+ List<ICSSProperty> properties = new ArrayList<ICSSProperty>();
+ for (ICSSRule icssRule : rules) {
+ properties.addAll( icssRule.getProperties() );
+ }
+
+ return properties;
+ }
}
Modified: incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSColorPropertyValueTests.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSColorPropertyValueTests.java?rev=1415923&r1=1415922&r2=1415923&view=diff
==============================================================================
--- incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSColorPropertyValueTests.java (original)
+++ incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSColorPropertyValueTests.java Sat Dec 1 06:30:13 2012
@@ -94,6 +94,15 @@ public class CSSColorPropertyValueTests
}
@Test
+ public void CSSColorPropertyValue_intColor()
+ {
+ String code = " color: 0xFF0000; ";
+
+ List<CSSColorPropertyValue> colorProperties = getCSSColorPropertyValues(code);
+ assertThat("colorProperties.size()" , colorProperties.size(), is(0) );
+ }
+
+ @Test
public void CSSColorPropertyValue_wrong_hexColor()
{
String code = " color: FF0000; ";
Added: incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSFontFaceTests.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSFontFaceTests.java?rev=1415923&view=auto
==============================================================================
--- incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSFontFaceTests.java (added)
+++ incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSFontFaceTests.java Sat Dec 1 06:30:13 2012
@@ -0,0 +1,175 @@
+/*
+ *
+ * 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.ICSSFontFace;
+import org.junit.Test;
+
+/**
+ * JUnit tests for {@link CSSFontFace}.
+ *
+ * @author Gordon Smith
+ */
+public class CSSFontFaceTests extends CSSBaseTests {
+
+ private static final String EOL = "\n\t\t";
+
+ protected String getPrefix()
+ {
+ return "@font-face {" + EOL;
+ }
+
+ protected String getPostfix()
+ {
+ return EOL + "}";
+ }
+
+ protected List<ICSSFontFace> getCSSFontFace(String code) {
+ return getCSSNodeBase(getPrefix() + code + getPostfix()).getFontFaces();
+ }
+
+ @Test
+ public void CSSFontFaceTests_default_properties()
+ {
+ String code =
+ " src: url(\"font.ttf\");" + EOL +
+ " fontFamily: font";
+
+ List<ICSSFontFace> fontfaces = getCSSFontFace(code);
+ assertThat("fontfaces.size()" , fontfaces.size(), is(1) );
+
+ CSSFontFace fontface = (CSSFontFace) fontfaces.get(0);
+ assertThat("fontface.getFontFamily()" , fontface.getFontFamily(), is( "font" ) );
+ assertThat("fontface.getFontStyle()" , fontface.getFontStyle(), is( "normal" ) );
+ assertThat("fontface.getFontWeight()" , fontface.getFontWeight(), is( "normal" ) );
+ assertThat("fontface.getAdvancedAntiAliasing()" , fontface.getAdvancedAntiAliasing(), is( true ) );
+
+ //TODO Implement missing methods getSourceType() & getSourceValue() & getEmbedAsCFF()
+ //assertThat("fontface.getSourceType()" , fontface.getSourceType(), is( FontFaceSourceType.URL ) );
+ //assertThat("fontface.getSourceValue()" , fontface.getSourceValue(), is( "font.ttf" ) );
+ //assertThat("fontface.getEmbedAsCFF()" , fontface.getEmbedAsCFF(), is( true ) );
+ }
+
+
+ @Test
+ public void CSSFontFaceTests_properties()
+ {
+ String code =
+ " src: url(\"font.ttf\");" + EOL +
+ " fontFamily: font;" + EOL +
+ " fontStyle: italic;" + EOL +
+ " fontWeight: bold;" + EOL +
+ " embedAsCFF: true;" + EOL +
+ " advancedAntiAliasing: true;";
+
+ List<ICSSFontFace> fontfaces = getCSSFontFace(code);
+ assertThat("fontfaces.size()" , fontfaces.size(), is(1) );
+
+ CSSFontFace fontface = (CSSFontFace) fontfaces.get(0);
+ assertThat("fontface.getFontFamily()" , fontface.getFontFamily(), is( "font" ) );
+ assertThat("fontface.getFontStyle()" , fontface.getFontStyle(), is( "italic" ) );
+ assertThat("fontface.getFontWeight()" , fontface.getFontWeight(), is( "bold" ) );
+ assertThat("fontface.getAdvancedAntiAliasing()" , fontface.getAdvancedAntiAliasing(), is( true ) );
+
+ //TODO Implement missing methods getSourceType() & getSourceValue() & getEmbedAsCFF()
+ //assertThat("fontface.getSourceType()" , fontface.getSourceType(), is( FontFaceSourceType.URL ) );
+ //assertThat("fontface.getSourceValue()" , fontface.getSourceValue(), is( "font.ttf" ) );
+ //assertThat("fontface.getEmbedAsCFF()" , fontface.getEmbedAsCFF(), is( true ) );
+ }
+
+ @Test
+ public void CSSFontFaceTests_properties2()
+ {
+ String code =
+ " src: url(\"font.ttf\");" + EOL +
+ " fontFamily: font;" + EOL +
+ " fontStyle: oblique;" + EOL +
+ " fontWeight: heavy;" + EOL +
+ " embedAsCFF: true;" + EOL +
+ " advancedAntiAliasing: true;";
+
+ List<ICSSFontFace> fontfaces = getCSSFontFace(code);
+ assertThat("fontfaces.size()" , fontfaces.size(), is(1) );
+
+ CSSFontFace fontface = (CSSFontFace) fontfaces.get(0);
+ assertThat("fontface.getFontFamily()" , fontface.getFontFamily(), is( "font" ) );
+ assertThat("fontface.getFontStyle()" , fontface.getFontStyle(), is( "oblique" ) );
+ assertThat("fontface.getFontWeight()" , fontface.getFontWeight(), is( "heavy" ) );
+ assertThat("fontface.getAdvancedAntiAliasing()" , fontface.getAdvancedAntiAliasing(), is( true ) );
+
+ //TODO Implement missing methods getSourceType() & getSourceValue() & getEmbedAsCFF()
+ //assertThat("fontface.getSourceType()" , fontface.getSourceType(), is( FontFaceSourceType.URL ) );
+ //assertThat("fontface.getSourceValue()" , fontface.getSourceValue(), is( "font.ttf" ) );
+ //assertThat("fontface.getEmbedAsCFF()" , fontface.getEmbedAsCFF(), is( true ) );
+ }
+
+
+ @Test
+ public void CSSFontFaceTests_src_local()
+ {
+ String code =
+ " src: local(\"Myriad Web Pro\");" + EOL +
+ " fontFamily: font";
+
+ List<ICSSFontFace> fontfaces = getCSSFontFace(code);
+ assertThat("fontfaces.size()" , fontfaces.size(), is(1) );
+
+ CSSFontFace fontface = (CSSFontFace) fontfaces.get(0);
+ assertThat("fontface.getFontFamily()" , fontface.getFontFamily(), is( "font" ) );
+ assertThat("fontface.getFontStyle()" , fontface.getFontStyle(), is( "normal" ) );
+ assertThat("fontface.getFontWeight()" , fontface.getFontWeight(), is( "normal" ) );
+ assertThat("fontface.getAdvancedAntiAliasing()" , fontface.getAdvancedAntiAliasing(), is( true ) );
+
+ //TODO Implement missing methods getSourceType() & getSourceValue() & getEmbedAsCFF()
+ //assertThat("fontface.getSourceType()" , fontface.getSourceType(), is( FontFaceSourceType.LOCAL ) );
+ //assertThat("fontface.getSourceValue()" , fontface.getSourceValue(), is( "Myriad Web Pro" ) );
+ //assertThat("fontface.getEmbedAsCFF()" , fontface.getEmbedAsCFF(), is( true ) );
+ }
+
+ @Test
+ public void CSSFontFaceTests_src_url()
+ {
+ String code =
+ " src: url(\"assets/font.ttf\");" + EOL +
+ " fontFamily: font";
+
+ List<ICSSFontFace> fontfaces = getCSSFontFace(code);
+ assertThat("fontfaces.size()" , fontfaces.size(), is(1) );
+
+ CSSFontFace fontface = (CSSFontFace) fontfaces.get(0);
+ assertThat("fontface.getFontFamily()" , fontface.getFontFamily(), is( "font" ) );
+ assertThat("fontface.getFontStyle()" , fontface.getFontStyle(), is( "normal" ) );
+ assertThat("fontface.getFontWeight()" , fontface.getFontWeight(), is( "normal" ) );
+ assertThat("fontface.getAdvancedAntiAliasing()" , fontface.getAdvancedAntiAliasing(), is( true ) );
+
+ //TODO Implement missing methods getSourceType() & getSourceValue() & getEmbedAsCFF()
+ //assertThat("fontface.getSourceType()" , fontface.getSourceType(), is( FontFaceSourceType.URL ) );
+ //assertThat("fontface.getSourceValue()" , fontface.getSourceValue(), is( "Myriad Web Pro" ) );
+ //assertThat("fontface.getEmbedAsCFF()" , fontface.getEmbedAsCFF(), is( true ) );
+ }
+
+
+
+}
Propchange: incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSFontFaceTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSFunctionCallPropertyValueTests.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSFunctionCallPropertyValueTests.java?rev=1415923&r1=1415922&r2=1415923&view=diff
==============================================================================
--- incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSFunctionCallPropertyValueTests.java (original)
+++ incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSFunctionCallPropertyValueTests.java Sat Dec 1 06:30:13 2012
@@ -88,6 +88,9 @@ public class CSSFunctionCallPropertyValu
public void CSSFunctionCallPropertyValue_static_getSingleArgumentFromRaw() {
assertThat("", CSSFunctionCallPropertyValue.getSingleArgumentFromRaw("\"Test\""), is("Test") );
assertThat("", CSSFunctionCallPropertyValue.getSingleArgumentFromRaw("'Test'"), is("Test") );
+ assertThat("", CSSFunctionCallPropertyValue.getSingleArgumentFromRaw("'Test"), is("'Test") );
+ assertThat("", CSSFunctionCallPropertyValue.getSingleArgumentFromRaw("'Test\""), is("'Test\"") );
+ assertThat("", CSSFunctionCallPropertyValue.getSingleArgumentFromRaw("Test"), is("Test") );
}
}
Added: incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSNamespaceDefinitionTests.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSNamespaceDefinitionTests.java?rev=1415923&view=auto
==============================================================================
--- incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSNamespaceDefinitionTests.java (added)
+++ incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSNamespaceDefinitionTests.java Sat Dec 1 06:30:13 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.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.apache.flex.compiler.css.ICSSNamespaceDefinition;
+import org.junit.Test;
+
+/**
+ * JUnit tests for {@link CSSNamespaceDefinition}.
+ *
+ * @author Gordon Smith
+ */
+public class CSSNamespaceDefinitionTests extends CSSBaseTests {
+
+ private static final String EOL = "\n\t\t";
+
+ protected List<ICSSNamespaceDefinition> getCSSNamespaceDefinition(String code) {
+ return getCSSNodeBase(code).getAtNamespaces();
+ }
+
+ @Test
+ public void CSSNamespaceDefinitionTests_namespace()
+ {
+ String code =
+ " @namespace s \"library://ns.adobe.com/flex/spark\";";
+
+ List<ICSSNamespaceDefinition> namespaces = getCSSNamespaceDefinition(code);
+ assertThat("fontfaces.size()" , namespaces.size(), is(1) );
+
+ CSSNamespaceDefinition namespace = (CSSNamespaceDefinition) namespaces.get(0);
+ assertThat("fontface.getPrefix()" , namespace.getPrefix(), is( "s" ) );
+ assertThat("fontface.getURI()" , namespace.getURI(), is( "library://ns.adobe.com/flex/spark" ) );
+ }
+
+ @Test
+ public void CSSNamespaceDefinitionTests_namespace1()
+ {
+ String code =
+ " @namespace s ;";
+
+ List<ICSSNamespaceDefinition> namespaces = getCSSNamespaceDefinition(code);
+ assertThat("fontfaces.size()" , namespaces.size(), is(1) );
+
+ CSSNamespaceDefinition namespace = (CSSNamespaceDefinition) namespaces.get(0);
+ assertThat("fontface.getPrefix()" , namespace.getPrefix(), is( "s" ) );
+ //TODO why is it "missing STRING"?
+ assertThat("fontface.getURI()" , namespace.getURI(), is( "missing STRING" ) );
+ }
+
+ @Test
+ public void CSSNamespaceDefinitionTests_namespace2()
+ {
+ String code =
+ " @namespace ;";
+
+ List<ICSSNamespaceDefinition> namespaces = getCSSNamespaceDefinition(code);
+ assertThat("fontfaces.size()" , namespaces.size(), is(1) );
+
+ CSSNamespaceDefinition namespace = (CSSNamespaceDefinition) namespaces.get(0);
+ assertThat("fontface.getPrefix()" , namespace.getPrefix(), is( (String)null ) );
+ //TODO why is it "missing STRING"?
+ assertThat("fontface.getURI()" , namespace.getURI(), is( "missing STRING" ) );
+ }
+
+ @Test
+ public void CSSNamespaceDefinitionTests_duplicate_namespace()
+ {
+ String code =
+ " @namespace s \"library://ns.adobe.com/flex/spark\";" + EOL +
+ " @namespace s \"library://ns.adobe.com/flex/spark\";";
+
+ List<ICSSNamespaceDefinition> namespaces = getCSSNamespaceDefinition(code);
+ assertThat("fontfaces.size()" , namespaces.size(), is(2) );
+
+ CSSNamespaceDefinition namespace1 = (CSSNamespaceDefinition) namespaces.get(0);
+ assertThat("fontface.getPrefix()" , namespace1.getPrefix(), is( "s" ) );
+ assertThat("fontface.getURI()" , namespace1.getURI(), is( "library://ns.adobe.com/flex/spark" ) );
+
+ CSSNamespaceDefinition namespace2 = (CSSNamespaceDefinition) namespaces.get(1);
+ assertThat("fontface.getPrefix()" , namespace2.getPrefix(), is( "s" ) );
+ assertThat("fontface.getURI()" , namespace2.getURI(), is( "library://ns.adobe.com/flex/spark" ) );
+ }
+
+ @Test
+ public void CSSNamespaceDefinitionTests_two_namespaces()
+ {
+ String code =
+ " @namespace s \"library://ns.adobe.com/flex/spark\";" + EOL +
+ " @namespace mx \"library://ns.adobe.com/flex/mx\";";
+
+ List<ICSSNamespaceDefinition> namespaces = getCSSNamespaceDefinition(code);
+ assertThat("fontfaces.size()" , namespaces.size(), is(2) );
+
+ CSSNamespaceDefinition namespace1 = (CSSNamespaceDefinition) namespaces.get(0);
+ assertThat("fontface.getPrefix()" , namespace1.getPrefix(), is( "s" ) );
+ assertThat("fontface.getURI()" , namespace1.getURI(), is( "library://ns.adobe.com/flex/spark" ) );
+
+ CSSNamespaceDefinition namespace2 = (CSSNamespaceDefinition) namespaces.get(1);
+ assertThat("fontface.getPrefix()" , namespace2.getPrefix(), is( "mx" ) );
+ assertThat("fontface.getURI()" , namespace2.getURI(), is( "library://ns.adobe.com/flex/mx" ) );
+ }
+
+
+
+}
Propchange: incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSNamespaceDefinitionTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSPropertyTests.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSPropertyTests.java?rev=1415923&view=auto
==============================================================================
--- incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSPropertyTests.java (added)
+++ incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSPropertyTests.java Sat Dec 1 06:30:13 2012
@@ -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 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.ICSSDocument;
+import org.apache.flex.compiler.css.ICSSProperty;
+import org.junit.Test;
+
+/**
+ * JUnit tests for {@link CSSProperty}.
+ *
+ * @author Gordon Smith
+ */
+public class CSSPropertyTests extends CSSBaseTests {
+
+ private static final String EOL = "\n\t\t";
+
+ protected String getPrefix()
+ {
+ return "s|Label {" + EOL;
+ }
+
+ protected String getPostfix()
+ {
+ return EOL +
+ "}";
+ }
+
+ @Override
+ public ICSSDocument getCSSNodeBase(String code) {
+ return super.getCSSNodeBase(getPrefix() + code + getPostfix());
+ }
+
+
+ @Test
+ public void CSSPropertyTests_property()
+ {
+ String code = " color: red; ";
+
+ List<ICSSProperty> properties = getCSSProperties(code);
+ assertThat("properties.size()" , properties.size(), is(1) );
+
+ CSSProperty property = (CSSProperty) properties.get(0);
+ assertThat("stringPropertyValue.getValue()" , property.getName(), is( "color" ) );
+
+ }
+
+ @Test
+ public void CSSPropertyTests_property2()
+ {
+ String code = " font-family: red; ";
+
+ List<ICSSProperty> properties = getCSSProperties(code);
+ assertThat("properties.size()" , properties.size(), is(1) );
+
+ CSSProperty property = (CSSProperty) properties.get(0);
+ assertThat("stringPropertyValue.getValue()" , property.getName(), is( "fontFamily" ) );
+
+ }
+
+ @Test
+ public void CSSPropertyTests_static_normalize()
+ {
+ assertThat("stringPropertyValue.getValue()" , CSSProperty.normalize("font-family") , is( "fontFamily" ) );
+ assertThat("stringPropertyValue.getValue()" , CSSProperty.normalize("fontfamily") , is( "fontfamily" ) );
+ assertThat("stringPropertyValue.getValue()" , CSSProperty.normalize("-font-family") , is( "FontFamily" ) );
+ assertThat("stringPropertyValue.getValue()" , CSSProperty.normalize("-fontfamily") , is( "Fontfamily" ) );
+ assertThat("stringPropertyValue.getValue()" , CSSProperty.normalize("fontfamily-") , is( "fontfamily" ) );
+ }
+
+}
Propchange: incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSPropertyTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSPropertyValueTests.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSPropertyValueTests.java?rev=1415923&r1=1415922&r2=1415923&view=diff
==============================================================================
--- incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSPropertyValueTests.java (original)
+++ incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSPropertyValueTests.java Sat Dec 1 06:30:13 2012
@@ -25,9 +25,6 @@ import java.util.List;
import org.apache.flex.compiler.css.ICSSDocument;
import org.apache.flex.compiler.css.ICSSProperty;
import org.apache.flex.compiler.css.ICSSPropertyValue;
-import org.apache.flex.compiler.css.ICSSRule;
-
-import com.google.common.collect.ImmutableList;
/**
* JUnit tests for {@link CSSPropertyValue}.
@@ -53,18 +50,6 @@ public class CSSPropertyValueTests exten
public ICSSDocument getCSSNodeBase(String code) {
return super.getCSSNodeBase(getPrefix() + code + getPostfix());
}
-
- private List<ICSSProperty> getCSSProperties(String code) {
- ICSSDocument doc = getCSSNodeBase(code);
-
- ImmutableList<ICSSRule> rules = doc.getRules();
- List<ICSSProperty> properties = new ArrayList<ICSSProperty>();
- for (ICSSRule icssRule : rules) {
- properties.addAll( icssRule.getProperties() );
- }
-
- return properties;
- }
protected List<ICSSPropertyValue> getCSSPropertyValues(String code) {
List<ICSSProperty> properties = getCSSProperties(code);