Search in sources :

Example 16 with WDropdown

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);
}
Also used : WDropdown(com.github.bordertech.wcomponents.WDropdown) Test(org.junit.Test)

Example 17 with WDropdown

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);
}
Also used : WDropdown(com.github.bordertech.wcomponents.WDropdown) Test(org.junit.Test)

Example 18 with WDropdown

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);
}
Also used : WDropdown(com.github.bordertech.wcomponents.WDropdown) Test(org.junit.Test)

Example 19 with WDropdown

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);
}
Also used : WDropdown(com.github.bordertech.wcomponents.WDropdown) Test(org.junit.Test)

Example 20 with WDropdown

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"));
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) WDropdown(com.github.bordertech.wcomponents.WDropdown) UIContext(com.github.bordertech.wcomponents.UIContext) Test(org.junit.Test)

Aggregations

WDropdown (com.github.bordertech.wcomponents.WDropdown)33 Test (org.junit.Test)28 WTextField (com.github.bordertech.wcomponents.WTextField)12 WTextArea (com.github.bordertech.wcomponents.WTextArea)10 UIContext (com.github.bordertech.wcomponents.UIContext)7 WMultiSelect (com.github.bordertech.wcomponents.WMultiSelect)6 SeleniumWComponentsWebDriver (com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver)6 OptionGroup (com.github.bordertech.wcomponents.OptionGroup)3 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)3 SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)2 WComponent (com.github.bordertech.wcomponents.WComponent)2 WFieldSet (com.github.bordertech.wcomponents.WFieldSet)2 Equal (com.github.bordertech.wcomponents.subordinate.Equal)2 Hide (com.github.bordertech.wcomponents.subordinate.Hide)2 Rule (com.github.bordertech.wcomponents.subordinate.Rule)2 WSubordinateControl (com.github.bordertech.wcomponents.subordinate.WSubordinateControl)2 Action (com.github.bordertech.wcomponents.Action)1 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)1 RadioButtonGroup (com.github.bordertech.wcomponents.RadioButtonGroup)1 TestLookupTable (com.github.bordertech.wcomponents.TestLookupTable)1