Search in sources :

Example 41 with WButton

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

the class WPartialDateFieldRenderer_Test method testDoPaintOptionals.

@Test
public void testDoPaintOptionals() throws IOException, SAXException, XpathException {
    WPartialDateField dateField = new WPartialDateField();
    // Optional attributes
    dateField.setDisabled(true);
    setFlag(dateField, ComponentModel.HIDE_FLAG, true);
    dateField.setMandatory(true);
    dateField.setToolTip(TEST_TITLE);
    dateField.setAccessibleText(TEST_ALT_TEXT);
    dateField.setDefaultSubmitButton(new WButton(TEST_BUTTON_ID));
    assertSchemaMatch(dateField);
    // Defaults
    assertXpathExists("//ui:datefield", dateField);
    assertXpathEvaluatesTo(dateField.getId(), "//ui:datefield/@id", dateField);
    assertXpathEvaluatesTo("true", "//ui:datefield/@allowPartial", dateField);
    // Optionals
    assertXpathEvaluatesTo("true", "//ui:datefield/@disabled", dateField);
    assertXpathEvaluatesTo("true", "//ui:datefield/@hidden", dateField);
    assertXpathEvaluatesTo("true", "//ui:datefield/@required", dateField);
    assertXpathEvaluatesTo(TEST_TITLE, "//ui:datefield/@toolTip", dateField);
    assertXpathEvaluatesTo(TEST_ALT_TEXT, "//ui:datefield/@accessibleText", dateField);
    assertXpathEvaluatesTo(String.valueOf(dateField.getDefaultSubmitButton().getId()), "//ui:datefield/@buttonId", dateField);
    // Actual date value not set
    assertXpathEvaluatesTo("", "//ui:datefield", dateField);
}
Also used : WButton(com.github.bordertech.wcomponents.WButton) WPartialDateField(com.github.bordertech.wcomponents.WPartialDateField) Test(org.junit.Test)

Example 42 with WButton

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

the class WPasswordFieldRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    WPasswordField field = new WPasswordField();
    WButton button = new WButton();
    WContainer root = new WContainer();
    root.add(field);
    root.add(button);
    assertSchemaMatch(field);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getId(), "//ui:passwordfield/@id", field);
    assertXpathNotExists("//ui:passwordfield/@disabled", field);
    assertXpathNotExists("//ui:passwordfield/@hidden", field);
    assertXpathNotExists("//ui:passwordfield/@required", field);
    assertXpathNotExists("//ui:passwordfield/@readOnly", field);
    assertXpathNotExists("//ui:passwordfield/@minLength", field);
    assertXpathNotExists("//ui:passwordfield/@maxLength", field);
    assertXpathNotExists("//ui:passwordfield/@toolTip", field);
    assertXpathNotExists("//ui:passwordfield/@accessibleText", field);
    assertXpathNotExists("//ui:passwordfield/@size", field);
    assertXpathNotExists("//ui:passwordfield/@buttonId", field);
    field.setDisabled(true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:passwordfield/@disabled", field);
    setFlag(field, ComponentModel.HIDE_FLAG, true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:passwordfield/@hidden", field);
    field.setMandatory(true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:passwordfield/@required", field);
    field.setMinLength(45);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("45", "//ui:passwordfield/@minLength", field);
    field.setMaxLength(50);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("50", "//ui:passwordfield/@maxLength", field);
    field.setToolTip("tooltip");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getToolTip(), "//ui:passwordfield/@toolTip", field);
    field.setAccessibleText("accessible");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getAccessibleText(), "//ui:passwordfield/@accessibleText", field);
    field.setColumns(40);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("40", "//ui:passwordfield/@size", field);
    field.setDefaultSubmitButton(button);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(button.getId(), "//ui:passwordfield/@buttonId", field);
    field.setText("Hello");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("", "normalize-space(//ui:passwordfield)", field);
    field.setPlaceholder("enter stuff here");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("enter stuff here", "//ui:passwordfield/@placeholder", field);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) WPasswordField(com.github.bordertech.wcomponents.WPasswordField) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 43 with WButton

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

the class WPhoneNumberFieldRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    WPhoneNumberField field = new WPhoneNumberField();
    WButton button = new WButton();
    WSuggestions suggestions = new WSuggestions();
    WContainer root = new WContainer();
    root.add(field);
    root.add(button);
    root.add(suggestions);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getId(), "//ui:phonenumberfield/@id", field);
    assertXpathNotExists("//ui:phonenumberfield/@disabled", field);
    assertXpathNotExists("//ui:phonenumberfield/@hidden", field);
    assertXpathNotExists("//ui:phonenumberfield/@required", field);
    assertXpathNotExists("//ui:phonenumberfield/@readOnly", field);
    assertXpathNotExists("//ui:phonenumberfield/@minLength", field);
    assertXpathNotExists("//ui:phonenumberfield/@maxLength", field);
    assertXpathNotExists("//ui:phonenumberfield/@toolTip", field);
    assertXpathNotExists("//ui:phonenumberfield/@accessibleText", field);
    assertXpathNotExists("//ui:phonenumberfield/@size", field);
    assertXpathNotExists("//ui:phonenumberfield/@buttonId", field);
    assertXpathNotExists("//ui:phonenumberfield/@pattern", field);
    assertXpathNotExists("//ui:phonenumberfield/@list", field);
    field.setDisabled(true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:phonenumberfield/@disabled", field);
    setFlag(field, ComponentModel.HIDE_FLAG, true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:phonenumberfield/@hidden", field);
    field.setMandatory(true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:phonenumberfield/@required", field);
    field.setMinLength(45);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("45", "//ui:phonenumberfield/@minLength", field);
    field.setMaxLength(50);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("50", "//ui:phonenumberfield/@maxLength", field);
    field.setToolTip("tooltip");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getToolTip(), "//ui:phonenumberfield/@toolTip", field);
    field.setAccessibleText("accessible");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getAccessibleText(), "//ui:phonenumberfield/@accessibleText", field);
    field.setColumns(40);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("40", "//ui:phonenumberfield/@size", field);
    field.setDefaultSubmitButton(button);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(button.getId(), "//ui:phonenumberfield/@buttonId", field);
    field.setPattern("");
    assertSchemaMatch(field);
    assertXpathNotExists("//ui:phonenumberfield/@pattern", field);
    field.setPattern("test[123]");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getPattern(), "//ui:phonenumberfield/@pattern", field);
    field.setText("(12) 3456 7890");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getText(), "normalize-space(//ui:phonenumberfield)", field);
    field.setSuggestions(suggestions);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(suggestions.getId(), "//ui:phonenumberfield/@list", field);
    field.setPlaceholder("enter stuff here");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("enter stuff here", "//ui:phonenumberfield/@placeholder", field);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) WPhoneNumberField(com.github.bordertech.wcomponents.WPhoneNumberField) WSuggestions(com.github.bordertech.wcomponents.WSuggestions) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 44 with WButton

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

the class ExampleSeleniumTest method testDuplicatorWithGettersWComponentImpl.

/**
 * This test implementation uses ByWComponent to find the HTML controls.
 * This is the easiest approach to use, but requires that the UI being
 * tested has been built with getters for every control, which is not
 * usually practical.
 */
@Test
public void testDuplicatorWithGettersWComponentImpl() {
    // Launch the web browser to the LDE
    WebDriver driver = getDriver();
    // UI components
    WTextField textField = ui.getTextDuplicatorWithGetters().getTextField();
    WButton duplicateButton = ui.getTextDuplicatorWithGetters().getDuplicateButton();
    WButton clearButton = ui.getTextDuplicatorWithGetters().getClearButton();
    // Select the 2nd tab
    driver.findElement(new ByWComponentPath(ui, "WTab[1]")).click();
    // Enter some text and use the duplicate button
    driver.findElement(new ByWComponent(textField)).sendKeys("dummy");
    driver.findElement(new ByWComponent(duplicateButton)).click();
    Assert.assertEquals("Incorrect text field text after duplicate", "dummydummy", driver.findElement(new ByWComponent(textField)).getAttribute("value"));
    // Clear the text
    driver.findElement(new ByWComponent(clearButton)).click();
    Assert.assertEquals("Incorrect text field text after clear", "", driver.findElement(new ByWComponent(textField)).getAttribute("value"));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) ByWComponentPath(com.github.bordertech.wcomponents.test.selenium.ByWComponentPath) ByWComponent(com.github.bordertech.wcomponents.test.selenium.ByWComponent) WTextField(com.github.bordertech.wcomponents.WTextField) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 45 with WButton

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

the class LinkOptionsExample method getButtonControls.

/**
 * build the button controls field set.
 *
 * @param errors the error pane from the page.
 * @return a field set for the controls.
 */
private WFieldSet getButtonControls(final WValidationErrors errors) {
    // Options Layout
    WFieldSet fieldSet = new WFieldSet("Link configuration");
    WFieldLayout layout = new WFieldLayout();
    layout.setLabelWidth(30);
    layout.addField("Link text", tfLinkLabel);
    layout.addField("Link address", tfUrlField);
    layout.addField("Link AccessKey", tfAccesskey).getLabel().setHint("A single upper case letter or digit.");
    layout.addField("Render as button", cbRenderAsButton);
    layout.addField("Disabled", cbDisabled);
    layout.addField("Open in a new window", cbOpenNew);
    layout.addField("setImage ('/image/attachment.png')", cbSetImage);
    layout.addField("Image Position", ddImagePosition);
    layout.setMargin(new com.github.bordertech.wcomponents.Margin(0, 0, 6, 0));
    // Apply Button
    WButton apply = new WButton("Apply");
    apply.setAction(new ValidatingAction(errors, fieldSet) {

        @Override
        public void executeOnValid(final ActionEvent event) {
            applySettings();
        }
    });
    fieldSet.add(layout);
    fieldSet.add(apply);
    return fieldSet;
}
Also used : WFieldSet(com.github.bordertech.wcomponents.WFieldSet) ValidatingAction(com.github.bordertech.wcomponents.validation.ValidatingAction) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) WButton(com.github.bordertech.wcomponents.WButton)

Aggregations

WButton (com.github.bordertech.wcomponents.WButton)76 Test (org.junit.Test)39 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)25 Action (com.github.bordertech.wcomponents.Action)20 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)18 WTextField (com.github.bordertech.wcomponents.WTextField)17 WHeading (com.github.bordertech.wcomponents.WHeading)16 WContainer (com.github.bordertech.wcomponents.WContainer)14 WPanel (com.github.bordertech.wcomponents.WPanel)13 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)11 ValidatingAction (com.github.bordertech.wcomponents.validation.ValidatingAction)10 WLabel (com.github.bordertech.wcomponents.WLabel)9 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)8 UIContext (com.github.bordertech.wcomponents.UIContext)7 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)7 WText (com.github.bordertech.wcomponents.WText)6 WDataTable (com.github.bordertech.wcomponents.WDataTable)5 WFieldSet (com.github.bordertech.wcomponents.WFieldSet)5 WTable (com.github.bordertech.wcomponents.WTable)5 AdapterBasicTableModel (com.github.bordertech.wcomponents.AdapterBasicTableModel)4