use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.
the class WDropdownRenderer_Test method testCrtEntryExpiration.
@Test
public void testCrtEntryExpiration() throws IOException, SAXException, XpathException {
UIContext uic1 = new UIContextImpl();
UIContext uic2 = new UIContextImpl() {
@Override
public long getCreationTime() {
// 01 jan 1970 - should have no options
return 0;
}
};
// Test getOptions accessor
WDropdown drop = new WDropdown(TestLookupTable.YesNoTable.class);
// Test rendered format
setActiveContext(uic1);
assertSchemaMatch(drop);
assertXpathEvaluatesTo("2", "count(//ui:dropdown/ui:option)", drop);
setActiveContext(uic2);
assertSchemaMatch(drop);
assertXpathEvaluatesTo("0", "count(//ui:dropdown/ui:option)", drop);
}
use of com.github.bordertech.wcomponents.WDropdown 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);
}
use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.
the class WDropdownRenderer_Test method testDoPaint.
@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
// Shared options.
WDropdown drop = new WDropdown();
drop.setLocked(true);
assertSchemaMatch(drop);
assertXpathEvaluatesTo("0", "count(//ui:dropdown/ui:option)", drop);
drop.setOptions(new String[] { "A", "B", "C" });
assertSchemaMatch(drop);
assertXpathEvaluatesTo("3", "count(//ui:dropdown/ui:option)", drop);
drop.setSubmitOnChange(true);
assertSchemaMatch(drop);
// User specific options.
drop.setLocked(true);
setActiveContext(createUIContext());
resetContext();
drop = new WDropdown(new String[] { "A", "B" });
assertXpathEvaluatesTo("2", "count(//ui:dropdown/ui:option)", drop);
assertXpathEvaluatesTo(drop.getId(), "//ui:dropdown/@id", drop);
assertXpathExists("//ui:dropdown[ui:option='A']", drop);
assertXpathExists("//ui:dropdown[ui:option='B']", drop);
Assert.assertTrue("Dropdown should be in default state", drop.isDefaultState());
setActiveContext(createUIContext());
drop.setOptions(new String[] { "X" });
assertXpathEvaluatesTo("1", "count(//ui:dropdown/ui:option)", drop);
assertXpathExists("//ui:dropdown[ui:option='X']", drop);
}
Aggregations