use of com.github.bordertech.wcomponents.WContainer in project wcomponents by BorderTech.
the class WFieldWarningIndicatorRenderer_Test method testDoPaint.
@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
WContainer root = new WContainer();
WPanel target = new WPanel();
WFieldWarningIndicator indicator = new WFieldWarningIndicator(target);
root.add(target);
root.add(indicator);
// Simulate Warning Message
setActiveContext(createUIContext());
List<Diagnostic> diags = new ArrayList<>();
diags.add(new DiagnosticImpl(Diagnostic.WARNING, target, "Test Warning"));
root.showWarningIndicators(diags);
// Validate Schema
assertSchemaMatch(root);
// Check Attributes
assertXpathEvaluatesTo(indicator.getId(), "//ui:fieldindicator/@id", root);
assertXpathEvaluatesTo("warn", "//ui:fieldindicator/@type", root);
assertXpathEvaluatesTo(target.getId(), "//ui:fieldindicator/@for", root);
// Check Message
assertXpathEvaluatesTo("Test Warning", "//ui:fieldindicator/ui:message", root);
}
use of com.github.bordertech.wcomponents.WContainer in project wcomponents by BorderTech.
the class WInternalLinkRenderer_Test method testDoPaint.
@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
WPanel refer = new WPanel();
WInternalLink link = new WInternalLink();
WContainer root = new WContainer();
root.add(refer);
root.add(link);
String linkText = "TEXT TEST";
String linkTip = "TIP TEST";
String linkAccessibleText = "ACCESS TEST";
link.setText(linkText);
link.setReference(refer);
assertSchemaMatch(link);
assertXpathEvaluatesTo(link.getId(), "//ui:link/@id", link);
assertXpathUrlEvaluatesTo("#" + refer.getId(), "//ui:link/@url", link);
assertXpathEvaluatesTo(linkText, "//ui:link", link);
assertXpathNotExists("//ui:link/@type", link);
assertXpathNotExists("//ui:link/@toolTip", link);
assertXpathNotExists("//ui:link/@accessibleText", link);
link.setToolTip(linkTip);
link.setAccessibleText(linkAccessibleText);
assertSchemaMatch(link);
assertXpathEvaluatesTo(linkTip, "//ui:link/@toolTip", link);
assertXpathEvaluatesTo(linkAccessibleText, "//ui:link/@accessibleText", link);
link.setText(null);
Assert.assertEquals("A link with no text should not render any output", "", render(link));
}
use of com.github.bordertech.wcomponents.WContainer in project wcomponents by BorderTech.
the class WLabelRenderer_Test method testDoPaintAllOptions.
@Test
public void testDoPaintAllOptions() throws IOException, SAXException, XpathException {
WTextArea text = new WTextArea();
text.setText("text1");
WLabel label = new WLabel();
label.setForComponent(text);
label.setHint("hint1");
label.setAccessKey('A');
label.setText("label1");
WContainer root = new WContainer();
root.add(label);
root.add(text);
// Validate Schema
assertSchemaMatch(root);
// Check Attributes
assertXpathEvaluatesTo(label.getId(), "//ui:label/@id", label);
assertXpathEvaluatesTo(text.getId(), "//ui:label/@for", label);
assertXpathEvaluatesTo("hint1", "//ui:label/@hint", label);
assertXpathEvaluatesTo("A", "//ui:label/@accessKey", label);
assertXpathEvaluatesTo("input", "//ui:label/@what", label);
// Check Label
assertXpathEvaluatesTo("label1", "//ui:label", label);
// Add Children to Label
WTextArea text2 = new WTextArea();
text2.setText("text2");
label.add(text2);
assertSchemaMatch(root);
assertXpathEvaluatesTo("text2", "//ui:label/ui:textarea", label);
}
use of com.github.bordertech.wcomponents.WContainer 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);
}
use of com.github.bordertech.wcomponents.WContainer 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);
}
Aggregations