Search in sources :

Example 21 with WCheckBoxSelect

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

the class WCheckBoxSelectRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    WCheckBoxSelect wcb = new WCheckBoxSelect(Arrays.asList(new Object[] { getInvalidCharSequence(), getMaliciousContent() }));
    assertSafeContent(wcb);
    wcb.setToolTip(getMaliciousAttribute("ui:checkboxselect"));
    assertSafeContent(wcb);
    wcb.setAccessibleText(getMaliciousAttribute("ui:checkboxselect"));
    assertSafeContent(wcb);
}
Also used : WCheckBoxSelect(com.github.bordertech.wcomponents.WCheckBoxSelect) Test(org.junit.Test)

Example 22 with WCheckBoxSelect

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

the class WCheckBoxSelectRenderer_Test method testDoPaintReadOnly.

@Test
public void testDoPaintReadOnly() throws IOException, SAXException, XpathException {
    WCheckBoxSelect wcbTest = new WCheckBoxSelect(new String[] { "a", "b", "c" });
    assertSchemaMatch(wcbTest);
    setActiveContext(createUIContext());
    // Check Readonly - only render selected option
    wcbTest.setReadOnly(true);
    wcbTest.setSelected(Arrays.asList(new String[] { "b" }));
    assertSchemaMatch(wcbTest);
    assertXpathEvaluatesTo("true", "//ui:checkboxselect/@readOnly", wcbTest);
    assertXpathEvaluatesTo("1", "count(//ui:checkboxselect/ui:option)", wcbTest);
    assertXpathEvaluatesTo("1", "count(//ui:checkboxselect/ui:option[@selected='true'])", wcbTest);
    assertXpathEvaluatesTo("b", "//ui:checkboxselect/ui:option[@selected='true']", wcbTest);
}
Also used : WCheckBoxSelect(com.github.bordertech.wcomponents.WCheckBoxSelect) Test(org.junit.Test)

Example 23 with WCheckBoxSelect

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

the class WCheckBoxSelectRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    WCheckBoxSelect wcbTest = new WCheckBoxSelect(new String[] { "a", "b", "c" });
    assertSchemaMatch(wcbTest);
    assertXpathEvaluatesTo("3", "count(//ui:checkboxselect/ui:option)", wcbTest);
    // Check selected
    assertXpathNotExists("//ui:checkboxselect/ui:option[@selected='true']", wcbTest);
    setActiveContext(createUIContext());
    wcbTest.setSelected(Arrays.asList(new String[] { "b" }));
    assertSchemaMatch(wcbTest);
    assertXpathEvaluatesTo("1", "count(//ui:checkboxselect/ui:option[@selected='true'])", wcbTest);
    assertXpathEvaluatesTo("b", "//ui:checkboxselect/ui:option[@selected='true']", wcbTest);
    // Check Readonly - only render selected option
    wcbTest.setReadOnly(true);
    assertSchemaMatch(wcbTest);
    assertXpathEvaluatesTo("true", "//ui:checkboxselect/@readOnly", wcbTest);
    assertXpathEvaluatesTo("1", "count(//ui:checkboxselect/ui:option)", wcbTest);
    assertXpathEvaluatesTo("1", "count(//ui:checkboxselect/ui:option[@selected='true'])", wcbTest);
    assertXpathEvaluatesTo("b", "//ui:checkboxselect/ui:option[@selected='true']", wcbTest);
}
Also used : WCheckBoxSelect(com.github.bordertech.wcomponents.WCheckBoxSelect) Test(org.junit.Test)

Aggregations

WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)23 WHeading (com.github.bordertech.wcomponents.WHeading)12 Test (org.junit.Test)8 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)7 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)6 WLabel (com.github.bordertech.wcomponents.WLabel)6 WTextField (com.github.bordertech.wcomponents.WTextField)6 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)5 Action (com.github.bordertech.wcomponents.Action)4 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)4 WButton (com.github.bordertech.wcomponents.WButton)4 OptionGroup (com.github.bordertech.wcomponents.OptionGroup)2 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)2 WDateField (com.github.bordertech.wcomponents.WDateField)2 WText (com.github.bordertech.wcomponents.WText)2 WTextArea (com.github.bordertech.wcomponents.WTextArea)2 SystemException (com.github.bordertech.wcomponents.util.SystemException)2 ArrayList (java.util.ArrayList)2 RadioButtonGroup (com.github.bordertech.wcomponents.RadioButtonGroup)1 UIContext (com.github.bordertech.wcomponents.UIContext)1