use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.
the class WDropdownRenderer_Test method testEditableComboOption.
@Test
public void testEditableComboOption() throws IOException, SAXException, XpathException {
String[] options = new String[] { "A", "B", "C" };
WDropdown drop = new WDropdown(options);
drop.setType(WDropdown.DropdownType.COMBO);
assertSchemaMatch(drop);
assertXpathEvaluatesTo("3", "count(//ui:dropdown/ui:option)", drop);
assertXpathEvaluatesTo("1", "count(//ui:option[@selected='true'])", drop);
assertXpathExists("//ui:dropdown/ui:option[text()='A'][@selected='true']", drop);
// Set a new selection which is not in the list.
drop.setSelected("D");
assertSchemaMatch(drop);
assertXpathEvaluatesTo("4", "count(//ui:dropdown/ui:option)", drop);
assertXpathEvaluatesTo("1", "count(//ui:option[@selected='true'])", drop);
assertXpathExists("//ui:dropdown/ui:option[text()='D'][@selected='true']", drop);
}
use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.
the class WDropdownRenderer_Test method testDoPaintOptions.
@Test
public void testDoPaintOptions() throws IOException, SAXException, XpathException {
WDropdown drop = new WDropdown(TestLookupTable.CACHEABLE_DAY_OF_WEEK_TABLE);
assertSchemaMatch(drop);
assertXpathEvaluatesTo(drop.getId(), "//ui:dropdown/@id", drop);
assertXpathEvaluatesTo(drop.getListCacheKey(), "//ui:dropdown/@data", drop);
assertXpathNotExists("//ui:dropdown/@disabled", drop);
assertXpathNotExists("//ui:dropdown/@hidden", drop);
assertXpathNotExists("//ui:dropdown/@required", drop);
assertXpathNotExists("//ui:dropdown/@readOnly", drop);
assertXpathNotExists("//ui:dropdown/@submitOnChange", drop);
assertXpathNotExists("//ui:dropdown/@toolTip", drop);
assertXpathNotExists("//ui:dropdown/@accessibleText", drop);
assertXpathNotExists("//ui:dropdown/@optionWidth", drop);
assertXpathNotExists("//ui:dropdown/@type", drop);
drop.setDisabled(true);
assertSchemaMatch(drop);
assertXpathEvaluatesTo("true", "//ui:dropdown/@disabled", drop);
setFlag(drop, ComponentModel.HIDE_FLAG, true);
assertSchemaMatch(drop);
assertXpathEvaluatesTo("true", "//ui:dropdown/@hidden", drop);
drop.setMandatory(true);
assertSchemaMatch(drop);
assertXpathEvaluatesTo("true", "//ui:dropdown/@required", drop);
drop.setSubmitOnChange(true);
assertSchemaMatch(drop);
assertXpathEvaluatesTo("true", "//ui:dropdown/@submitOnChange", drop);
drop.setToolTip("tooltip");
assertSchemaMatch(drop);
assertXpathEvaluatesTo(drop.getToolTip(), "//ui:dropdown/@toolTip", drop);
drop.setAccessibleText("accessible");
assertSchemaMatch(drop);
assertXpathEvaluatesTo(drop.getAccessibleText(), "//ui:dropdown/@accessibleText", drop);
drop.setOptionWidth(20);
assertSchemaMatch(drop);
assertXpathEvaluatesTo("20", "//ui:dropdown/@optionWidth", drop);
drop.setType(DropdownType.COMBO);
assertSchemaMatch(drop);
assertXpathEvaluatesTo("combo", "//ui:dropdown/@type", drop);
}
use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.
the class WDropdownRenderer_Test method testDoPaintReadOnly.
@Test
public void testDoPaintReadOnly() throws IOException, SAXException, XpathException {
// Shared options.
WDropdown drop = new WDropdown();
drop.setOptions(new String[] { "A", "B", "C" });
setActiveContext(createUIContext());
// Check Readonly - only render selected option
drop.setReadOnly(true);
drop.setSelected("B");
assertSchemaMatch(drop);
assertXpathEvaluatesTo("true", "//ui:dropdown/@readOnly", drop);
assertXpathEvaluatesTo("1", "count(//ui:dropdown/ui:option)", drop);
assertXpathEvaluatesTo("1", "count(//ui:dropdown/ui:option[@selected='true'])", drop);
assertXpathEvaluatesTo("B", "//ui:dropdown/ui:option[@selected='true']", drop);
}
use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.
the class WDropdownRenderer_Test method testSpecialCharacters.
@Test
public void testSpecialCharacters() throws IOException, SAXException, XpathException {
String optionA = "<A";
String optionB = "B&B";
String optionC = "C";
WDropdown drop = new WDropdown(new String[] { optionA, optionB, optionC });
assertSchemaMatch(drop);
assertXpathEvaluatesTo("3", "count(//ui:dropdown/ui:option)", drop);
}
use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.
the class AutoReFocusExample_Test method testRefocusWDropdown.
@Test
public void testRefocusWDropdown() {
SeleniumWComponentsWebDriver driver = getDriver();
String path = "WDropdownSubmitOnChangeExample/WDropdown[0]";
driver.findWDropdown(byWComponentPath(path)).click();
UIContext uic = getUserContextForSession();
UIContextHolder.pushContext(uic);
try {
// The dropdowns in the example need something to be selected to trigger the submit
WComponent comp = TreeUtil.findWComponent(getUi(), path.split("/")).getComponent();
if (comp instanceof WDropdown) {
WDropdown dropdown = (WDropdown) comp;
driver.findElement(byWComponentPath(path, dropdown.getOptions().get(1))).click();
}
} finally {
UIContextHolder.popContext();
}
Assert.assertEquals("Incorrect focus", driver.findWDropdown(byWComponentPath(path)).getActiveId(), driver.switchTo(true).activeElement().getAttribute("id"));
}
Aggregations