Search in sources :

Example 66 with WText

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

the class WListRenderer_Test method testRenderedFormatEmptyWithBorder.

@Test
public void testRenderedFormatEmptyWithBorder() throws IOException, SAXException, XpathException {
    // empty list, with border
    WList list = new WList(WList.Type.STRIPED);
    list.setRenderBorder(true);
    list.setRepeatedComponent(new WText());
    assertSchemaMatch(list);
    assertXpathEvaluatesTo("striped", "//ui:listlayout/@type", list);
    assertXpathEvaluatesTo("box", "//ui:panel/@type", list);
    assertXpathNotExists("//ui:listlayout/@separator", list);
}
Also used : WText(com.github.bordertech.wcomponents.WText) WList(com.github.bordertech.wcomponents.WList) Test(org.junit.Test)

Example 67 with WText

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

the class WPanelRenderer_Test method testRenderedLazyModePanel.

@Test
public void testRenderedLazyModePanel() throws IOException, SAXException, XpathException {
    String content = "TEST CONTENT";
    WPanel panel = new WPanel();
    panel.setMode(PanelMode.LAZY);
    panel.add(new WText(content));
    // Content NOT Hidden
    assertSchemaMatch(panel);
    // If not hidden, then the panel's content should be rendered
    assertXpathEvaluatesTo("", "//ui:panel/@type", panel);
    assertXpathEvaluatesTo("", "//ui:panel/@hidden", panel);
    assertXpathEvaluatesTo("lazy", "//ui:panel/@mode", panel);
    assertXpathEvaluatesTo(content, "//ui:panel/ui:content", panel);
    // Content Hidden
    // Create User Context with UI component
    UIContext uic = createUIContext();
    uic.setUI(new DefaultWComponent());
    setActiveContext(uic);
    setFlag(panel, ComponentModel.HIDE_FLAG, true);
    assertSchemaMatch(panel);
    // If hidden, then the panel's content should NOT be rendered
    assertXpathEvaluatesTo("", "//ui:panel/@type", panel);
    assertXpathEvaluatesTo("true", "//ui:panel/@hidden", panel);
    assertXpathEvaluatesTo("lazy", "//ui:panel/@mode", panel);
    assertXpathEvaluatesTo("", "//ui:panel/ui:content", panel);
}
Also used : 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)

Example 68 with WText

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

the class WSectionRenderer_Test method testRenderedLazyMode.

@Test
public void testRenderedLazyMode() throws IOException, SAXException, XpathException {
    WSection section = new WSection(SECTION_HEADING);
    section.setMode(SectionMode.LAZY);
    section.getContent().add(new WText(SECTION_CONTENT));
    // Content NOT Hidden
    assertSchemaMatch(section);
    // If not hidden, then the section's content should be rendered
    assertXpathEvaluatesTo("", "//ui:section/@type", section);
    assertXpathEvaluatesTo("", "//ui:section/@hidden", section);
    assertXpathEvaluatesTo("lazy", "//ui:section/@mode", section);
    assertXpathEvaluatesTo(SECTION_CONTENT, "normalize-space(//ui:section/ui:panel)", section);
    // Content Hidden
    // Create User Context with UI component
    UIContext uic = createUIContext();
    uic.setUI(new DefaultWComponent());
    setActiveContext(uic);
    setFlag(section, ComponentModel.HIDE_FLAG, true);
    assertSchemaMatch(section);
    // If hidden, then the section's content should NOT be rendered
    assertXpathEvaluatesTo("", "//ui:section/@type", section);
    assertXpathEvaluatesTo("true", "//ui:section/@hidden", section);
    assertXpathEvaluatesTo("lazy", "//ui:section/@mode", section);
    assertXpathEvaluatesTo("", "normalize-space(//ui:section/ui:panel)", section);
}
Also used : WSection(com.github.bordertech.wcomponents.WSection) WText(com.github.bordertech.wcomponents.WText) UIContext(com.github.bordertech.wcomponents.UIContext) DefaultWComponent(com.github.bordertech.wcomponents.DefaultWComponent) Test(org.junit.Test)

Example 69 with WText

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

the class WSectionRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    WSection section = new WSection(getMaliciousContent());
    section.getContent().add(new WText(getMaliciousContent()));
    assertSafeContent(section);
}
Also used : WSection(com.github.bordertech.wcomponents.WSection) WText(com.github.bordertech.wcomponents.WText) Test(org.junit.Test)

Example 70 with WText

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

the class WTabGroupRenderer_Test method testXssEscaping.

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

Aggregations

WText (com.github.bordertech.wcomponents.WText)97 Test (org.junit.Test)63 WPanel (com.github.bordertech.wcomponents.WPanel)17 WCollapsible (com.github.bordertech.wcomponents.WCollapsible)10 WDecoratedLabel (com.github.bordertech.wcomponents.WDecoratedLabel)10 UIContext (com.github.bordertech.wcomponents.UIContext)9 WHeading (com.github.bordertech.wcomponents.WHeading)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 WComponent (com.github.bordertech.wcomponents.WComponent)5 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)5 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)5 WImage (com.github.bordertech.wcomponents.WImage)5 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)5 MockHttpServletRequest (com.github.bordertech.wcomponents.util.mock.servlet.MockHttpServletRequest)5