コード例 #1
0
  // TODO(oana): Added a task in tracker for fixing these dependencies and
  // making the mocking of objects easier.
  public void testEnterArgumentNode() {
    CssDefinitionNode def = new CssDefinitionNode(new CssLiteralNode("COLOR"));

    MutatingVisitController visitController = createMock(MutatingVisitController.class);
    CssTree tree = createMock(CssTree.class);
    expect(tree.getMutatingVisitController()).andReturn(visitController).anyTimes();
    ConstantDefinitions definitions = EasyMock.createMock(ConstantDefinitions.class);
    expect(definitions.getConstantDefinition("COLOR")).andReturn(def).anyTimes();
    replay(definitions);
    replay(tree);

    ReplaceConstantReferences pass =
        new ReplaceConstantReferences(
            tree,
            definitions,
            true /* removeDefs */,
            new DummyErrorManager(),
            true /* allowUndefinedConstants */);

    Capture<List<CssNode>> tempList = new Capture<List<CssNode>>();
    visitController.replaceCurrentBlockChildWith(capture(tempList), eq(true));
    replay(visitController);

    CssConstantReferenceNode node = new CssConstantReferenceNode("COLOR", null);
    pass.enterArgumentNode(node);
    verify(visitController);
    assertEquals(1, tempList.getValue().size());
    assertEquals(CssCompositeValueNode.class, tempList.getValue().get(0).getClass());
  }
コード例 #2
0
  public void testRunPass() {
    MutatingVisitController visitController = createMock(MutatingVisitController.class);

    ColorValueOptimizer pass = new ColorValueOptimizer(visitController);
    visitController.startVisit(pass);
    replay(visitController);

    pass.runPass();
    verify(visitController);
  }
コード例 #3
0
  public void testRunPass() {
    MutatingVisitController visitController = createMock(MutatingVisitController.class);
    CssTree tree = createMock(CssTree.class);
    expect(tree.getMutatingVisitController()).andReturn(visitController).anyTimes();
    // We need to have this replayed because in the constructor of
    // ReplaceConstantReferences pass we need tree.getMutatingVisitController().
    replay(tree);

    ReplaceConstantReferences pass =
        new ReplaceConstantReferences(
            tree,
            new ConstantDefinitions(),
            true /* removeDefs */,
            new DummyErrorManager(),
            true /* allowUndefinedConstants */);
    visitController.startVisit(pass);
    replay(visitController);

    pass.runPass();
    verify(visitController);
  }