String css = "body {mcs-container: foo('xyz')}" +
"div {mcs-container: foo('abc')}";
StringReader reader = new StringReader(css);
StylingEngine engine = createStylingEngine(reader,
functionResolverMock);
final EvaluationContext context = engine.getEvaluationContext();
// =====================================================================
// Set Expectations
// =====================================================================
expectations.add(new OrderedExpectations() {
public void add() {
attributesMock.expects.getAttributeValue(
null, "class").returns(null);
stylingFunctionMock.expects
.evaluate(context, "foo",
Arrays.asList(new Object[]{
XYZ_STRING
}))
.returns(ABC_STRING);
attributesMock.expects.getAttributeValue(
null, "class").returns(null);
stylingFunctionMock.expects
.evaluate(context, "foo",
Arrays.asList(new Object[]{
ABC_STRING
}))
.returns(XYZ_STRING);
}
});
// =====================================================================
// Test Expectations
// =====================================================================
StyleValue value;
engine.startElement(NS, "body", attributesMock);
value = getContainerValue(engine, StylePropertyDetails.MCS_CONTAINER);
assertEquals(ABC_STRING, value);
{
engine.startElement(NS, "div", attributesMock);
value = getContainerValue(engine, StylePropertyDetails.MCS_CONTAINER);
assertEquals(XYZ_STRING, value);
engine.endElement(NS, "div");
}
engine.endElement(NS, "body");
}