* Test the openAction method
*/
public void testOpenAction() {
privateSetUp();
TestMarinerPageContext mpc = new TestMarinerPageContext();
mpc.pushRequestContext( new TestMarinerRequestContext());
ProtocolsConfiguration config = new ProtocolsConfiguration();
config.setWmlPreferredOutputFormat("wmlc");
Volantis bean = new Volantis();
bean.setProtocolsConfiguration(config);
mpc.setVolantis(bean);
/**
* Inner class that may be used to iterate through tests in the
* specified order.
*/
class Values {
XFActionAttributes attributes;
boolean inline = false;
boolean supportsAccessKeys = false;
String expected = null;
Values(boolean inline,
boolean supportsAccessKeys,
String expected) {
this(inline, supportsAccessKeys, null, expected);
}
Values(boolean inline,
boolean supportsAccessKeys,
String shortcut,
String expected) {
this(inline, supportsAccessKeys, shortcut, null, null, expected);
}
Values(boolean inline,
boolean supportsAccessKeys,
int tabIndex,
String expected) {
this(inline, supportsAccessKeys, null, expected);
attributes.setTabindex(Integer.toString(tabIndex));
}
Values(boolean inline,
boolean supportsAccessKeys,
String shortcut,
String title,
String caption,
String expected) {
this.inline = inline;
this.supportsAccessKeys = supportsAccessKeys;
this.expected = expected;
attributes = new XFActionAttributes();
attributes.setStyles(StylesBuilder.getInitialValueStyles());
attributes.setShortcut(new LiteralTextAssetReference(shortcut));
attributes.setCaption(new LiteralTextAssetReference(caption));
attributes.setTitle(title);
}
}
List tests = new ArrayList();
// Test anchor generation (not inline)
tests.add(new Values(false, false,
"<do name=\"" + mpc.generateWMLActionID() +
"\" type=\"accept\"/>"));
// Test the tabindex addition
tests.add(new Values(false, false, 8,
"<do name=\"" + mpc.generateWMLActionID() +
"\" type=\"accept\" tabindex=\"8\"/>"));
// Test anchor generation (inline)
tests.add(new Values(true, false,
"<anchor/>"));
// Test shortcut accesskey attribute (accesskeys not allowed)
tests.add(new Values(true, false, "shortcut",
"<anchor/>"));
// Test shortcut accesskey attribute (accesskeys allowed)
tests.add(new Values(true, true, "shortcut",
"<anchor accesskey=\"shortcut\"/>"));
// Test caption generation (not inline)
String caption = "Not Inline Caption";
tests.add(new Values(false, false, null, null, caption,
"<do label=\"" + caption + "\" name=\"" +
mpc.generateWMLActionID() + "\" " +
"type=\"accept\"/>"));
// Test caption generation (inline)
caption = "Inline Caption";
tests.add(new Values(true, false, null, null, caption,
"<anchor>" + caption + "</anchor>"));
// Test caption generation (inline and acceskeys allowed)
caption = "Inline Caption";
tests.add(new Values(true, true, "shortcut", null, caption,
"<anchor accesskey=\"shortcut\">" + caption +
"</anchor>"));
// Test title generation (not inline)
String title = "Not Inline Title";
tests.add(new Values(false, false, null, title, null,
"<do label=\"" + title + "\" name=\"" +
mpc.generateWMLActionID() + "\" " +
"type=\"accept\"/>"));
// Test title generation (inline)
title = "Inline Title";
tests.add(new Values(true, false, null, title, null,