papiFactory.getPAPIElementFactory(name.toLowerCase());
assertNotNull("Unknown element name, '" + name + "' check testcase.",
factory);
PAPIElement element = factory.createPAPIElement();
PAPIAttributes attributes = factory.createElementSpecificAttributes();
// If we are opening a subclass of BaseAttributes
// then param[0] will be a style class name
if (attributes instanceof BaseAttributes && params.length >= 1 &&
params[0] != null) {
BaseAttributes ba = (BaseAttributes)attributes;
ba.setStyleClass(params[0]);
}
// If we are opening a Pane param[1] will be the name
if (attributes instanceof PaneAttributes && params.length >= 2) {
PaneAttributes pa = (PaneAttributes)attributes;
pa.setName(params[1]);
}
// If its a Canvas then param[1] will be the page title,
// param[2] the theme file name
// param[3] the layout file name and
// param[4] the type.
if (attributes instanceof CanvasAttributes && params.length >= 5) {
CanvasAttributes ca = (CanvasAttributes)attributes;
ca.setPageTitle(params[1]);
ca.setTheme(params[2]);
ca.setLayoutName(params[3]);
if (params[4] != null) {
ca.setType(params[4]);
}
}
// If we are opening a Region param[1] will be the name
if (attributes instanceof RegionAttributes && params.length >= 2) {
RegionAttributes ra = (RegionAttributes)attributes;
ra.setName(params[1]);
}
// Process start element, this is the thing which does
// the work.
int result = element.elementStart(getCurrentRequestContext(), attributes);
assertEquals("Open did not return PROCESS_ELEMENT_BODY as expected",
result, PROCESS_ELEMENT_BODY);
// Push the element on the stack so that we can close it later.