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