Search in sources :

Example 6 with WMenuItem

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);
}
Also used : WMenuItem(com.github.bordertech.wcomponents.WMenuItem) Test(org.junit.Test)

Example 7 with WMenuItem

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);
}
Also used : WMenuItem(com.github.bordertech.wcomponents.WMenuItem) WMenu(com.github.bordertech.wcomponents.WMenu) Test(org.junit.Test)

Example 8 with WMenuItem

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);
}
Also used : WMenuItem(com.github.bordertech.wcomponents.WMenuItem) WMenu(com.github.bordertech.wcomponents.WMenu) Test(org.junit.Test)

Example 9 with WMenuItem

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);
}
Also used : WMenuItem(com.github.bordertech.wcomponents.WMenuItem) WMenu(com.github.bordertech.wcomponents.WMenu) Test(org.junit.Test)

Example 10 with WMenuItem

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);
}
Also used : WMenuItem(com.github.bordertech.wcomponents.WMenuItem) WMenu(com.github.bordertech.wcomponents.WMenu) Margin(com.github.bordertech.wcomponents.Margin) Test(org.junit.Test)

Aggregations

WMenuItem (com.github.bordertech.wcomponents.WMenuItem)31 WMenu (com.github.bordertech.wcomponents.WMenu)23 Test (org.junit.Test)16 WSubMenu (com.github.bordertech.wcomponents.WSubMenu)11 WDecoratedLabel (com.github.bordertech.wcomponents.WDecoratedLabel)5 WText (com.github.bordertech.wcomponents.WText)5 Action (com.github.bordertech.wcomponents.Action)4 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)4 WImage (com.github.bordertech.wcomponents.WImage)4 WMenuItemGroup (com.github.bordertech.wcomponents.WMenuItemGroup)4 TreeNode (com.github.bordertech.wcomponents.util.TreeNode)2 Margin (com.github.bordertech.wcomponents.Margin)1 Request (com.github.bordertech.wcomponents.Request)1 TestAction (com.github.bordertech.wcomponents.TestAction)1 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)1 WButton (com.github.bordertech.wcomponents.WButton)1 WContainer (com.github.bordertech.wcomponents.WContainer)1 WContent (com.github.bordertech.wcomponents.WContent)1 WContentLink (com.github.bordertech.wcomponents.WContentLink)1 WPanel (com.github.bordertech.wcomponents.WPanel)1