public void notestCheckPaneCellAttributes() throws Exception {
Pane pane = new Pane(null);
PaneAttributes attributes = new PaneAttributes();
TestDOMOutputBuffer dom = new TestDOMOutputBuffer();
Element element = dom.openStyledElement("td", attributes);
attributes.setPane(pane);
// No width set, return DO_NOTHING.
PaneRendering result;
result = protocol.checkPaneCellAttributes(element, attributes);
assertEquals("Expected ",
PaneRendering.DO_NOTHING,
result);
// No width set to zero, return DO_NOTHING.
// attributes.setWidth("0");
result = protocol.checkPaneCellAttributes(element, attributes);
assertEquals("Expected ",
PaneRendering.DO_NOTHING,
result);
// If the width isn't 100% (or zero) and the element has no width
// attribute set already, we can use the enclosing table cell.
// attributes.setWidth("10");
result = protocol.checkPaneCellAttributes(element, attributes);
assertEquals("Expected ",
PaneRendering.USE_ENCLOSING_TABLE_CELL,
result);
// If the enclosing cell is null we need to use a table.
// attributes.setWidth("10");
result = protocol.checkPaneCellAttributes(null, attributes);
assertEquals("Expected ",
PaneRendering.USE_TABLE,
result);
// If the width isn't 100% (or zero) and the element has a width
// attribute set already, we need to use a table.
// attributes.setWidth("10");
element.setAttribute("width", "40");
result = protocol.checkPaneCellAttributes(element, attributes);
assertEquals("Expected ",
PaneRendering.USE_TABLE,
result);
// If the width is 100% we should return DO_NOTHING.
// attributes.setWidth("100");
// attributes.setWidthUnits(PaneAttributes.WIDTH_UNITS_VALUE_PERCENT);
element.setAttribute("width", "40");
result = protocol.checkPaneCellAttributes(element, attributes);
assertEquals("Expected ",
PaneRendering.DO_NOTHING,
result);
// If the style class has been set on the element and the attributes
// and we do not support multiple style classes we should return
// CREATE_ENCLOSING_ELEMENT.
// attributes.setWidth(null);
element.setAttribute("class", "elementStyleClass");
// attributes.setStyleClass("attributeStyleClass");
// testable.setSupportsMultipleAttributeClasses(false);
result = protocol.checkPaneCellAttributes(element, attributes);
assertEquals("Expected ",
PaneRendering.CREATE_ENCLOSING_ELEMENT,
result);
// Same as above except the support of multiple style classes is
// set to true.
// Expect USE_ENCLOSING_TABLE_CELL (classes may be merged).
// attributes.setWidth(null);
element.setAttribute("class", "elementStyleClass");
// attributes.setStyleClass("attributeStyleClass");
// testable.setSupportsMultipleAttributeClasses(true);
result = protocol.checkPaneCellAttributes(element, attributes);
assertEquals("Expected ",
PaneRendering.USE_ENCLOSING_TABLE_CELL,
result);
// Same as above except the support of multiple style classes is
// set to true and a valid width has been set. Expect USE_ENCLOSING_TABLE_CELL.
// attributes.setWidth("10");
element.setAttribute("class", "elementStyleClass");
element.removeAttribute("width");
// attributes.setStyleClass("attributeStyleClass");
// testable.setSupportsMultipleAttributeClasses(true);
result = protocol.checkPaneCellAttributes(element, attributes);
assertEquals("Expected ",
PaneRendering.USE_ENCLOSING_TABLE_CELL,
result);
// If the style class has been set on the element and the attributes
// and we do not support multiple style classes and the style classes
// are the same we should return DO_NOTHING.
// attributes.setWidth(null);
element.setAttribute("class", "bg-blue");
// attributes.setStyleClass("bg-blue");
// testable.setSupportsMultipleAttributeClasses(false);
result = protocol.checkPaneCellAttributes(element, attributes);
assertEquals("Expected ",
PaneRendering.DO_NOTHING,
result);
// Same as above except style class is contained by element style class
// already. Expected DO_NOTHING
// attributes.setWidth(null);
element.setAttribute("class", "bg-blue");
// attributes.setStyleClass("VE-test bg-blue");
// testable.setSupportsMultipleAttributeClasses(false);
result = protocol.checkPaneCellAttributes(element, attributes);
assertEquals("Expected ",
PaneRendering.DO_NOTHING,
result);
// If the style class has been set on the element and the attributes
// and we do not support multiple style classes we should return
// USE_TABLE.
// attributes.setWidth(null);
element.setAttribute("class", "elementStyleClass");
element.setAttribute("valign", "center"); // not supported on a div so use a table.
// attributes.setStyleClass("attributeStyleClass");
// testable.setSupportsMultipleAttributeClasses(false);
result = protocol.checkPaneCellAttributes(element, attributes);
assertEquals("Expected ",
PaneRendering.CREATE_ENCLOSING_ELEMENT,
result);
// Same as above except the support of multiple style classes is
// set to true and a valid width has been set.
// Expect CREATE_ENCLOSING_ELEMENT.
// attributes.setWidth("10");
element.setAttribute("class", "elementStyleClass");
element.removeAttribute("valign");
// attributes.setStyleClass("attributeStyleClass");
// testable.setSupportsMultipleAttributeClasses(false);
result = protocol.checkPaneCellAttributes(element, attributes);
assertEquals("Expected ",
PaneRendering.CREATE_ENCLOSING_ELEMENT,
result);
// If the width is 100 pixels we should return USE_TABLE.
// attributes.setWidth("100");
// attributes.setWidthUnits(PaneAttributes.WIDTH_UNITS_VALUE_PIXELS);
element.setAttribute("width", "40");
result = protocol.checkPaneCellAttributes(element, attributes);
assertEquals("Expected ",
PaneRendering.USE_TABLE,
result);