use of com.github.bordertech.wcomponents.WMultiDropdown in project wcomponents by BorderTech.
the class WMultiDropdownRenderer_Test method testIsNullOption.
@Test
public void testIsNullOption() throws IOException, SAXException, XpathException {
String[] options = new String[] { null, "", "A", "B", "C" };
WMultiDropdown drop = new WMultiDropdown(options);
assertSchemaMatch(drop);
assertXpathEvaluatesTo("5", "count(//ui:multidropdown/ui:option)", drop);
assertXpathEvaluatesTo("", "//ui:multidropdown/ui:option[@value='']/text()", drop);
for (int i = 0; i < options.length; i++) {
String code = drop.optionToCode(options[i]);
String option = options[i];
if (option == null || option.equals("")) {
assertXpathEvaluatesTo("", "//ui:multidropdown/ui:option[@value='" + code + "']/text()", drop);
assertXpathEvaluatesTo("true", "//ui:multidropdown/ui:option[@value='" + code + "']/@isNull", drop);
} else {
assertXpathEvaluatesTo(option, "//ui:multidropdown/ui:option[@value='" + code + "']/text()", drop);
assertXpathEvaluatesTo("", "//ui:multidropdown/ui:option[@value='" + code + "']/@isNull", drop);
}
}
}
use of com.github.bordertech.wcomponents.WMultiDropdown in project wcomponents by BorderTech.
the class WMultiDropdownRenderer_Test method testDataList.
@Test
public void testDataList() throws IOException, SAXException, XpathException {
WMultiDropdown dropdown = new WMultiDropdown(TestLookupTable.CACHEABLE_DAY_OF_WEEK_TABLE);
setActiveContext(createUIContext());
assertSchemaMatch(dropdown);
// Default first option
String code = dropdown.getCode(dropdown.getOptions().get(0), 0);
String desc = dropdown.getDesc(dropdown.getOptions().get(0), 0);
assertSchemaMatch(dropdown);
assertXpathEvaluatesTo("1", "count(//ui:multidropdown/ui:option)", dropdown);
assertXpathEvaluatesTo(desc, "//ui:multidropdown/ui:option[@value='" + code + "']/text()", dropdown);
assertXpathEvaluatesTo(dropdown.getListCacheKey(), "//ui:multidropdown/@data", dropdown);
}
use of com.github.bordertech.wcomponents.WMultiDropdown in project wcomponents by BorderTech.
the class WMultiDropdownRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
OptionGroup optionGroup = new OptionGroup(getMaliciousAttribute("ui:optgroup"), Arrays.asList(new String[] { "dummy" }));
WMultiDropdown drop = new WMultiDropdown(Arrays.asList(new Object[] { getInvalidCharSequence(), getMaliciousContent(), optionGroup }));
assertSafeContent(drop);
drop.setToolTip(getMaliciousAttribute("ui:multidropdown"));
assertSafeContent(drop);
drop.setAccessibleText(getMaliciousAttribute("ui:multidropdown"));
assertSafeContent(drop);
}
use of com.github.bordertech.wcomponents.WMultiDropdown in project wcomponents by BorderTech.
the class WMultiDropdownRenderer_Test method testRendererCorrectlyConfigured.
@Test
public void testRendererCorrectlyConfigured() {
WMultiDropdown dropdown = new WMultiDropdown(new String[] { "a", "b", "c" });
Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(dropdown) instanceof WMultiDropdownRenderer);
}
use of com.github.bordertech.wcomponents.WMultiDropdown in project wcomponents by BorderTech.
the class WMultiDropdownTestingExample method addOneSelectionExample.
/**
* Add example with one default selection.
* @param readOnly if {@code true} then make the example read-only.
*/
private void addOneSelectionExample(final boolean readOnly) {
String label = readOnly ? LABEL_RO_ONE_SELECTED : LABEL_ONE_SELECTED;
WMultiDropdown dropdown = new WMultiDropdown(DATA_LIST);
dropdown.setSelected(DATA_ONE_SELECTED);
dropdown.setReadOnly(readOnly);
layout.addField(label, dropdown);
}
Aggregations