Examples of CssTree


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

*/
public class PermutationsCollectorTest extends BaseGssTest {

  public void testPermutationCollector() {
    // given
    CssTree cssTree = parseAndBuildTree(lines(
        "@if (is('custom.one', 'foo') && is('custom.one', 'bar')) {",
        "  .foo {",
        "    padding: 5px;",
        " }",
        "}",
        "",
        "@elseif (!is('custom.two', 'foo') && is('custom.three', 'foo') " +
            "|| is('custom.four', 'foo')) {",
        "  .foo {",
        "    padding: 15px;",
        " }",
        "}"));

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

    // when
    visitor.runPass();

View Full Code Here

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

    assertTrue(permutationAxis.contains("custom.three"));
    assertTrue(permutationAxis.contains("custom.four"));
  }

  public void testUserAgentShortcut() {
    CssTree cssTree = parseAndBuildTree(lines(
        "@if (is('custom.one', 'foo') && is('ie6')) {",
        "  .foo {",
        "    padding: 5px;",
        " }",
        "}"));

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

    // when
    visitor.runPass();
View Full Code Here

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

    assertTrue(permutationAxis.contains("custom.one"));
    assertTrue(permutationAxis.contains("user.agent"));
  }

  public void testRuntimeConditionAreIgnored() {
    CssTree cssTree = parseAndBuildTree(lines(
        "@if (eval('com.foo.BAR')) {",
        "  .foo {",
        "    padding: 5px;",
        "  }",
        "}",
        "@elseif (eval('com.foo.bar()')) {",
        "  @if (is('custom.one', 'foo')) {",
        "    .foo {",
        "      padding: 15px;",
        "    }",
        "  }",
        "  @else{",
        "    .foo {",
        "      padding: 15px;",
        "    }",
        "  }",
        "}"));

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

    // when
    visitor.runPass();
View Full Code Here

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

    assertEquals(1, permutationAxis.size());
    assertTrue(permutationAxis.contains("custom.one"));
  }

  public void testInvalidConditionThrowsAnError() {
    CssTree cssTree = parseAndBuildTree(lines(
        "@if (evaluate('com.foo.BAR')) {",
        "  .foo {",
        "    padding: 5px;",
        "  }",
        "}"
    ));

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

    // when
    visitor.runPass();
View Full Code Here

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

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

*/
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

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

    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

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

    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

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

    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

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

    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
Copyright © 2018 www.massapi.com. 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.