use of com.github.bordertech.wcomponents.WMenu in project wcomponents by BorderTech.
the class WMenuItemRenderer_Test method testTargetWindow.
@Test
public void testTargetWindow() throws IOException, SAXException, XpathException {
final String targetWindow = "WMenuItemLayout-targetWindow";
// Test with target window
WMenuItem item = new WMenuItem(itemText, url);
item.setTargetWindow(targetWindow);
WMenu wrapped = wrapMenuItem(item);
assertSchemaMatch(wrapped);
assertXpathEvaluatesTo(itemText, "normalize-space(//ui:menuitem/ui:decoratedlabel)", item);
assertXpathEvaluatesTo(targetWindow, "//ui:menuitem/@targetWindow", item);
}
use of com.github.bordertech.wcomponents.WMenu in project wcomponents by BorderTech.
the class WMenuItemRenderer_Test method wrapMenuItem.
/**
* Menu items can not be used stand-alone, so we must test them through a WMenu.
*
* @param item the menu item
* @return the menu item wrapped
*/
private WMenu wrapMenuItem(final WMenuItem item) {
WMenu menu = new WMenu();
menu.add(item);
return menu;
}
use of com.github.bordertech.wcomponents.WMenu in project wcomponents by BorderTech.
the class WMenuItemRenderer_Test method testSelection.
@Test
public void testSelection() throws IOException, SAXException, XpathException {
// Test selection
WMenuItem item = new WMenuItem(itemText);
WMenu wrapped = wrapMenuItem(item);
wrapped.setSelectionMode(MenuSelectContainer.SelectionMode.SINGLE);
assertXpathNotExists("//ui:menuitem/@selected", item);
wrapped.setSelectedItem(item);
assertSchemaMatch(wrapped);
assertXpathEvaluatesTo("true", "//ui:menuitem/@selected", item);
}
use of com.github.bordertech.wcomponents.WMenu in project wcomponents by BorderTech.
the class WMenuItemRenderer_Test method testDoPaintDefaults.
@Test
public void testDoPaintDefaults() throws IOException, SAXException, XpathException {
WMenuItem item = new WMenuItem(itemText);
WMenu wrapped = wrapMenuItem(item);
setActiveContext(createUIContext());
assertSchemaMatch(wrapped);
assertXpathExists("//ui:menuitem", wrapped);
assertXpathEvaluatesTo(itemText, "normalize-space(//ui:menuitem/ui:decoratedlabel)", item);
assertXpathEvaluatesTo(item.getId(), "//ui:menuitem/@id", item);
assertXpathNotExists("//ui:menuitem/@url", item);
assertXpathNotExists("//ui:menuitem/@submit", item);
assertXpathNotExists("//ui:menuitem/@disabled", item);
assertXpathNotExists("//ui:menuitem/@accessKey", item);
assertXpathNotExists("//ui:menuitem/@targetWindow", item);
assertXpathNotExists("//ui:menuitem/@selectable", item);
assertXpathNotExists("//ui:menuitem/@role", item);
}
use of com.github.bordertech.wcomponents.WMenu in project wcomponents by BorderTech.
the class WMenuItemRenderer_Test method testDisabled.
@Test
public void testDisabled() throws IOException, SAXException, XpathException {
// Disabled
WMenuItem item = new WMenuItem(itemText, url);
WMenu wrapped = wrapMenuItem(item);
item.setDisabled(true);
assertSchemaMatch(wrapped);
assertXpathEvaluatesTo("true", "//ui:menuitem/@disabled", item);
// disabled menu should provide disabled menu item
item = new WMenuItem(itemText, url);
wrapped = wrapMenuItem(item);
wrapped.setDisabled(true);
assertSchemaMatch(wrapped);
assertXpathEvaluatesTo("true", "//ui:menuitem/@disabled", item);
}
Aggregations