Search in sources :

Example 6 with WCollapsible

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

the class WCollapsibleRenderer_Test method testDoRenderServerSideCollapse.

@Test
public void testDoRenderServerSideCollapse() throws IOException, SAXException, XpathException {
    WCollapsible collapsible = new WCollapsible(new WText(COLLAPSIBLE_CONTENT), COLLAPSIBLE_HEADING, WCollapsible.CollapsibleMode.SERVER);
    assertSchemaMatch(collapsible);
    // see https://github.com/BorderTech/wcomponents/issues/694
    assertXpathEvaluatesTo("dynamic", "//ui:collapsible/@mode", collapsible);
    assertRenderContentCorrectly(collapsible, false, true);
}
Also used : WCollapsible(com.github.bordertech.wcomponents.WCollapsible) WText(com.github.bordertech.wcomponents.WText) Test(org.junit.Test)

Example 7 with WCollapsible

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

the class WCollapsibleRenderer_Test method testDoRenderEagerCollapse.

@Test
public void testDoRenderEagerCollapse() throws IOException, SAXException, XpathException {
    WCollapsible collapsible = new WCollapsible(new WText(COLLAPSIBLE_CONTENT), COLLAPSIBLE_HEADING, WCollapsible.CollapsibleMode.EAGER);
    assertSchemaMatch(collapsible);
    assertXpathEvaluatesTo("eager", "//ui:collapsible/@mode", collapsible);
    assertRenderContentCorrectly(collapsible, false, false);
}
Also used : WCollapsible(com.github.bordertech.wcomponents.WCollapsible) WText(com.github.bordertech.wcomponents.WText) Test(org.junit.Test)

Example 8 with WCollapsible

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

the class WCollapsibleRenderer_Test method testRendererCorrectlyConfigured.

@Test
public void testRendererCorrectlyConfigured() {
    WCollapsible collapsible = new WCollapsible(new WText(), "");
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(collapsible) instanceof WCollapsibleRenderer);
}
Also used : WCollapsible(com.github.bordertech.wcomponents.WCollapsible) WText(com.github.bordertech.wcomponents.WText) Test(org.junit.Test)

Example 9 with WCollapsible

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

the class WCollapsibleRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    WCollapsible collapsible = new WCollapsible(new WText("dummy"), getMaliciousContent(), WCollapsible.CollapsibleMode.CLIENT);
    assertSafeContent(collapsible);
}
Also used : WCollapsible(com.github.bordertech.wcomponents.WCollapsible) WText(com.github.bordertech.wcomponents.WText) Test(org.junit.Test)

Example 10 with WCollapsible

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

the class WCollapsibleRenderer_Test method testRenderedWithMargins.

@Test
public void testRenderedWithMargins() throws IOException, SAXException, XpathException {
    WCollapsible collapsible = new WCollapsible(new WText(COLLAPSIBLE_CONTENT), COLLAPSIBLE_HEADING, WCollapsible.CollapsibleMode.EAGER);
    assertXpathNotExists("//ui:collapsible/ui:margin", collapsible);
    Margin margin = new Margin(null);
    collapsible.setMargin(margin);
    assertXpathNotExists("//ui:collapsible/ui:margin", collapsible);
    margin = new Margin(Size.SMALL);
    collapsible.setMargin(margin);
    assertSchemaMatch(collapsible);
    assertXpathEvaluatesTo("sm", "//ui:collapsible/ui:margin/@all", collapsible);
    assertXpathEvaluatesTo("", "//ui:collapsible/ui:margin/@north", collapsible);
    assertXpathEvaluatesTo("", "//ui:collapsible/ui:margin/@east", collapsible);
    assertXpathEvaluatesTo("", "//ui:collapsible/ui:margin/@south", collapsible);
    assertXpathEvaluatesTo("", "//ui:collapsible/ui:margin/@west", collapsible);
    margin = new Margin(Size.SMALL, Size.MEDIUM, Size.LARGE, Size.XL);
    collapsible.setMargin(margin);
    assertSchemaMatch(collapsible);
    assertXpathEvaluatesTo("", "//ui:collapsible/ui:margin/@all", collapsible);
    assertXpathEvaluatesTo("sm", "//ui:collapsible/ui:margin/@north", collapsible);
    assertXpathEvaluatesTo("med", "//ui:collapsible/ui:margin/@east", collapsible);
    assertXpathEvaluatesTo("lg", "//ui:collapsible/ui:margin/@south", collapsible);
    assertXpathEvaluatesTo("xl", "//ui:collapsible/ui:margin/@west", collapsible);
}
Also used : WCollapsible(com.github.bordertech.wcomponents.WCollapsible) WText(com.github.bordertech.wcomponents.WText) Margin(com.github.bordertech.wcomponents.Margin) Test(org.junit.Test)

Aggregations

WCollapsible (com.github.bordertech.wcomponents.WCollapsible)11 WText (com.github.bordertech.wcomponents.WText)10 Test (org.junit.Test)9 HeadingLevel (com.github.bordertech.wcomponents.HeadingLevel)1 Margin (com.github.bordertech.wcomponents.Margin)1 WComponent (com.github.bordertech.wcomponents.WComponent)1 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)1 SystemException (com.github.bordertech.wcomponents.util.SystemException)1 Date (java.util.Date)1