use of com.github.bordertech.wcomponents.WMultiSelectPair in project wcomponents by BorderTech.
the class WLabelRenderer_Test method testWhatForGroup4.
@Test
public void testWhatForGroup4() throws IOException, SAXException, XpathException {
WMultiSelectPair comp = new WMultiSelectPair();
WLabel label = new WLabel("label", comp);
assertSchemaMatch(label);
assertXpathEvaluatesTo("group", "//ui:label/@what", label);
}
use of com.github.bordertech.wcomponents.WMultiSelectPair in project wcomponents by BorderTech.
the class WMultiSelectPairRenderer_Test method testOptionGroups.
@Test
public void testOptionGroups() throws IOException, SAXException, XpathException {
OptionGroup optionGroup = new OptionGroup("B", Arrays.asList(new String[] { "B.1", "B.2", "B.3", "B.4" }));
Object[] options = new Object[] { "A", optionGroup, "C" };
WMultiSelectPair select = new WMultiSelectPair(options);
assertSchemaMatch(select);
assertXpathEvaluatesTo("2", "count(//ui:multiselectpair/ui:option)", select);
assertXpathEvaluatesTo("1", "count(//ui:multiselectpair/ui:optgroup)", select);
assertXpathEvaluatesTo("4", "count(//ui:multiselectpair/ui:optgroup/ui:option)", select);
// Check grouped options
assertXpathEvaluatesTo(optionGroup.getDesc(), "//ui:multiselectpair/ui:optgroup/@label", select);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(0), "//ui:multiselectpair/ui:optgroup/ui:option[1]", select);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(1), "//ui:multiselectpair/ui:optgroup/ui:option[2]", select);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(2), "//ui:multiselectpair/ui:optgroup/ui:option[3]", select);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(3), "//ui:multiselectpair/ui:optgroup/ui:option[4]", select);
// Check values
assertXpathEvaluatesTo("1", "//ui:multiselectpair/ui:option[1]/@value", select);
assertXpathEvaluatesTo("2", "//ui:multiselectpair/ui:optgroup/ui:option[1]/@value", select);
assertXpathEvaluatesTo("3", "//ui:multiselectpair/ui:optgroup/ui:option[2]/@value", select);
assertXpathEvaluatesTo("4", "//ui:multiselectpair/ui:optgroup/ui:option[3]/@value", select);
assertXpathEvaluatesTo("5", "//ui:multiselectpair/ui:optgroup/ui:option[4]/@value", select);
assertXpathEvaluatesTo("6", "//ui:multiselectpair/ui:option[2]/@value", select);
// Check selection
select.setSelected(Arrays.asList(new String[] { "A", "B.3" }));
assertXpathEvaluatesTo("2", "count(//ui:option[@selected='true'])", select);
assertXpathExists("//ui:multiselectpair/ui:option[text()='A'][@selected='true']", select);
assertXpathExists("//ui:multiselectpair/ui:optgroup/ui:option[text()='B.3'][@selected='true']", select);
}
use of com.github.bordertech.wcomponents.WMultiSelectPair in project wcomponents by BorderTech.
the class WMultiSelectPairRenderer_Test method testReadOnlyOption.
@Test
public void testReadOnlyOption() throws IOException, SAXException, XpathException {
final String option1 = "WMultiSelectPairRenderer_Test.testDoPaint.option1";
final String option2 = "WMultiSelectPairRenderer_Test.testDoPaint.option2";
final String option3 = "WMultiSelectPairRenderer_Test.testDoPaint.option3";
// Empty list
WMultiSelectPair select = new WMultiSelectPair();
setActiveContext(createUIContext());
select.setOptions(new String[] { option1, option2, option3 });
select.setSelected(Arrays.asList(new String[] { option2 }));
assertSchemaMatch(select);
// Check Readonly - only render selected option
select.setReadOnly(true);
assertSchemaMatch(select);
assertXpathEvaluatesTo("true", "//ui:multiselectpair/@readOnly", select);
assertXpathEvaluatesTo("1", "count(//ui:multiselectpair/ui:option)", select);
assertXpathEvaluatesTo(option2, "//ui:multiselectpair/ui:option[@selected='true']", select);
}
use of com.github.bordertech.wcomponents.WMultiSelectPair in project wcomponents by BorderTech.
the class WMultiSelectPairRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
OptionGroup optionGroup = new OptionGroup(getMaliciousAttribute("ui:optgroup"), Arrays.asList(new String[] { "dummy" }));
WMultiSelectPair select = new WMultiSelectPair(Arrays.asList(new Object[] { getInvalidCharSequence(), getMaliciousContent(), optionGroup }));
select.setAvailableListName(getMaliciousAttribute("ui:multiselectpair"));
select.setSelectedListName(getMaliciousAttribute("ui:multiselectpair"));
assertSafeContent(select);
select.setToolTip(getMaliciousAttribute("ui:multiselectpair"));
assertSafeContent(select);
select.setAccessibleText(getMaliciousAttribute("ui:multiselectpair"));
assertSafeContent(select);
}
use of com.github.bordertech.wcomponents.WMultiSelectPair in project wcomponents by BorderTech.
the class WMultiSelectPairRenderer_Test method testOptionGroupsWithShuffle.
@Test
public void testOptionGroupsWithShuffle() throws IOException, SAXException, XpathException {
OptionGroup optionGroup = new OptionGroup("B", Arrays.asList(new String[] { "B.1", "B.2", "B.3", "B.4" }));
Object[] options = new Object[] { "A", optionGroup, "C" };
WMultiSelectPair select = new WMultiSelectPair(options);
select.setShuffle(true);
assertSchemaMatch(select);
assertXpathEvaluatesTo("2", "count(//ui:multiselectpair/ui:option)", select);
assertXpathEvaluatesTo("1", "count(//ui:multiselectpair/ui:optgroup)", select);
assertXpathEvaluatesTo("4", "count(//ui:multiselectpair/ui:optgroup/ui:option)", select);
// Check grouped options
assertXpathEvaluatesTo(optionGroup.getDesc(), "//ui:multiselectpair/ui:optgroup/@label", select);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(0), "//ui:multiselectpair/ui:optgroup/ui:option[1]", select);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(1), "//ui:multiselectpair/ui:optgroup/ui:option[2]", select);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(2), "//ui:multiselectpair/ui:optgroup/ui:option[3]", select);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(3), "//ui:multiselectpair/ui:optgroup/ui:option[4]", select);
// Check values
assertXpathEvaluatesTo("1", "//ui:multiselectpair/ui:option[1]/@value", select);
assertXpathEvaluatesTo("2", "//ui:multiselectpair/ui:optgroup/ui:option[1]/@value", select);
assertXpathEvaluatesTo("3", "//ui:multiselectpair/ui:optgroup/ui:option[2]/@value", select);
assertXpathEvaluatesTo("4", "//ui:multiselectpair/ui:optgroup/ui:option[3]/@value", select);
assertXpathEvaluatesTo("5", "//ui:multiselectpair/ui:optgroup/ui:option[4]/@value", select);
assertXpathEvaluatesTo("6", "//ui:multiselectpair/ui:option[2]/@value", select);
// Check selection order
select.setSelected(Arrays.asList(new String[] { "A", "B.3", "B.1" }));
assertXpathEvaluatesTo("3", "count(//ui:option[@selected='true'])", select);
assertXpathExists("//ui:multiselectpair/ui:option[text()='A'][@selected='true']", select);
assertXpathExists("//ui:multiselectpair/ui:optgroup/ui:option[text()='B.3'][@selected='true']", select);
assertXpathExists("//ui:multiselectpair/ui:optgroup/ui:option[text()='B.1'][@selected='true']", select);
assertXpathEvaluatesTo("A", "//ui:multiselectpair/ui:option[@selected='true']/text()", select);
assertXpathEvaluatesTo("B.3", "//ui:multiselectpair/ui:optgroup[1]/ui:option[@selected='true'][1]/text()", select);
assertXpathEvaluatesTo("B.1", "//ui:multiselectpair/ui:optgroup[1]/ui:option[@selected='true'][2]/text()", select);
}
Aggregations