use of com.github.bordertech.wcomponents.WTextArea in project wcomponents by BorderTech.
the class WTextAreaRenderer_Test method testDoPaint.
@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
WTextArea field = new WTextArea();
WButton button = new WButton();
WContainer root = new WContainer();
root.add(field);
root.add(button);
assertSchemaMatch(field);
assertXpathEvaluatesTo(field.getId(), "//ui:textarea/@id", field);
assertXpathNotExists("//ui:textarea/@disabled", field);
assertXpathNotExists("//ui:textarea/@hidden", field);
assertXpathNotExists("//ui:textarea/@required", field);
assertXpathNotExists("//ui:textarea/@readOnly", field);
assertXpathNotExists("//ui:textarea/@minLength", field);
assertXpathNotExists("//ui:textarea/@maxLength", field);
assertXpathNotExists("//ui:textarea/@toolTip", field);
assertXpathNotExists("//ui:textarea/@accessibleText", field);
assertXpathNotExists("//ui:textarea/@rows", field);
assertXpathNotExists("//ui:textarea/@cols", field);
assertXpathNotExists("//ui:textarea/ui:rtf", field);
field.setDisabled(true);
assertSchemaMatch(field);
assertXpathEvaluatesTo("true", "//ui:textarea/@disabled", field);
setFlag(field, ComponentModel.HIDE_FLAG, true);
assertSchemaMatch(field);
assertXpathEvaluatesTo("true", "//ui:textarea/@hidden", field);
field.setMandatory(true);
assertSchemaMatch(field);
assertXpathEvaluatesTo("true", "//ui:textarea/@required", field);
field.setMinLength(45);
assertSchemaMatch(field);
assertXpathEvaluatesTo("45", "//ui:textarea/@minLength", field);
field.setMaxLength(50);
assertSchemaMatch(field);
assertXpathEvaluatesTo("50", "//ui:textarea/@maxLength", field);
field.setToolTip("tooltip");
assertSchemaMatch(field);
assertXpathEvaluatesTo(field.getToolTip(), "//ui:textarea/@toolTip", field);
field.setAccessibleText("accessible");
assertSchemaMatch(field);
assertXpathEvaluatesTo(field.getAccessibleText(), "//ui:textarea/@accessibleText", field);
field.setRows(20);
assertSchemaMatch(field);
assertXpathEvaluatesTo("20", "//ui:textarea/@rows", field);
field.setColumns(40);
assertSchemaMatch(field);
assertXpathEvaluatesTo("40", "//ui:textarea/@cols", field);
field.setRichTextArea(false);
assertSchemaMatch(field);
assertXpathNotExists("//ui:textarea/ui:rtf", field);
field.setRichTextArea(true);
assertSchemaMatch(field);
assertXpathExists("//ui:textarea/ui:rtf", field);
field.setDefaultSubmitButton(button);
assertSchemaMatch(field);
assertXpathEvaluatesTo(button.getId(), "//ui:textarea/@buttonId", field);
field.setPattern("");
assertSchemaMatch(field);
assertXpathNotExists("//ui:textarea/@pattern", field);
// Pattern is not supported on the client for TextArea, and will not be rendered
field.setPattern("test[123]");
assertSchemaMatch(field);
assertXpathNotExists("//ui:textarea/@pattern", field);
field.setText("Hello");
assertSchemaMatch(field);
assertXpathEvaluatesTo(field.getText(), "normalize-space(//ui:textarea)", field);
field.setPlaceholder("enter stuff here");
assertSchemaMatch(field);
assertXpathEvaluatesTo("enter stuff here", "//ui:textarea/@placeholder", field);
}
use of com.github.bordertech.wcomponents.WTextArea in project wcomponents by BorderTech.
the class WValidationErrorsRenderer_Test method testDoPaintBasic.
@Test
public void testDoPaintBasic() throws IOException, SAXException, XpathException {
WValidationErrors errors = new WValidationErrors();
WTextArea text1 = new WTextArea();
text1.setText("text1");
WContainer root = new WContainer();
root.add(errors);
root.add(text1);
root.setLocked(true);
// Validate Schema with no errors
assertSchemaMatch(root);
// Simulate Error Message
setActiveContext(createUIContext());
List<Diagnostic> diags = new ArrayList<>();
diags.add(new DiagnosticImpl(Diagnostic.ERROR, text1, "Test Error1"));
root.showErrorIndicators(diags);
errors.setErrors(diags);
assertSchemaMatch(root);
assertXpathEvaluatesTo(text1.getId(), "//ui:validationerrors/ui:error/@for", root);
assertXpathEvaluatesTo("Test Error1", "//ui:validationerrors/ui:error", root);
String title = "WValidationErrorsTitle";
errors.setTitleText(title);
assertSchemaMatch(root);
assertXpathEvaluatesTo(title, "//ui:validationerrors/@title", root);
// Check for error message with no associated component
setActiveContext(createUIContext());
diags.clear();
diags.add(new DiagnosticImpl(Diagnostic.ERROR, null, "Test Error1"));
errors.setErrors(diags);
assertSchemaMatch(root);
assertXpathNotExists("//ui:validationerrors/ui:error/@for", root);
assertXpathEvaluatesTo("Test Error1", "//ui:validationerrors/ui:error", root);
}
use of com.github.bordertech.wcomponents.WTextArea in project wcomponents by BorderTech.
the class WFieldRenderer_Test method testRendererCorrectlyConfigured.
/**
* Test the Layout is correctly configured.
*/
@Test
public void testRendererCorrectlyConfigured() {
WField field = new WFieldLayout().addField("test1", new WTextArea());
Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(field) instanceof WFieldRenderer);
}
Aggregations