Search in sources :

Example 1 with TestAction

use of com.github.bordertech.wcomponents.TestAction in project wcomponents by BorderTech.

the class WLinkRenderer_Test method testDoPaintWithAction.

@Test
public void testDoPaintWithAction() throws IOException, SAXException, XpathException {
    WContainer root = new WContainer();
    WLink link = new WLink("test", "http://test");
    WPanel target1 = new WPanel();
    WPanel target2 = new WPanel();
    root.add(link);
    root.add(target1);
    root.add(target2);
    // No Targets (target itself)
    link.setAction(new TestAction());
    assertSchemaMatch(root);
    assertXpathEvaluatesTo(link.getId(), "//ui:ajaxtrigger/@triggerId", root);
    assertXpathEvaluatesTo("1", "count(//ui:ajaxtrigger/ui:ajaxtargetid)", root);
    assertXpathEvaluatesTo(link.getId(), "//ui:ajaxtrigger/ui:ajaxtargetid[1]/@targetId", root);
    // With Targets
    link.setAction(new TestAction(), target1, target2);
    assertSchemaMatch(root);
    assertXpathEvaluatesTo(link.getId(), "//ui:ajaxtrigger/@triggerId", root);
    assertXpathEvaluatesTo("2", "count(//ui:ajaxtrigger/ui:ajaxtargetid)", root);
    assertXpathEvaluatesTo(target1.getId(), "//ui:ajaxtrigger/ui:ajaxtargetid[1]/@targetId", root);
    assertXpathEvaluatesTo(target2.getId(), "//ui:ajaxtrigger/ui:ajaxtargetid[2]/@targetId", root);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) WPanel(com.github.bordertech.wcomponents.WPanel) WLink(com.github.bordertech.wcomponents.WLink) TestAction(com.github.bordertech.wcomponents.TestAction) Test(org.junit.Test)

Example 2 with TestAction

use of com.github.bordertech.wcomponents.TestAction in project wcomponents by BorderTech.

the class WMenuItemRenderer_Test method testAction.

@Test
public void testAction() throws IOException, SAXException, XpathException {
    // Test with action
    WMenuItem item = new WMenuItem(itemText, new TestAction());
    WMenu wrapped = wrapMenuItem(item);
    assertSchemaMatch(wrapped);
    assertXpathEvaluatesTo(itemText, "normalize-space(//ui:menuitem/ui:decoratedlabel)", item);
    assertXpathNotExists("//ui:menuitem/@url", item);
    assertXpathEvaluatesTo("true", "//ui:menuitem/@submit", item);
}
Also used : WMenuItem(com.github.bordertech.wcomponents.WMenuItem) WMenu(com.github.bordertech.wcomponents.WMenu) TestAction(com.github.bordertech.wcomponents.TestAction) Test(org.junit.Test)

Aggregations

TestAction (com.github.bordertech.wcomponents.TestAction)2 Test (org.junit.Test)2 WContainer (com.github.bordertech.wcomponents.WContainer)1 WLink (com.github.bordertech.wcomponents.WLink)1 WMenu (com.github.bordertech.wcomponents.WMenu)1 WMenuItem (com.github.bordertech.wcomponents.WMenuItem)1 WPanel (com.github.bordertech.wcomponents.WPanel)1