Search in sources :

Example 26 with WText

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

the class WTabSetRenderer_Test method testRenderedWithMargins.

@Test
public void testRenderedWithMargins() throws IOException, SAXException, XpathException {
    WTabSet tabSet = new WTabSet();
    tabSet.addTab(new WText("1"), "1", TabMode.CLIENT);
    assertXpathNotExists("//ui:tabset/ui:margin", tabSet);
    Margin margin = new Margin(null);
    tabSet.setMargin(margin);
    assertXpathNotExists("//ui:tabset/ui:margin", tabSet);
    margin = new Margin(Size.SMALL);
    tabSet.setMargin(margin);
    assertSchemaMatch(tabSet);
    assertXpathEvaluatesTo("sm", "//ui:tabset/ui:margin/@all", tabSet);
    assertXpathEvaluatesTo("", "//ui:tabset/ui:margin/@north", tabSet);
    assertXpathEvaluatesTo("", "//ui:tabset/ui:margin/@east", tabSet);
    assertXpathEvaluatesTo("", "//ui:tabset/ui:margin/@south", tabSet);
    assertXpathEvaluatesTo("", "//ui:tabset/ui:margin/@west", tabSet);
}
Also used : WText(com.github.bordertech.wcomponents.WText) WTabSet(com.github.bordertech.wcomponents.WTabSet) Margin(com.github.bordertech.wcomponents.Margin) Test(org.junit.Test)

Example 27 with WText

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

the class WTabSetRenderer_Test method testSingleAccordian.

@Test
public void testSingleAccordian() throws IOException, SAXException, XpathException {
    WTabSet tabSet = new WTabSet(WTabSet.TabSetType.ACCORDION);
    tabSet.addTab(new WText("1"), "1", TabMode.CLIENT);
    // Default should be single is false (ie not rendered)
    assertSchemaMatch(tabSet);
    assertXpathEvaluatesTo("", "//ui:tabset/@single", tabSet);
    // Default should be single is false (ie not rendered)
    tabSet.setSingle(true);
    assertSchemaMatch(tabSet);
    assertXpathEvaluatesTo("true", "//ui:tabset/@single", tabSet);
}
Also used : WText(com.github.bordertech.wcomponents.WText) WTabSet(com.github.bordertech.wcomponents.WTabSet) Test(org.junit.Test)

Example 28 with WText

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

the class WSectionRenderer_Test method testRenderedEagerMode.

@Test
public void testRenderedEagerMode() throws IOException, SAXException, XpathException {
    WSection section = new WSection(SECTION_HEADING);
    section.setMode(SectionMode.EAGER);
    section.getContent().add(new WText(SECTION_CONTENT));
    UIContext uic = createUIContext();
    uic.setUI(new DefaultWComponent());
    setActiveContext(uic);
    // The section's content should NOT be rendered
    assertSchemaMatch(section);
    assertXpathEvaluatesTo("", "//ui:section/@type", section);
    assertXpathEvaluatesTo("", "//ui:section/@hidden", section);
    assertXpathEvaluatesTo("eager", "//ui:section/@mode", section);
    assertXpathEvaluatesTo("", "normalize-space(//ui:section/ui:panel)", section);
    try {
        // Section is the AJAX Trigger, content should be rendered
        AjaxOperation operation = new AjaxOperation(section.getId(), section.getId());
        AjaxHelper.setCurrentOperationDetails(operation, null);
        assertSchemaMatch(section);
        assertXpathEvaluatesTo("", "//ui:section/@type", section);
        assertXpathEvaluatesTo("", "//ui:section/@hidden", section);
        assertXpathEvaluatesTo("eager", "//ui:section/@mode", section);
        assertXpathEvaluatesTo(SECTION_CONTENT, "normalize-space(//ui:section/ui:panel)", section);
    } finally {
        AjaxHelper.clearCurrentOperationDetails();
    }
}
Also used : WSection(com.github.bordertech.wcomponents.WSection) AjaxOperation(com.github.bordertech.wcomponents.AjaxOperation) WText(com.github.bordertech.wcomponents.WText) UIContext(com.github.bordertech.wcomponents.UIContext) DefaultWComponent(com.github.bordertech.wcomponents.DefaultWComponent) Test(org.junit.Test)

Example 29 with WText

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

the class WTabRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    WTabSet tabSet = new WTabSet();
    WTab tab = tabSet.addTab(new WText("dummy"), getMaliciousContent(), TabMode.CLIENT);
    assertSafeContent(tabSet);
    tab.setToolTip(getMaliciousAttribute("ui:tab"));
    assertSafeContent(tabSet);
    tab.setAccessibleText(getMaliciousAttribute("ui:tab"));
    assertSafeContent(tabSet);
}
Also used : WText(com.github.bordertech.wcomponents.WText) WTab(com.github.bordertech.wcomponents.WTab) WTabSet(com.github.bordertech.wcomponents.WTabSet) Test(org.junit.Test)

Example 30 with WText

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

the class WPanelRenderer_Test method testRenderedEagerModePanel.

@Test
public void testRenderedEagerModePanel() throws IOException, SAXException, XpathException {
    String content = "TEST CONTENT";
    WPanel panel = new WPanel();
    panel.setMode(PanelMode.EAGER);
    panel.add(new WText(content));
    UIContext uic = createUIContext();
    uic.setUI(new DefaultWComponent());
    setActiveContext(uic);
    // The panel's content should NOT be rendered
    assertSchemaMatch(panel);
    assertXpathEvaluatesTo("", "//ui:panel/@type", panel);
    assertXpathEvaluatesTo("", "//ui:panel/@hidden", panel);
    assertXpathEvaluatesTo("eager", "//ui:panel/@mode", panel);
    assertXpathEvaluatesTo("", "//ui:panel/ui:content", panel);
    try {
        // Panel is the AJAX Trigger, content should be rendered
        AjaxOperation operation = new AjaxOperation(panel.getId(), panel.getId());
        AjaxHelper.setCurrentOperationDetails(operation, null);
        assertSchemaMatch(panel);
        assertXpathEvaluatesTo("", "//ui:panel/@type", panel);
        assertXpathEvaluatesTo("", "//ui:panel/@hidden", panel);
        assertXpathEvaluatesTo("eager", "//ui:panel/@mode", panel);
        assertXpathEvaluatesTo(content, "//ui:panel/ui:content", panel);
    } finally {
        AjaxHelper.clearCurrentOperationDetails();
    }
}
Also used : AjaxOperation(com.github.bordertech.wcomponents.AjaxOperation) WText(com.github.bordertech.wcomponents.WText) UIContext(com.github.bordertech.wcomponents.UIContext) WPanel(com.github.bordertech.wcomponents.WPanel) DefaultWComponent(com.github.bordertech.wcomponents.DefaultWComponent) Test(org.junit.Test)

Aggregations

WText (com.github.bordertech.wcomponents.WText)100 Test (org.junit.Test)63 WPanel (com.github.bordertech.wcomponents.WPanel)18 WCollapsible (com.github.bordertech.wcomponents.WCollapsible)10 WDecoratedLabel (com.github.bordertech.wcomponents.WDecoratedLabel)10 WHeading (com.github.bordertech.wcomponents.WHeading)10 UIContext (com.github.bordertech.wcomponents.UIContext)9 WTabSet (com.github.bordertech.wcomponents.WTabSet)7 DefaultWComponent (com.github.bordertech.wcomponents.DefaultWComponent)6 WList (com.github.bordertech.wcomponents.WList)6 WebXmlRenderContext (com.github.bordertech.wcomponents.servlet.WebXmlRenderContext)6 MockResponse (com.github.bordertech.wcomponents.util.mock.MockResponse)6 MockServletConfig (com.github.bordertech.wcomponents.util.mock.servlet.MockServletConfig)6 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)5 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)5 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)5 WImage (com.github.bordertech.wcomponents.WImage)5 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)5 WTextField (com.github.bordertech.wcomponents.WTextField)5 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)5