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);
}
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);
}
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"));
}
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());
}
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());
}
Aggregations