Search in sources :

Example 71 with WText

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

the class WTabRenderer_Test method testRendererCorrectlyConfigured.

@Test
public void testRendererCorrectlyConfigured() {
    WTabSet tabSet = new WTabSet();
    tabSet.addTab(new WText(""), "", TabMode.DYNAMIC);
    WTab tab = tabSet.getTab(0);
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(tab) instanceof WTabRenderer);
}
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 72 with WText

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

the class WTabRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    String tabName = "WTabRenderer_Test.testDoPaint.tabName";
    String tabContent = "WTabRenderer_Test.testDoPaint.tabContent";
    WTabSet tabSet = new WTabSet();
    WTab tab = tabSet.addTab(new WText(tabContent), tabName, TabMode.CLIENT);
    assertXpathExists("//ui:tab", tabSet);
    assertXpathEvaluatesTo(tab.getId(), "//ui:tab/@id", tabSet);
    assertXpathEvaluatesTo(tabName, "normalize-space(//ui:tab/ui:decoratedlabel)", tabSet);
    assertXpathEvaluatesTo(tabContent, "normalize-space(//ui:tab/ui:tabcontent)", tabSet);
    assertXpathEvaluatesTo("true", "//ui:tab/@open", tabSet);
    assertXpathEvaluatesTo("client", "//ui:tab/@mode", tabSet);
    assertXpathNotExists("//ui:tab/@disabled", tabSet);
    assertXpathNotExists("//ui:tab/@accessKey", tabSet);
    tab.setDisabled(true);
    assertXpathEvaluatesTo("true", "//ui:tab/@disabled", tabSet);
    tabSet.remove(tab);
    tab = tabSet.addTab(new WText(tabContent), tabName, TabMode.LAZY);
    assertXpathEvaluatesTo(tab.getId(), "//ui:tab/@id", tabSet);
    assertXpathEvaluatesTo(tabName, "normalize-space(//ui:tab/ui:decoratedlabel)", tabSet);
    assertXpathEvaluatesTo(tabContent, "normalize-space(//ui:tab/ui:tabcontent)", tabSet);
    assertXpathEvaluatesTo("true", "//ui:tab/@open", tabSet);
    assertXpathEvaluatesTo("lazy", "//ui:tab/@mode", tabSet);
    assertXpathNotExists("//ui:tab/@disabled", tabSet);
    tabSet.remove(tab);
    tab = tabSet.addTab(new WText(tabContent), tabName, TabMode.EAGER);
    assertXpathEvaluatesTo("eager", "//ui:tab/@mode", tabSet);
    tabSet.remove(tab);
    tab = tabSet.addTab(new WText(tabContent), tabName, TabMode.DYNAMIC);
    assertXpathEvaluatesTo("dynamic", "//ui:tab/@mode", tabSet);
    tabSet.remove(tab);
    tab = tabSet.addTab(new WText(tabContent), tabName, TabMode.SERVER, 'X');
    assertXpathEvaluatesTo("dynamic", "//ui:tab/@mode", tabSet);
    assertXpathEvaluatesTo(String.valueOf(tab.getAccessKey()), "//ui:tab/@accessKey", tabSet);
    tabSet.remove(tab);
    tab = tabSet.addTab(new WText(tabContent), tabName, TabMode.CLIENT);
    tab.setToolTip("Title");
    assertXpathEvaluatesTo(String.valueOf(tab.getToolTip()), "//ui:tab/@toolTip", 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 73 with WText

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

the class WTabSetRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    WTabSet tabSet = new WTabSet();
    tabSet.addTab(new WText("1"), "1", TabMode.CLIENT);
    tabSet.addTab(new WText("2"), "3", TabMode.CLIENT);
    tabSet.addTab(new WText("2"), "3", TabMode.CLIENT);
    assertSchemaMatch(tabSet);
    assertXpathExists("//ui:tabset", tabSet);
    assertXpathEvaluatesTo("3", "count(//ui:tabset/ui:tab)", tabSet);
    assertXpathEvaluatesTo(tabSet.getId(), "//ui:tabset/@id", tabSet);
    assertXpathEvaluatesTo(WTabSetRenderer.getTypeAsString(tabSet.getType()), "//ui:tabset/@type", tabSet);
    assertXpathNotExists("//ui:tabset/@disabled", tabSet);
    tabSet.setDisabled(true);
    assertXpathEvaluatesTo("true", "//ui:tabset/@disabled", tabSet);
    tabSet.setDisabled(false);
}
Also used : WText(com.github.bordertech.wcomponents.WText) WTabSet(com.github.bordertech.wcomponents.WTabSet) Test(org.junit.Test)

Example 74 with WText

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

the class WTemplateRenderer_Test method setupTemplate.

/**
 * @param template the template to setup
 */
private void setupTemplate(final WTemplate template) {
    template.setIdName(TEST_ID);
    template.addTaggedComponent("child1", new WText(CHILD_TEXT));
    template.addParameter("mytest", PARAMETER_TEXT);
    template.setBean(new TestBean(FIRST_NAME, LAST_NAME));
}
Also used : WText(com.github.bordertech.wcomponents.WText)

Example 75 with WText

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

the class WTextRenderer_Test method testEncodeText.

@Test
public void testEncodeText() throws IOException, SAXException, XpathException {
    String value = "T1<b>T2</b>T3";
    String encoded = WebUtilities.encode(value);
    WText text = new WText();
    text.setText(value);
    // Encoded (default)
    String xml = toXHtml(text);
    Assert.assertTrue("XML should have encoded text", xml.contains(encoded));
    // Not encoded
    text.setEncodeText(false);
    xml = toXHtml(text);
    Assert.assertTrue("XML should have not encoded text", xml.contains(value));
}
Also used : WText(com.github.bordertech.wcomponents.WText) 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