use of com.github.bordertech.wcomponents.OptionGroup in project wcomponents by BorderTech.
the class WMultiSelectRenderer_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" };
WMultiSelect multi = new WMultiSelect(options);
assertSchemaMatch(multi);
assertXpathEvaluatesTo("2", "count(//ui:listbox/ui:option)", multi);
assertXpathEvaluatesTo("1", "count(//ui:listbox/ui:optgroup)", multi);
assertXpathEvaluatesTo("4", "count(//ui:listbox/ui:optgroup/ui:option)", multi);
// Check grouped options
assertXpathEvaluatesTo(optionGroup.getDesc(), "//ui:listbox/ui:optgroup/@label", multi);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(0), "//ui:listbox/ui:optgroup/ui:option[1]", multi);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(1), "//ui:listbox/ui:optgroup/ui:option[2]", multi);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(2), "//ui:listbox/ui:optgroup/ui:option[3]", multi);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(3), "//ui:listbox/ui:optgroup/ui:option[4]", multi);
// Check values
assertXpathEvaluatesTo("1", "//ui:listbox/ui:option[1]/@value", multi);
assertXpathEvaluatesTo("2", "//ui:listbox/ui:optgroup/ui:option[1]/@value", multi);
assertXpathEvaluatesTo("3", "//ui:listbox/ui:optgroup/ui:option[2]/@value", multi);
assertXpathEvaluatesTo("4", "//ui:listbox/ui:optgroup/ui:option[3]/@value", multi);
assertXpathEvaluatesTo("5", "//ui:listbox/ui:optgroup/ui:option[4]/@value", multi);
assertXpathEvaluatesTo("6", "//ui:listbox/ui:option[2]/@value", multi);
// Check selection
multi.setSelected(Arrays.asList(new String[] { "A", "B.3" }));
assertXpathEvaluatesTo("2", "count(//ui:option[@selected='true'])", multi);
assertXpathExists("//ui:listbox/ui:option[text()='A'][@selected='true']", multi);
assertXpathExists("//ui:listbox/ui:optgroup/ui:option[text()='B.3'][@selected='true']", multi);
}
use of com.github.bordertech.wcomponents.OptionGroup in project wcomponents by BorderTech.
the class WSingleSelectRenderer_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" };
WSingleSelect single = new WSingleSelect(options);
assertSchemaMatch(single);
assertXpathEvaluatesTo("2", "count(//ui:listbox/ui:option)", single);
assertXpathEvaluatesTo("1", "count(//ui:listbox/ui:optgroup)", single);
assertXpathEvaluatesTo("4", "count(//ui:listbox/ui:optgroup/ui:option)", single);
// Check grouped options
assertXpathEvaluatesTo(optionGroup.getDesc(), "//ui:listbox/ui:optgroup/@label", single);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(0), "//ui:listbox/ui:optgroup/ui:option[1]", single);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(1), "//ui:listbox/ui:optgroup/ui:option[2]", single);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(2), "//ui:listbox/ui:optgroup/ui:option[3]", single);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(3), "//ui:listbox/ui:optgroup/ui:option[4]", single);
// Check values
assertXpathEvaluatesTo("1", "//ui:listbox/ui:option[1]/@value", single);
assertXpathEvaluatesTo("2", "//ui:listbox/ui:optgroup/ui:option[1]/@value", single);
assertXpathEvaluatesTo("3", "//ui:listbox/ui:optgroup/ui:option[2]/@value", single);
assertXpathEvaluatesTo("4", "//ui:listbox/ui:optgroup/ui:option[3]/@value", single);
assertXpathEvaluatesTo("5", "//ui:listbox/ui:optgroup/ui:option[4]/@value", single);
assertXpathEvaluatesTo("6", "//ui:listbox/ui:option[2]/@value", single);
// Check selection
single.setSelected("A");
assertXpathEvaluatesTo("1", "count(//ui:option[@selected='true'])", single);
assertXpathExists("//ui:listbox/ui:option[text()='A'][@selected='true']", single);
single.setSelected("B.3");
assertXpathEvaluatesTo("1", "count(//ui:option[@selected='true'])", single);
assertXpathExists("//ui:listbox/ui:optgroup/ui:option[text()='B.3'][@selected='true']", single);
}
use of com.github.bordertech.wcomponents.OptionGroup in project wcomponents by BorderTech.
the class WDropdownRenderer_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" };
WDropdown drop = new WDropdown(options);
assertSchemaMatch(drop);
assertXpathEvaluatesTo("2", "count(//ui:dropdown/ui:option)", drop);
assertXpathEvaluatesTo("1", "count(//ui:dropdown/ui:optgroup)", drop);
assertXpathEvaluatesTo("4", "count(//ui:dropdown/ui:optgroup/ui:option)", drop);
// Check grouped options
assertXpathEvaluatesTo(optionGroup.getDesc(), "//ui:dropdown/ui:optgroup/@label", drop);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(0), "//ui:dropdown/ui:optgroup/ui:option[1]", drop);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(1), "//ui:dropdown/ui:optgroup/ui:option[2]", drop);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(2), "//ui:dropdown/ui:optgroup/ui:option[3]", drop);
assertXpathEvaluatesTo((String) optionGroup.getOptions().get(3), "//ui:dropdown/ui:optgroup/ui:option[4]", drop);
// Check values
assertXpathEvaluatesTo("1", "//ui:dropdown/ui:option[1]/@value", drop);
assertXpathEvaluatesTo("2", "//ui:dropdown/ui:optgroup/ui:option[1]/@value", drop);
assertXpathEvaluatesTo("3", "//ui:dropdown/ui:optgroup/ui:option[2]/@value", drop);
assertXpathEvaluatesTo("4", "//ui:dropdown/ui:optgroup/ui:option[3]/@value", drop);
assertXpathEvaluatesTo("5", "//ui:dropdown/ui:optgroup/ui:option[4]/@value", drop);
assertXpathEvaluatesTo("6", "//ui:dropdown/ui:option[2]/@value", drop);
// Check selection
drop.setSelected("B.3");
assertXpathEvaluatesTo("1", "count(//ui:option[@selected='true'])", drop);
assertXpathExists("//ui:dropdown/ui:optgroup/ui:option[text()='B.3'][@selected='true']", drop);
}
Aggregations