use of com.github.bordertech.wcomponents.WMenuItem in project wcomponents by BorderTech.
the class WMenuItemRenderer_Test method testRendererCorrectlyConfigured.
@Test
public void testRendererCorrectlyConfigured() {
WMenuItem menuItem = new WMenuItem("");
Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(menuItem) instanceof WMenuItemRenderer);
}
use of com.github.bordertech.wcomponents.WMenuItem 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.WMenuItem 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.WMenuItem 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);
}
use of com.github.bordertech.wcomponents.WMenuItem in project wcomponents by BorderTech.
the class WMenuRenderer_Test method testRenderedWithMargins.
@Test
public void testRenderedWithMargins() throws IOException, SAXException, XpathException {
WMenu menu = new WMenu();
menu.add(new WMenuItem(""));
assertXpathNotExists("//ui:menu/ui:margin", menu);
Margin margin = new Margin(0);
menu.setMargin(margin);
assertXpathNotExists("//ui:menu/ui:margin", menu);
margin = new Margin(Size.SMALL);
menu.setMargin(margin);
assertSchemaMatch(menu);
assertXpathEvaluatesTo("sm", "//ui:menu/ui:margin/@all", menu);
assertXpathEvaluatesTo("", "//ui:menu/ui:margin/@north", menu);
assertXpathEvaluatesTo("", "//ui:menu/ui:margin/@east", menu);
assertXpathEvaluatesTo("", "//ui:menu/ui:margin/@south", menu);
assertXpathEvaluatesTo("", "//ui:menu/ui:margin/@west", menu);
margin = new Margin(Size.SMALL, Size.MEDIUM, Size.LARGE, Size.XL);
menu.setMargin(margin);
assertSchemaMatch(menu);
assertXpathEvaluatesTo("", "//ui:menu/ui:margin/@all", menu);
assertXpathEvaluatesTo("sm", "//ui:menu/ui:margin/@north", menu);
assertXpathEvaluatesTo("med", "//ui:menu/ui:margin/@east", menu);
assertXpathEvaluatesTo("lg", "//ui:menu/ui:margin/@south", menu);
assertXpathEvaluatesTo("xl", "//ui:menu/ui:margin/@west", menu);
}
Aggregations