Search in sources :

Example 51 with WTextField

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

the class WTextFieldRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    WTextField textField = new WTextField();
    textField.setText(getMaliciousContent());
    assertSafeContent(textField);
    textField.setToolTip(getMaliciousAttribute("ui:textfield"));
    assertSafeContent(textField);
    textField.setAccessibleText(getMaliciousAttribute("ui:textfield"));
    assertSafeContent(textField);
}
Also used : WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 52 with WTextField

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

the class WButtonRenderer_Test method testAllOptions.

@Test
public void testAllOptions() throws IOException, SAXException, XpathException {
    WButton button = new WButton("All");
    button.setDisabled(true);
    setFlag(button, ComponentModel.HIDE_FLAG, true);
    button.setToolTip("Title");
    button.setAccessKey('T');
    button.setImageUrl("http://localhost/image.png");
    button.setImagePosition(ImagePosition.EAST);
    button.setRenderAsLink(true);
    button.setAjaxTarget(new WTextField());
    button.setPopupTrigger(true);
    setActiveContext(createUIContext());
    WPanel validationComponent = new WPanel();
    button.setAction(new ValidatingAction(new WValidationErrors(), validationComponent) {

        @Override
        public void executeOnValid(final ActionEvent event) {
        // Do nothing
        }
    });
    WContainer root = new WContainer();
    root.add(button);
    root.add(validationComponent);
    assertXpathExists("//html:button[@id]", button);
    assertXpathExists("//html:button[contains(@class, 'wc-linkbutton')]", button);
    assertXpathEvaluatesTo(button.getText(), "//html:button", button);
    assertXpathEvaluatesTo("disabled", "//html:button/@disabled", button);
    assertXpathEvaluatesTo("hidden", "//html:button/@hidden", button);
    assertXpathEvaluatesTo(button.getToolTip(), "//html:button/@title", button);
    assertXpathUrlEvaluatesTo(button.getImageUrl(), "//html:button//html:img/@src", button);
    assertXpathExists("//html:button/html:span[contains(@class, 'wc_btn_imge')]", button);
    assertXpathEvaluatesTo(button.getAccessKeyAsString(), "//html:button/@accesskey", button);
    assertXpathEvaluatesTo("true", "//html:button/@aria-haspopup", button);
    assertXpathEvaluatesTo(validationComponent.getId(), "//html:button/@data-wc-validate", button);
    assertXpathEvaluatesTo(button.getId(), "//ui:ajaxtrigger/@triggerId", button);
    button.setImagePosition(ImagePosition.NORTH);
    assertXpathExists("//html:button/html:span[contains(@class, 'wc_btn_imgn')]", button);
    button.setImagePosition(ImagePosition.SOUTH);
    assertXpathExists("//html:button/html:span[contains(@class, 'wc_btn_imgs')]", button);
    button.setImagePosition(ImagePosition.WEST);
    assertXpathExists("//html:button/html:span[contains(@class, 'wc_btn_imgw')]", button);
    button.setClientCommandOnly(true);
    assertXpathEvaluatesTo("button", "//html:button/@type", button);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) ValidatingAction(com.github.bordertech.wcomponents.validation.ValidatingAction) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WPanel(com.github.bordertech.wcomponents.WPanel) WValidationErrors(com.github.bordertech.wcomponents.validation.WValidationErrors) WButton(com.github.bordertech.wcomponents.WButton) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 53 with WTextField

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

the class WComponentGroupRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    // Setup Group
    WComponent actionTarget1 = new WTextField();
    WComponent actionTarget2 = new WTextField();
    WComponent actionTarget3 = new WTextField();
    WComponentGroup<WComponent> group = new WComponentGroup<>();
    group.addToGroup(actionTarget1);
    group.addToGroup(actionTarget2);
    group.addToGroup(actionTarget3);
    WContainer root = new WContainer();
    root.add(actionTarget1);
    root.add(actionTarget2);
    root.add(actionTarget3);
    root.add(group);
    setActiveContext(createUIContext());
    // Validate Schema
    assertSchemaMatch(root);
    // Check group
    assertXpathEvaluatesTo("1", "count(//ui:componentGroup)", root);
    assertXpathEvaluatesTo("3", "count(//ui:componentGroup/ui:component)", root);
    assertXpathEvaluatesTo(group.getId(), "//ui:componentGroup/@id", root);
    assertXpathEvaluatesTo(actionTarget1.getId(), "//ui:componentGroup/ui:component[position()=1]/@id", root);
    assertXpathEvaluatesTo(actionTarget2.getId(), "//ui:componentGroup/ui:component[position()=2]/@id", root);
    assertXpathEvaluatesTo(actionTarget3.getId(), "//ui:componentGroup/ui:component[position()=3]/@id", root);
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) WContainer(com.github.bordertech.wcomponents.WContainer) WComponentGroup(com.github.bordertech.wcomponents.WComponentGroup) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 54 with WTextField

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

the class WFieldSetRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    final String title = "WFieldSetRenderer_Test.testDoPaint.title";
    WTextField text = new WTextField();
    WFieldSet fieldSet = new WFieldSet(title);
    fieldSet.add(text);
    text.setText("text1");
    assertSchemaMatch(fieldSet);
    // Check Attributes
    assertXpathEvaluatesTo(fieldSet.getId(), "//ui:fieldset/@id", fieldSet);
    assertXpathNotExists("//ui:fieldset/@frame", fieldSet);
    // Check Input
    assertXpathEvaluatesTo(text.getText(), "//ui:fieldset/ui:content/ui:textfield", fieldSet);
    fieldSet.setFrameType(FrameType.NO_BORDER);
    assertXpathEvaluatesTo("noborder", "//ui:fieldset/@frame", fieldSet);
    fieldSet.setFrameType(FrameType.NO_TEXT);
    assertXpathEvaluatesTo("notext", "//ui:fieldset/@frame", fieldSet);
    fieldSet.setFrameType(FrameType.NONE);
    assertXpathEvaluatesTo("none", "//ui:fieldset/@frame", fieldSet);
}
Also used : WFieldSet(com.github.bordertech.wcomponents.WFieldSet) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 55 with WTextField

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

the class WFieldWarningIndicatorRenderer_Test method testRendererCorrectlyConfigured.

/**
 * Test the Layout is correctly configured.
 */
@Test
public void testRendererCorrectlyConfigured() {
    WFieldWarningIndicator indicator = new WFieldWarningIndicator(new WTextField());
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(indicator) instanceof WFieldWarningIndicatorRenderer);
}
Also used : WTextField(com.github.bordertech.wcomponents.WTextField) WFieldWarningIndicator(com.github.bordertech.wcomponents.validation.WFieldWarningIndicator) Test(org.junit.Test)

Aggregations

WTextField (com.github.bordertech.wcomponents.WTextField)117 Test (org.junit.Test)90 SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)21 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)21 WContainer (com.github.bordertech.wcomponents.WContainer)21 Equal (com.github.bordertech.wcomponents.subordinate.Equal)16 GreaterThanOrEqual (com.github.bordertech.wcomponents.subordinate.GreaterThanOrEqual)15 LessThanOrEqual (com.github.bordertech.wcomponents.subordinate.LessThanOrEqual)15 NotEqual (com.github.bordertech.wcomponents.subordinate.NotEqual)15 Rule (com.github.bordertech.wcomponents.subordinate.Rule)15 WSubordinateControl (com.github.bordertech.wcomponents.subordinate.WSubordinateControl)15 SubordinateTrigger (com.github.bordertech.wcomponents.SubordinateTrigger)14 WTextArea (com.github.bordertech.wcomponents.WTextArea)14 WComponentGroup (com.github.bordertech.wcomponents.WComponentGroup)12 WDropdown (com.github.bordertech.wcomponents.WDropdown)12 WButton (com.github.bordertech.wcomponents.WButton)11 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)11 WHeading (com.github.bordertech.wcomponents.WHeading)10 WLabel (com.github.bordertech.wcomponents.WLabel)10 Hide (com.github.bordertech.wcomponents.subordinate.Hide)10