You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NestedProperties.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright 2000-2013 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.sass.testcases.scss;
  17. import java.io.IOException;
  18. import junit.framework.Assert;
  19. import org.junit.Test;
  20. import org.w3c.css.sac.CSSException;
  21. import com.vaadin.sass.AbstractTestBase;
  22. import com.vaadin.sass.internal.ScssStylesheet;
  23. import com.vaadin.sass.internal.handler.SCSSDocumentHandler;
  24. import com.vaadin.sass.internal.handler.SCSSDocumentHandlerImpl;
  25. import com.vaadin.sass.internal.parser.Parser;
  26. import com.vaadin.sass.internal.tree.BlockNode;
  27. import com.vaadin.sass.internal.tree.NestPropertiesNode;
  28. import com.vaadin.sass.internal.tree.RuleNode;
  29. public class NestedProperties extends AbstractTestBase {
  30. String scss = "/scss/nested-properties.scss";
  31. String css = "/css/nested-properties.css";
  32. @Test
  33. public void testParser() throws CSSException, IOException {
  34. Parser parser = new Parser();
  35. SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl();
  36. parser.setDocumentHandler(handler);
  37. parser.parseStyleSheet(getClass().getResource(scss).getPath());
  38. ScssStylesheet root = handler.getStyleSheet();
  39. Assert.assertEquals(1, root.getChildren().size());
  40. BlockNode blockNode = (BlockNode) root.getChildren().get(0);
  41. Assert.assertEquals(1, blockNode.getChildren().size());
  42. NestPropertiesNode nestPropertiesNode = (NestPropertiesNode) blockNode
  43. .getChildren().get(0);
  44. Assert.assertEquals("font", nestPropertiesNode.getName());
  45. RuleNode nestedProperty0 = (RuleNode) nestPropertiesNode.getChildren()
  46. .get(0);
  47. RuleNode nestedProperty1 = (RuleNode) nestPropertiesNode.getChildren()
  48. .get(1);
  49. RuleNode nestedProperty2 = (RuleNode) nestPropertiesNode.getChildren()
  50. .get(2);
  51. Assert.assertEquals("family", nestedProperty0.getVariable());
  52. Assert.assertEquals("weight", nestedProperty1.getVariable());
  53. Assert.assertEquals("size", nestedProperty2.getVariable());
  54. }
  55. @Test
  56. public void testCompiler() throws Exception {
  57. testCompiler(scss, css);
  58. }
  59. }