Search in sources :

Example 11 with WDropdown

use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.

the class WDropdownRenderer_Test method testDataList.

@Test
public void testDataList() throws IOException, SAXException, XpathException {
    WDropdown drop = new WDropdown(TestLookupTable.CACHEABLE_DAY_OF_WEEK_TABLE);
    assertSchemaMatch(drop);
    String code = drop.getCode(drop.getOptions().get(0), 0);
    String desc = drop.getDesc(drop.getOptions().get(0), 0);
    assertXpathEvaluatesTo("1", "count(//ui:dropdown/ui:option)", drop);
    assertXpathEvaluatesTo(desc, "//ui:dropdown/ui:option[@value='" + code + "']/text()", drop);
    assertXpathEvaluatesTo(drop.getListCacheKey(), "//ui:dropdown/@data", drop);
}
Also used : WDropdown(com.github.bordertech.wcomponents.WDropdown) Test(org.junit.Test)

Example 12 with WDropdown

use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.

the class WDropdownRenderer_Test method testRendererCorrectlyConfigured.

@Test
public void testRendererCorrectlyConfigured() {
    WDropdown component = new WDropdown();
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(component) instanceof WDropdownRenderer);
}
Also used : WDropdown(com.github.bordertech.wcomponents.WDropdown) Test(org.junit.Test)

Example 13 with WDropdown

use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.

the class WDropdownRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    OptionGroup optionGroup = new OptionGroup(getMaliciousAttribute("ui:optgroup"), Arrays.asList(new String[] { "dummy" }));
    WDropdown drop = new WDropdown(Arrays.asList(new Object[] { getInvalidCharSequence(), getMaliciousContent(), optionGroup }));
    assertSafeContent(drop);
    drop.setToolTip(getMaliciousAttribute("ui:dropdown"));
    assertSafeContent(drop);
    drop.setAccessibleText(getMaliciousAttribute("ui:dropdown"));
    assertSafeContent(drop);
}
Also used : OptionGroup(com.github.bordertech.wcomponents.OptionGroup) WDropdown(com.github.bordertech.wcomponents.WDropdown) Test(org.junit.Test)

Example 14 with WDropdown

use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.

the class WDropdownRenderer_Test method testNullOption.

@Test
public void testNullOption() throws IOException, SAXException, XpathException {
    String[] options = new String[] { null, "A", "B", "C" };
    WDropdown drop = new WDropdown(options);
    assertSchemaMatch(drop);
    assertXpathEvaluatesTo("4", "count(//ui:dropdown/ui:option)", drop);
    assertXpathEvaluatesTo("", "//ui:dropdown/ui:option[@value='']/text()", drop);
    for (int i = 0; i < options.length; i++) {
        String code = drop.optionToCode(options[i]);
        String option;
        if (i == 0) {
            // null
            option = "";
        } else {
            option = options[i];
        }
        assertXpathEvaluatesTo(option, "//ui:dropdown/ui:option[@value='" + code + "']/text()", drop);
    }
}
Also used : WDropdown(com.github.bordertech.wcomponents.WDropdown) Test(org.junit.Test)

Example 15 with WDropdown

use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.

the class WDropdownRenderer_Test method testIsNullOption.

@Test
public void testIsNullOption() throws IOException, SAXException, XpathException {
    String[] options = new String[] { null, "", "A", "B", "C" };
    WDropdown drop = new WDropdown(options);
    assertSchemaMatch(drop);
    assertXpathEvaluatesTo("5", "count(//ui:dropdown/ui:option)", drop);
    assertXpathEvaluatesTo("", "//ui:dropdown/ui:option[@value='']/text()", drop);
    for (int i = 0; i < options.length; i++) {
        String code = drop.optionToCode(options[i]);
        String option = options[i];
        if (option == null || option.equals("")) {
            assertXpathEvaluatesTo("", "//ui:dropdown/ui:option[@value='" + code + "']/text()", drop);
            assertXpathEvaluatesTo("true", "//ui:dropdown/ui:option[@value='" + code + "']/@isNull", drop);
        } else {
            assertXpathEvaluatesTo(option, "//ui:dropdown/ui:option[@value='" + code + "']/text()", drop);
            assertXpathEvaluatesTo("", "//ui:dropdown/ui:option[@value='" + code + "']/@isNull", drop);
        }
    }
}
Also used : WDropdown(com.github.bordertech.wcomponents.WDropdown) 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