Examples of CssTree


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

    assertEquals(expectedTreeToString, cssTree.getRoot().getBody().toString());
  }

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

    Set<String> trueConditions = Sets.newHashSet("foo:BAR");
    ExtendedEliminateConditionalNodes visitor =
        new ExtendedEliminateConditionalNodes(cssTree.getMutatingVisitController(),
            trueConditions, cssRuntimeConditionalBlockNodes);

    // when
    visitor.runPass();

    // then
    String expectedTreeToString = "[[.foo]{[padding:[5px]]}]";

    assertEquals(expectedTreeToString, cssTree.getRoot().getBody().toString());
  }
View Full Code Here

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

*/
public class RecordingBidiFlipperTest extends BaseGssTest {

  public void testFlipWithRuleValueIsRecorded() {
    // given
    CssTree cssTree = parseAndBuildTree(lines(
        ".foo {",
        "  background-position: 10% 20%;",
        "}"));

    RecordingBidiFlipper visitor = new RecordingBidiFlipper(cssTree.getMutatingVisitController(),
        false, false, true);

    // when
    visitor.runPass();

View Full Code Here

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

    assertEquals(true, visitor.nodeFlipped());
  }

  public void testFlipWithRuleNameIsRecorded() {
    // given
    CssTree cssTree = parseAndBuildTree(lines(
        ".foo {",
        "  padding-left: 15px;",
        "}"));

    RecordingBidiFlipper visitor = new RecordingBidiFlipper(cssTree.getMutatingVisitController(),
        false, false, true);

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

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

    assertEquals(true, visitor.nodeFlipped());
  }

  public void testNoFlipNothingIsRecorder() {
    // given
    CssTree cssTree = parseAndBuildTree(lines(
        ".foo {",
        "  background-color: black;",
        "  color: white;",
        "  font-size: 12px;",
        "  padding: 5px;",
        "}"));

    RecordingBidiFlipper visitor = new RecordingBidiFlipper(cssTree.getMutatingVisitController(),
        false, false, true);

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

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

*/
public class RuntimeConditionalBlockCollectorTest extends BaseGssTest {

  public void testCollectRuntimeConditionalBlock() {
    // 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;",
        "  }",
        "}"));

    RuntimeConditionalBlockCollector visitor =
        new RuntimeConditionalBlockCollector(cssTree.getMutatingVisitController());

    // when
    visitor.runPass();

    // then
View Full Code Here

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

            "}"
        ));
  }

  private void assertPrintedResult(String expectedCss, String source) {
    CssTree cssTree = parseAndBuildTree(source);

    CssPrinter pass = new CssPrinter(cssTree);
    pass.runPass();

    assertEquals(expectedCss, pass.getCompactPrintedString());
View Full Code Here

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

   */
  private static class GssWrapper {
    private static Set<String> getCssClassNames(String fileName, String cssSource,
        Set<JClassType> imports, TreeLogger logger) throws UnableToCompleteException {
      SourceCode sourceCode = new SourceCode(fileName, cssSource);
      CssTree tree;
      try {
        tree = new GssParser(sourceCode).parse();
      } catch (GssParserException e) {
        logger.log(TreeLogger.ERROR, "Unable to parse CSS", e);
        throw new UnableToCompleteException();
View Full Code Here

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

    imageMethod = mock(JMethod.class);
  }

  public void testInvalidSpriteWithSeveralValue() {
    // given
    CssTree cssTree = parseAndBuildTree(lines(
        ".someClassWithSprite { ",
        "  gwt-sprite: imageResource otherImageResource;",
        "}"));

    ImageSpriteCreator visitor = new ImageSpriteCreator(cssTree.getMutatingVisitController(),
        resourceContext, errorManager, methodByPathHelper);

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

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

    verify(errorManager).report(any(GssError.class));
  }

  public void testInvalidSpriteImageMethodNotFound() throws NotFoundException {
    // given
    CssTree cssTree = parseAndBuildTree(lines(
        ".someClassWithSprite { ",
        "  gwt-sprite: imageResource;",
        "}"));
    when(resourceContext.getClientBundleType()).thenReturn(mock(JClassType.class));
    when(methodByPathHelper.getMethodByPath(any(ResourceContext.class), anyList(),
        any(JClassType.class))).thenThrow(new NotFoundException(""));

    ImageSpriteCreator visitor = new ImageSpriteCreator(cssTree.getMutatingVisitController(),
        resourceContext, errorManager, methodByPathHelper);

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

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

    testSpriteCreation("no-repeat", RepeatStyle.None);
  }

  private void testSpriteCreation(String repeat, RepeatStyle repeatStyle) throws NotFoundException {
    // given
    CssTree cssTree = parseAndBuildTree(lines(
        ".someClassWithSprite { ",
        "  color: white;",
        "  gwt-sprite: 'imageResource';",
        "  background-color: black;",
        "}"));

    when(methodByPathHelper.getMethodByPath(any(ResourceContext.class), anyList(),
        any(JClassType.class))).thenReturn(imageMethod);

    if (repeatStyle != null) {
      // simulate a @ImageOptions(repeatStyle)
      ImageOptions imageOptions = mock(ImageOptions.class);
      when(imageOptions.repeatStyle()).thenReturn(repeatStyle);
      when(imageMethod.getAnnotation(ImageOptions.class)).thenReturn(imageOptions);
    }

    ImageSpriteCreator visitor = new ImageSpriteCreator(cssTree.getMutatingVisitController(),
        resourceContext, errorManager, methodByPathHelper);

    // when
    visitor.runPass();

    // then
    verify(errorManager, never()).report(any(GssError.class));

    String widthRule = "[/* @alternate */]width:[ImageSpriteCreatorTest.this.imageResource()" +
        ".getWidth() + \"px\"], ";
    String heightRule = "[/* @alternate */]height:[ImageSpriteCreatorTest.this.imageResource()" +
        ".getHeight() + \"px\"], ";

    if (repeatStyle == RepeatStyle.Horizontal || repeatStyle == RepeatStyle.Both) {
      widthRule = "";
    }

    if (repeatStyle == RepeatStyle.Vertical || repeatStyle == RepeatStyle.Both) {
      heightRule = "";
    }

    String cssTreeStringExpected = "[" +
        "[.someClassWithSprite]{" +
        "[color:[white], " +
        heightRule +
        widthRule +
        "[/* @alternate */]overflow:[hidden], " +
        "[/* @alternate */]background:" +
        "[url(ImageSpriteCreatorTest.this.imageResource().getSafeUri().asString()), " +
        "\"-\" + ImageSpriteCreatorTest.this.imageResource().getLeft() + \"px\", " +
        "\"-\" + ImageSpriteCreatorTest.this.imageResource().getTop() + \"px\",  " +
        "" + repeat + "], " +
        "background-color:[black]]" +
        "}]";
    assertEquals(cssTreeStringExpected, cssTree.getRoot().getBody().toString());
  }
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.