*/
public void testElementStart() throws Exception {
MenuItemElementImpl element = (MenuItemElementImpl)createTestablePAPIElement();
TestMarinerPageContext pageContext = new TestMarinerPageContext();
MockMenuModelBuilder menuModelBuilder = new MockMenuModelBuilder();
pageContext.setMenuBuilder(menuModelBuilder);
MarinerRequestContext requestContext = new TestMarinerRequestContext();
ProtocolBuilder builder = new ProtocolBuilder();
DOMProtocol protocol = (DOMProtocol) builder.build(
new TestProtocolRegistry.TestDOMProtocolFactory(),
InternalDeviceTestHelper.createTestDevice());
pageContext.pushRequestContext(requestContext);
pageContext.setProtocol(protocol);
ContextInternals.setMarinerPageContext(requestContext, pageContext);
protocol.setMarinerPageContext(pageContext);
MenuElementImpl menuElement = new MenuElementImpl();
Styles testStyles = StylesBuilder.getStyles(
"mcs-menu-image-style: rollover");
PrivateAccessor.setField(menuElement, "menuProperties",
testStyles.getPropertyValues());
pageContext.pushElement(menuElement);
pageContext.setPolicyReferenceResolver(
PolicyReferenceResolverTestHelper.getCommonExpectations(
expectations, mockFactory));
MenuItemAttributes menuItemAttrs = createAttributes();
assertEquals("Set title should not have been called",
null,
menuModelBuilder.getTitle());
int result = element.elementStart(requestContext, menuItemAttrs);
assertTrue("Unexpected value returned from MenuElement. Should have" +
"been PROCESS_ELEMENT_BODY.",
result == PAPIElement.PROCESS_ELEMENT_BODY);
final String msg = "PAPI and Protocol attribute values should match.";
assertEquals(msg, shortcut, menuModelBuilder.getShortcut()
.getText(TextEncoding.PLAIN));
assertEquals(msg, href, menuModelBuilder.getHref().getURL());
assertEquals(msg, prompt, menuModelBuilder.getPrompt()
.getText(TextEncoding.PLAIN));
assertEquals(msg, segment, menuModelBuilder.getSegment());
assertEquals(msg, target, menuModelBuilder.getTarget());
String textString = DOMUtilities.toString((Element)PrivateAccessor.
getField(menuModelBuilder.getText(), "currentElement"));
assertEquals(msg, text, textString);
assertEquals(msg, title, menuModelBuilder.getTitle());
assertNotNull(menuModelBuilder.getOffimage());
assertNotNull(menuModelBuilder.getOnimage());
}