String expectedCSS)
throws Exception {
StringWriter writer = new StringWriter();
StyleSheetRenderer styleSheetRenderer = CSSStyleSheetRenderer.getSingleton();
RendererContext context = new RendererContext(writer,
styleSheetRenderer);
final StyleValuesMock parentValuesMock =
new StyleValuesMock("parentValuesMock", expectations);
StylingFactory stylingFactory = StylingFactory.getDefaultInstance();
final MutableStyleProperties inputProperties =
parser.parseDeclarations(inputCSS);
final MutablePropertyValues inputValues = stylingFactory.createPropertyValues(
StylePropertyDetails.getDefinitions());
inputProperties.iteratePropertyValues(new PropertyValueIteratee() {
public IterationAction next(PropertyValue propertyValue) {
inputValues.setComputedValue(propertyValue.getProperty(),
propertyValue.getValue());
return IterationAction.CONTINUE;
}
});
final MutableStyleProperties outputValues =
ThemeFactory.getDefaultInstance().createMutableStyleProperties();
checker.setInputValues(inputValues);
if (normalizer != null) {
normalizer.normalize(inputValues);
}
// // Create output properties and populate with the computed values.
// PropertyDetailsSet detailsSet = StylePropertyDetails
// .getDefinitions().getStandardDetailsSet();
// detailsSet.iterateStyleProperties(new StylePropertyIteratee() {
// public IterationAction next(StyleProperty property) {
// StyleValue value = inputValues.getComputedValue(property);
//
// outputValues.setStyleValue(property, value);
// return IterationAction.CONTINUE;
// }
// });
//
final DeviceValuesMock deviceValuesMock =
DeviceStylingTestHelper.createDeviceValuesMock(mockFactory,
expectations, DeviceValues.UNKNOWN);
optimizer.optimize(TargetEntity.ELEMENT, inputValues, outputValues,
deviceValuesMock);
renderer.render(outputValues, context);
context.flushStyleSheet();
String actualCSS = writer.getBuffer().toString();
assertEquals(expectedCSS, actualCSS);
}