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);
}
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);
}
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);
}
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));
}
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));
}
Aggregations