Package com.google.gwt.thirdparty.common.css.compiler.ast

Examples of com.google.gwt.thirdparty.common.css.compiler.ast.CssTree


public abstract class BaseGssTest extends TestCase {
  /**
   * Parse the css given in parameter and return the corresponding CssTree.
   */
  protected CssTree parseAndBuildTree(String source) {
    CssTree cssTree = parse(source);

    ErrorManager errorManager = mock(ErrorManager.class);

    runPassesOnNewTree(cssTree, errorManager);

View Full Code Here


*/
public class ValidateRuntimeConditionalNodeTest extends BaseGssTest {

  public void testValidRuntimeConditional() {
    // given
    CssTree cssTree = parseAndBuildTree(lines(
        "@if (eval('com.foo.BAR')) {",
        "  .foo {",
        "    padding: 5px;",
        "  }",
        "  @if (is('ie9')) {",
        "    .foo {",
        "      padding: 55px;",
        "    }",
        "  }",
        "}",
        "@elseif (eval('com.foo.bar()')) {",
        "  @if (eval('com.foo.FOO')) {",
        "    .foo {",
        "      padding: 15px;",
        "    }",
        "  }",
        "  @else{",
        "    .foo {",
        "      padding: 15px;",
        "    }",
        "  }",
        "}",
        "@if (is('ie6')) {",
        "  .foo {",
        "    padding: 25px;",
        "  }",
        "}",
        "@elseif (eval('com.foo.BAR')) {",
        "  .foo {",
        "    padding: 35px;",
        "  }",
        "}"));

    ErrorManager errorManager = mock(ErrorManager.class);
    boolean lenient = false;
    ValidateRuntimeConditionalNode visitor = new ValidateRuntimeConditionalNode(
        cssTree.getMutatingVisitController(), errorManager, lenient);

    // when
    visitor.runPass();

    // then
View Full Code Here

    testInvalidRuntimeConditionalWithExternal(false);
  }

  private void testInvalidRuntimeConditionalWithExternal(boolean lenient) {
    // given
    CssTree cssTree = parseAndBuildTree(lines(
        "@if (eval('com.foo.BAR')) {",
        "  @external foo;",
        "}"));

    ErrorManager errorManager = mock(ErrorManager.class);
    ValidateRuntimeConditionalNode visitor = new ValidateRuntimeConditionalNode(
        cssTree.getMutatingVisitController(), errorManager, lenient);

    // when
    visitor.runPass();

    // then
View Full Code Here

    testInvalidRuntimeConditionalWithConstantDef(false);
  }

  private void testInvalidRuntimeConditionalWithConstantDef(boolean lenient) {
    // given
    CssTree cssTree = parseAndBuildTree(lines(
        "@if (eval('com.foo.BAR')) {",
        "  @def FOO 5px;",
        "}"));

    ErrorManager errorManager = mock(ErrorManager.class);
    ValidateRuntimeConditionalNode visitor = new ValidateRuntimeConditionalNode(
        cssTree.getMutatingVisitController(), errorManager, lenient);

    // when
    visitor.runPass();

    // then
View Full Code Here

    verify(errorManager, warning).reportWarning(any(GssError.class));
  }

  public void testValidCompileTimeConditionalWithConstantDef() {
    // given
    CssTree cssTree = parseAndBuildTree(lines(
        "@if (is('foo', 'bar')) {",
        "  @def FOO 5px;",
        "}"));

    ErrorManager errorManager = mock(ErrorManager.class);
    ValidateRuntimeConditionalNode visitor = new ValidateRuntimeConditionalNode(
        cssTree.getMutatingVisitController(), errorManager, false);

    // when
    visitor.runPass();

    // then
View Full Code Here

    verify(errorManager, never()).reportWarning(any(GssError.class));
  }

  public void testValidCompileTimeConditionalWithExternal() {
    // given
    CssTree cssTree = parseAndBuildTree(lines(
        "@if (is('foo', 'bar')) {",
        "  @external bar;",
        "}"));

    ErrorManager errorManager = mock(ErrorManager.class);
    ValidateRuntimeConditionalNode visitor = new ValidateRuntimeConditionalNode(
        cssTree.getMutatingVisitController(), errorManager, false);

    // when
    visitor.runPass();

    // then
View Full Code Here

TOP

Related Classes of com.google.gwt.thirdparty.common.css.compiler.ast.CssTree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.