diff options
author | Marc Englund <marc@vaadin.com> | 2012-09-21 11:52:52 +0300 |
---|---|---|
committer | Marc Englund <marc@vaadin.com> | 2012-09-21 11:53:22 +0300 |
commit | 8b28ea439cf09b69574009337c2659dd653d3760 (patch) | |
tree | c7e28e1e29b5608115b84f7b0b0cc334fd312455 /theme-compiler/tests/src | |
parent | 9500a714336d6f08b47f7cba980fc82faf318ef3 (diff) | |
download | vaadin-framework-8b28ea439cf09b69574009337c2659dd653d3760.tar.gz vaadin-framework-8b28ea439cf09b69574009337c2659dd653d3760.zip |
Big SassCompiler change, fixes #9411 #9489 partials for #9354 #9545 #9380 (applied patch)
Diffstat (limited to 'theme-compiler/tests/src')
7 files changed, 96 insertions, 91 deletions
diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ControlDirectives.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ControlDirectives.java index f6b32e32a2..7a0f1f1a25 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ControlDirectives.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ControlDirectives.java @@ -29,7 +29,12 @@ import com.vaadin.sass.ScssStylesheet; import com.vaadin.sass.handler.SCSSDocumentHandler; import com.vaadin.sass.handler.SCSSDocumentHandlerImpl; import com.vaadin.sass.parser.Parser; +import com.vaadin.sass.tree.BlockNode; +import com.vaadin.sass.tree.MixinDefNode; +import com.vaadin.sass.tree.MixinNode; import com.vaadin.sass.tree.Node; +import com.vaadin.sass.tree.controldirective.EachDefNode; +import com.vaadin.sass.tree.controldirective.IfElseDefNode; public class ControlDirectives extends AbstractTestBase { @@ -46,24 +51,21 @@ public class ControlDirectives extends AbstractTestBase { Assert.assertNotNull(root); ArrayList<Node> children = root.getChildren(); - Assert.assertEquals(6, root.getChildren().size()); - // - // Assert.assertTrue(children.get(1) instanceof EachDefNode); - // Assert.assertTrue(children.get(2) instanceof BlockNode); - // Assert.assertTrue(children.get(3) instanceof BlockNode); - // Assert.assertTrue(children.get(4) instanceof BlockNode); - // Assert.assertTrue(children.get(5) instanceof MixinDefNode); - // - // Assert.assertTrue(children.get(2).getChildren().get(0) instanceof - // IfElseDefNode); - // Assert.assertTrue(children.get(3).getChildren().get(0) instanceof - // IfElseDefNode); - // Assert.assertTrue(children.get(4).getChildren().get(0) instanceof - // IfElseDefNode); - // Assert.assertTrue(!(children.get(5).getChildren().get(0) instanceof - // IfElseDefNode)); - // - // Assert.assertEquals(1, children.get(1).getChildren().size()); + Assert.assertEquals(8, root.getChildren().size()); + + Assert.assertTrue(children.get(1) instanceof MixinDefNode); + Assert.assertTrue(children.get(2) instanceof MixinNode); + Assert.assertTrue(children.get(3) instanceof BlockNode); + Assert.assertTrue(children.get(4) instanceof BlockNode); + Assert.assertTrue(children.get(5) instanceof BlockNode); + Assert.assertTrue(children.get(7) instanceof MixinDefNode); + + Assert.assertTrue(children.get(1).getChildren().get(0) instanceof EachDefNode); + Assert.assertTrue(children.get(3).getChildren().get(0) instanceof IfElseDefNode); + Assert.assertTrue(children.get(4).getChildren().get(0) instanceof IfElseDefNode); + Assert.assertTrue(!(children.get(7).getChildren().get(0) instanceof IfElseDefNode)); + + Assert.assertEquals(1, children.get(1).getChildren().size()); } diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Functions.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Functions.java index d2e890c052..cc6d67795c 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Functions.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Functions.java @@ -18,8 +18,7 @@ package com.vaadin.sass.testcases.scss; import java.io.IOException; -import junit.framework.Assert; - +import org.junit.Assert; import org.junit.Test; import org.w3c.css.sac.CSSException; @@ -42,9 +41,9 @@ public class Functions extends AbstractTestBase { parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); ScssStylesheet root = handler.getStyleSheet(); - Assert.assertEquals(1, root.getChildren().size()); - BlockNode blockNode = (BlockNode) root.getChildren().get(0); - Assert.assertEquals(12, blockNode.getChildren().size()); + Assert.assertEquals(3, root.getChildren().size()); + BlockNode blockNode = (BlockNode) root.getChildren().get(2); + Assert.assertEquals(14, blockNode.getChildren().size()); } @Test diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Mixins.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Mixins.java index 4efa88275f..ac3ad20e15 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Mixins.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Mixins.java @@ -29,6 +29,7 @@ import com.vaadin.sass.AbstractTestBase; import com.vaadin.sass.ScssStylesheet; import com.vaadin.sass.handler.SCSSDocumentHandler; import com.vaadin.sass.handler.SCSSDocumentHandlerImpl; +import com.vaadin.sass.parser.LexicalUnitImpl; import com.vaadin.sass.parser.Parser; import com.vaadin.sass.tree.BlockNode; import com.vaadin.sass.tree.MixinDefNode; @@ -71,48 +72,37 @@ public class Mixins extends AbstractTestBase { Assert.assertEquals(3, mainBlockNode.getChildren().size()); MixinNode mixinNode0MainBlock = (MixinNode) mainBlockNode.getChildren() .get(0); - // Assert.assertEquals("rounded-borders", - // mixinNode0MainBlock.getName()); - // Assert.assertEquals(1f, mixinNode0MainBlock.getArglist().get(0) - // .getFloatValue()); - // Assert.assertEquals(LexicalUnit.SAC_PIXEL, mixinNode0MainBlock - // .getArglist().get(0).getLexicalUnitType()); - // MixinNode mixinNOde1MainBlock = (MixinNode) - // mainBlockNode.getChildren() - // .get(1); - // Assert.assertEquals("font-settings", mixinNOde1MainBlock.getName()); - // Assert.assertTrue(mixinNOde1MainBlock.getArglist().isEmpty()); - // - // MixinNode mixinNOde2MainBlock = (MixinNode) - // mainBlockNode.getChildren() - // .get(2); - // Assert.assertEquals("main-details", mixinNOde2MainBlock.getName()); - // Assert.assertTrue(mixinNOde1MainBlock.getArglist().isEmpty()); - // - // MixinNode mixinNode1MainBlock = (MixinNode) - // mainBlockNode.getChildren() - // .get(1); - // Assert.assertTrue(mixinNode1MainBlock.getArglist().isEmpty()); - // - // BlockNode footerBlockNode = (BlockNode) root.getChildren().get(3); - // MixinNode mixinNodeFooterBlock = (MixinNode) footerBlockNode - // .getChildren().get(0); - // Assert.assertEquals(2f, mixinNodeFooterBlock.getArglist().get(0) - // .getFloatValue()); - // Assert.assertEquals("px", mixinNodeFooterBlock.getArglist().get(0) - // .getDimensionUnitText()); - // - // Assert.assertEquals(10f, mixinNodeFooterBlock.getArglist().get(1) - // .getFloatValue()); - // Assert.assertEquals("px", mixinNodeFooterBlock.getArglist().get(1) - // .getDimensionUnitText()); - // - // Assert.assertTrue(root.getChildren().get(4) instanceof MixinDefNode); - // Assert.assertTrue(root.getChildren().get(4).getChildren().get(3) - // instanceof MediaNode); - // Assert.assertTrue(root.getChildren().get(4).getChildren().get(4) - // instanceof MixinNode); + Assert.assertEquals("rounded-borders", mixinNode0MainBlock.getName()); + Assert.assertEquals("mixinVar", mixinNode0MainBlock.getArglist().get(0) + .getStringValue()); + Assert.assertEquals(LexicalUnitImpl.SCSS_VARIABLE, mixinNode0MainBlock + .getArglist().get(0).getLexicalUnitType()); + MixinNode mixinNOde1MainBlock = (MixinNode) mainBlockNode.getChildren() + .get(1); + Assert.assertEquals("font-settings", mixinNOde1MainBlock.getName()); + Assert.assertTrue(mixinNOde1MainBlock.getArglist().isEmpty()); + MixinNode mixinNOde2MainBlock = (MixinNode) mainBlockNode.getChildren() + .get(2); + Assert.assertEquals("main-details", mixinNOde2MainBlock.getName()); + Assert.assertTrue(mixinNOde1MainBlock.getArglist().isEmpty()); + + MixinNode mixinNode1MainBlock = (MixinNode) mainBlockNode.getChildren() + .get(1); + Assert.assertTrue(mixinNode1MainBlock.getArglist().isEmpty()); + + BlockNode footerBlockNode = (BlockNode) root.getChildren().get(3); + MixinNode mixinNodeFooterBlock = (MixinNode) footerBlockNode + .getChildren().get(0); + Assert.assertEquals("mixinVar", mixinNodeFooterBlock.getArglist() + .get(0).getStringValue()); + + Assert.assertTrue(root.getChildren().get(0) instanceof MixinDefNode); + Assert.assertTrue(root.getChildren().get(1) instanceof MixinDefNode); + Assert.assertTrue(root.getChildren().get(5) instanceof MixinDefNode); + Assert.assertTrue(root.getChildren().get(6) instanceof MixinDefNode); + Assert.assertTrue(root.getChildren().get(8) instanceof MixinDefNode); + Assert.assertTrue(root.getChildren().get(9) instanceof MixinNode); } @Test diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentSelector.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentSelector.java index 7ac2450bfc..7f3b3d6551 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentSelector.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentSelector.java @@ -28,7 +28,6 @@ import com.vaadin.sass.ScssStylesheet; import com.vaadin.sass.handler.SCSSDocumentHandler; import com.vaadin.sass.handler.SCSSDocumentHandlerImpl; import com.vaadin.sass.parser.Parser; -import com.vaadin.sass.selector.SelectorUtil; import com.vaadin.sass.tree.BlockNode; public class ParentSelector extends AbstractTestBase { @@ -45,11 +44,10 @@ public class ParentSelector extends AbstractTestBase { BlockNode blockNode = (BlockNode) root.getChildren().get(0); Assert.assertEquals(4, blockNode.getChildren().size()); BlockNode nestedBlock1 = (BlockNode) blockNode.getChildren().get(2); - Assert.assertEquals("&:hover", - SelectorUtil.toString(nestedBlock1.getSelectorList())); + Assert.assertEquals("&:hover", nestedBlock1.getSelectorList().get(0)); BlockNode nestedBlock2 = (BlockNode) blockNode.getChildren().get(3); - Assert.assertEquals("body.firefox &", - SelectorUtil.toString(nestedBlock2.getSelectorList())); + Assert.assertEquals("body.firefox &", nestedBlock2.getSelectorList() + .get(0)); } @Test diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/RemoveDirective.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/RemoveDirective.java new file mode 100644 index 0000000000..e9e87e7b56 --- /dev/null +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/RemoveDirective.java @@ -0,0 +1,25 @@ +package com.vaadin.sass.testcases.scss; + +import java.io.IOException; + +import org.junit.Test; +import org.w3c.css.sac.CSSException; + +import com.vaadin.sass.AbstractTestBase; + +public class RemoveDirective extends AbstractTestBase { + + String scss = "/scss/remove-directive.scss"; + String css = "/css/remove-directive.css"; + + @Test + public void testParser() throws CSSException, IOException { + + } + + @Test + public void testCompiler() throws Exception { + testCompiler(scss, css); + } + +} diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/visitor/MixinVisitorTest.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/visitor/MixinVisitorTest.java index 46d6efbeac..56a35807d1 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/visitor/MixinVisitorTest.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/visitor/MixinVisitorTest.java @@ -20,10 +20,9 @@ import java.util.ArrayList; import org.junit.Assert; import org.junit.Test; -import org.w3c.css.sac.LexicalUnit; -import com.steadystate.css.parser.LexicalUnitImpl; import com.vaadin.sass.ScssStylesheet; +import com.vaadin.sass.parser.LexicalUnitImpl; import com.vaadin.sass.parser.SCSSLexicalUnit; import com.vaadin.sass.tree.BlockNode; import com.vaadin.sass.tree.MixinDefNode; @@ -72,8 +71,10 @@ public class MixinVisitorTest { root.appendChild(mixinDefWithNonDefaultArg); BlockNode blockWithMixin = new BlockNode(null); - ArrayList<LexicalUnit> includeArgs = new ArrayList<LexicalUnit>(); - LexicalUnit includeArg = LexicalUnitImpl.createPixel(null, 1f); + ArrayList<LexicalUnitImpl> includeArgs = new ArrayList<LexicalUnitImpl>(); + LexicalUnitImpl includeArg = LexicalUnitImpl.createPixel(1f); + includeArg.setLexicalUnitType(LexicalUnitImpl.SAC_PIXEL); + includeArg.setFloatValue(1); includeArgs.add(includeArg); MixinNode mixin = new MixinNode("non-default-arg", includeArgs); blockWithMixin.appendChild(mixin); @@ -96,8 +97,8 @@ public class MixinVisitorTest { public void testTraverseMixinWithDefaultArgs() { ScssStylesheet root = new ScssStylesheet(); ArrayList<VariableNode> args = new ArrayList<VariableNode>(); - args.add(new VariableNode("arg", LexicalUnitImpl.createPixel(null, 1f), - false)); + LexicalUnitImpl includeArg = LexicalUnitImpl.createPixel(1f); + args.add(new VariableNode("arg", includeArg, false)); MixinDefNode mixinDefWithNonDefaultArg = new MixinDefNode( "default-arg", args); BlockNode blockNode = new BlockNode(null); @@ -135,16 +136,16 @@ public class MixinVisitorTest { MixinDefNode mixinDefNoArgs = new MixinDefNode("table-base", null); BlockNode thBlockNode = new BlockNode(null); RuleNode textAlignRuleNode = new RuleNode("text-align", - LexicalUnitImpl.createString(null, "center"), false, null); + LexicalUnitImpl.createString("center"), false, null); thBlockNode.appendChild(textAlignRuleNode); RuleNode fontWeightRuleNode = new RuleNode("font-weight", - LexicalUnitImpl.createString(null, "bold"), false, null); + LexicalUnitImpl.createString("bold"), false, null); thBlockNode.appendChild(fontWeightRuleNode); mixinDefNoArgs.appendChild(thBlockNode); BlockNode tdthBlockNode = new BlockNode(null); RuleNode paddingRuleNode = new RuleNode("padding", - LexicalUnitImpl.createPixel(null, 2f), false, null); + LexicalUnitImpl.createPixel(2f), false, null); tdthBlockNode.appendChild(paddingRuleNode); mixinDefNoArgs.appendChild(tdthBlockNode); root.appendChild(mixinDefNoArgs); @@ -205,7 +206,7 @@ public class MixinVisitorTest { MixinDefNode mixinDef = new MixinDefNode("left", argNameList); RuleNode floatRuleNode = new RuleNode("float", - LexicalUnitImpl.createString(null, "left"), false, null); + LexicalUnitImpl.createString("left"), false, null); mixinDef.appendChild(floatRuleNode); RuleNode marginLeftRuleNode = new RuleNode("margin-left", com.vaadin.sass.parser.LexicalUnitImpl.createVariable(0, 0, @@ -214,8 +215,8 @@ public class MixinVisitorTest { root.appendChild(mixinDef); BlockNode dataBlock = new BlockNode(null); - ArrayList<LexicalUnit> argValueList = new ArrayList<LexicalUnit>(); - LexicalUnit arg = LexicalUnitImpl.createPixel(null, 10f); + ArrayList<LexicalUnitImpl> argValueList = new ArrayList<LexicalUnitImpl>(); + LexicalUnitImpl arg = LexicalUnitImpl.createPixel(10f); argValueList.add(arg); MixinNode mixinNode = new MixinNode("left", argValueList); dataBlock.appendChild(mixinNode); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/visitor/NestedPropertiesVisitorTest.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/visitor/NestedPropertiesVisitorTest.java index 3885869b72..eafdb4908f 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/visitor/NestedPropertiesVisitorTest.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/visitor/NestedPropertiesVisitorTest.java @@ -22,7 +22,6 @@ import org.junit.Test; import com.vaadin.sass.ScssStylesheet; import com.vaadin.sass.tree.NestPropertiesNode; import com.vaadin.sass.tree.RuleNode; -import com.vaadin.sass.tree.VariableNode; import com.vaadin.sass.visitor.NestPropertiesVisitor; public class NestedPropertiesVisitorTest { @@ -37,15 +36,6 @@ public class NestedPropertiesVisitorTest { } @Test - public void testNoNestPropertiesNodeNoChange() { - ScssStylesheet root = new ScssStylesheet(); - root.appendChild(new VariableNode("", "")); - Assert.assertEquals(1, root.getChildren().size()); - visitor.traverse(root); - Assert.assertEquals(1, root.getChildren().size()); - } - - @Test public void testNestedPropertiesCanBeUnnested() { ScssStylesheet root = new ScssStylesheet(); NestPropertiesNode nested = new NestPropertiesNode("nested"); |