Search in sources :

Example 56 with WTextField

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

the class WRepeaterRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    WRepeater repeater = new WRepeater();
    repeater.setRepeatedComponent(new WTextField());
    repeater.setBeanList(Arrays.asList(ROW_DATA));
    // Should have 3 inputs
    assertXpathEvaluatesTo("3", "count(//ui:textfield)", repeater);
    assertXpathEvaluatesTo(ROW_DATA[0], "//ui:textfield[1]/text()", repeater);
    assertXpathEvaluatesTo(ROW_DATA[1], "//ui:textfield[2]/text()", repeater);
    assertXpathEvaluatesTo(ROW_DATA[2], "//ui:textfield[3]/text()", repeater);
}
Also used : WRepeater(com.github.bordertech.wcomponents.WRepeater) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 57 with WTextField

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

the class WSubordinateControlRenderer_Test method testAllConditions.

@Test
public void testAllConditions() throws IOException, SAXException, XpathException {
    SubordinateTrigger condTrigger = new WNumberField();
    SubordinateTrigger condTrigger2 = new WTextField();
    SubordinateTarget actionTarget = new WTextField();
    BigDecimal value = BigDecimal.valueOf(2);
    Condition cond1 = new Equal(condTrigger, value);
    Condition cond2 = new NotEqual(condTrigger, value);
    Condition cond3 = new LessThan(condTrigger, value);
    Condition cond4 = new LessThanOrEqual(condTrigger, value);
    Condition cond5 = new GreaterThan(condTrigger, value);
    Condition cond6 = new GreaterThanOrEqual(condTrigger, value);
    Condition cond7 = new Match(condTrigger2, "[abc]");
    // Basic Condition
    Rule rule = new Rule();
    rule.setCondition(new And(cond1, cond2, cond3, cond4, cond5, cond6, cond7));
    rule.addActionOnTrue(new Show(actionTarget));
    rule.addActionOnFalse(new Hide(actionTarget));
    // Setup Subordinate
    WSubordinateControl control = new WSubordinateControl();
    control.addRule(rule);
    WContainer root = new WContainer();
    root.add(condTrigger);
    root.add(condTrigger2);
    root.add(actionTarget);
    root.add(control);
    setActiveContext(createUIContext());
    // Validate Schema
    assertSchemaMatch(root);
    assertXpathNotExists("//ui:subordinate/ui:and/ui:condition[1]/@operator", root);
    assertXpathEvaluatesTo("ne", "//ui:subordinate/ui:and/ui:condition[2]/@operator", root);
    assertXpathEvaluatesTo("lt", "//ui:subordinate/ui:and/ui:condition[3]/@operator", root);
    assertXpathEvaluatesTo("le", "//ui:subordinate/ui:and/ui:condition[4]/@operator", root);
    assertXpathEvaluatesTo("gt", "//ui:subordinate/ui:and/ui:condition[5]/@operator", root);
    assertXpathEvaluatesTo("ge", "//ui:subordinate/ui:and/ui:condition[6]/@operator", root);
    assertXpathEvaluatesTo("rx", "//ui:subordinate/ui:and/ui:condition[7]/@operator", root);
}
Also used : Condition(com.github.bordertech.wcomponents.subordinate.Condition) Hide(com.github.bordertech.wcomponents.subordinate.Hide) WContainer(com.github.bordertech.wcomponents.WContainer) NotEqual(com.github.bordertech.wcomponents.subordinate.NotEqual) WNumberField(com.github.bordertech.wcomponents.WNumberField) LessThanOrEqual(com.github.bordertech.wcomponents.subordinate.LessThanOrEqual) WSubordinateControl(com.github.bordertech.wcomponents.subordinate.WSubordinateControl) GreaterThanOrEqual(com.github.bordertech.wcomponents.subordinate.GreaterThanOrEqual) BigDecimal(java.math.BigDecimal) Match(com.github.bordertech.wcomponents.subordinate.Match) SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) LessThan(com.github.bordertech.wcomponents.subordinate.LessThan) Equal(com.github.bordertech.wcomponents.subordinate.Equal) LessThanOrEqual(com.github.bordertech.wcomponents.subordinate.LessThanOrEqual) NotEqual(com.github.bordertech.wcomponents.subordinate.NotEqual) GreaterThanOrEqual(com.github.bordertech.wcomponents.subordinate.GreaterThanOrEqual) GreaterThan(com.github.bordertech.wcomponents.subordinate.GreaterThan) And(com.github.bordertech.wcomponents.subordinate.And) SubordinateTrigger(com.github.bordertech.wcomponents.SubordinateTrigger) Show(com.github.bordertech.wcomponents.subordinate.Show) Rule(com.github.bordertech.wcomponents.subordinate.Rule) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 58 with WTextField

use of com.github.bordertech.wcomponents.WTextField 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 59 with WTextField

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

the class DiagnosticImpl_Test method testGetDescription.

@Test
public void testGetDescription() {
    final UIContext uic = new UIContextImpl();
    final WTextField input = new WTextField();
    final String noArgsMessage = "The field is required";
    final String fieldArgMessage = "The field ''{0}'' is required";
    // Test with no formatting
    DiagnosticImpl diag = new DiagnosticImpl(Diagnostic.INFO, uic, input, noArgsMessage);
    Assert.assertEquals("Incorrect description text", noArgsMessage, diag.getDescription());
    // Test with formatting, but missing label text should default to empty String
    diag = new DiagnosticImpl(Diagnostic.INFO, uic, input, fieldArgMessage, input);
    Assert.assertEquals("Incorrect description text", "The field '' is required", diag.getDescription());
    // Test with formatting with accessible text set
    input.setAccessibleText("a");
    Assert.assertEquals("Incorrect description text", "The field 'a' is required", diag.getDescription());
    // Test with formatting with toolTip
    input.setAccessibleText(null);
    input.setToolTip("a tooltip");
    Assert.assertEquals("Incorrect description text", "The field 'a tooltip' is required", diag.getDescription());
    // Test with label set
    WLabel label = new WLabel("bc", input);
    Assert.assertEquals("Incorrect description text", "The field 'bc' is required", diag.getDescription());
    // Test with label set, with a colon at the end
    label.setText("def:");
    Assert.assertEquals("Incorrect description text", "The field 'def' is required", diag.getDescription());
}
Also used : UIContext(com.github.bordertech.wcomponents.UIContext) UIContextImpl(com.github.bordertech.wcomponents.UIContextImpl) WTextField(com.github.bordertech.wcomponents.WTextField) WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Example 60 with WTextField

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

the class DiagnosticImpl_Test method testGetComponent.

@Test
public void testGetComponent() {
    final WComponent component = new WTextField();
    DiagnosticImpl diag = new DiagnosticImpl(Diagnostic.INFO, component, "dummy");
    Assert.assertSame("Incorrect component", component, diag.getComponent());
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) WTextField(com.github.bordertech.wcomponents.WTextField) 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