use of com.github.bordertech.wcomponents.WContainer in project wcomponents by BorderTech.
the class WDecoratedLabelRenderer_Test method testDoPaint.
@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
final String bodyText = "WDecoratedLabelRenderer_Test.testDoPaint.bodyText";
final String headText = "WDecoratedLabelRenderer_Test.testDoPaint.headText";
final String tailText = "WDecoratedLabelRenderer_Test.testDoPaint.tailText";
// Test minimal text content
WDecoratedLabel decoratedLabel = new WDecoratedLabel(bodyText);
assertSchemaMatch(decoratedLabel);
assertXpathEvaluatesTo(bodyText, "normalize-space(//ui:decoratedlabel/ui:labelbody)", decoratedLabel);
assertXpathNotExists("//ui:decoratedlabel/@labelFocus", decoratedLabel);
decoratedLabel.setHead(new WText(headText));
decoratedLabel.setTail(new WText(tailText));
// Test all text content
assertSchemaMatch(decoratedLabel);
assertXpathEvaluatesTo(headText, "normalize-space(//ui:decoratedlabel/ui:labelhead)", decoratedLabel);
assertXpathEvaluatesTo(bodyText, "normalize-space(//ui:decoratedlabel/ui:labelbody)", decoratedLabel);
assertXpathEvaluatesTo(tailText, "normalize-space(//ui:decoratedlabel/ui:labeltail)", decoratedLabel);
assertXpathNotExists("//ui:decoratedlabel/@labelFocus", decoratedLabel);
// Test complex content
WContainer complexContent = new WContainer();
complexContent.add(new WLabel("Select"));
complexContent.add(new WCheckBox());
decoratedLabel.setBody(complexContent);
assertXpathExists("//ui:decoratedlabel/ui:labelbody/ui:label/following-sibling::ui:checkbox", decoratedLabel);
}
use of com.github.bordertech.wcomponents.WContainer in project wcomponents by BorderTech.
the class WEmailFieldRenderer_Test method testDoPaint.
@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
WEmailField field = new WEmailField();
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:emailfield/@id", field);
assertXpathNotExists("//ui:emailfield/@disabled", field);
assertXpathNotExists("//ui:emailfield/@hidden", field);
assertXpathNotExists("//ui:emailfield/@required", field);
assertXpathNotExists("//ui:emailfield/@readOnly", field);
assertXpathNotExists("//ui:emailfield/@maxLength", field);
assertXpathNotExists("//ui:emailfield/@toolTip", field);
assertXpathNotExists("//ui:emailfield/@accessibleText", field);
assertXpathNotExists("//ui:emailfield/@size", field);
assertXpathNotExists("//ui:emailfield/@buttonId", field);
assertXpathNotExists("//ui:emailfield/@list", field);
field.setDisabled(true);
assertSchemaMatch(field);
assertXpathEvaluatesTo("true", "//ui:emailfield/@disabled", field);
setFlag(field, ComponentModel.HIDE_FLAG, true);
assertSchemaMatch(field);
assertXpathEvaluatesTo("true", "//ui:emailfield/@hidden", field);
field.setMandatory(true);
assertSchemaMatch(field);
assertXpathEvaluatesTo("true", "//ui:emailfield/@required", field);
field.setMaxLength(50);
assertSchemaMatch(field);
assertXpathEvaluatesTo("50", "//ui:emailfield/@maxLength", field);
field.setToolTip("tooltip");
assertSchemaMatch(field);
assertXpathEvaluatesTo(field.getToolTip(), "//ui:emailfield/@toolTip", field);
field.setAccessibleText("accessible");
assertSchemaMatch(field);
assertXpathEvaluatesTo(field.getAccessibleText(), "//ui:emailfield/@accessibleText", field);
field.setColumns(40);
assertSchemaMatch(field);
assertXpathEvaluatesTo("40", "//ui:emailfield/@size", field);
field.setDefaultSubmitButton(button);
assertSchemaMatch(field);
assertXpathEvaluatesTo(button.getId(), "//ui:emailfield/@buttonId", field);
// RFC 2606
field.setText("nobody@wc.test");
assertSchemaMatch(field);
assertXpathEvaluatesTo(field.getText(), "normalize-space(//ui:emailfield)", field);
field.setSuggestions(suggestions);
assertSchemaMatch(field);
assertXpathEvaluatesTo(suggestions.getId(), "//ui:emailfield/@list", field);
field.setPlaceholder("enter stuff here");
assertSchemaMatch(field);
assertXpathEvaluatesTo("enter stuff here", "//ui:emailfield/@placeholder", field);
}
use of com.github.bordertech.wcomponents.WContainer in project wcomponents by BorderTech.
the class WFieldErrorIndicatorRenderer_Test method testDoPaint.
@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
WContainer root = new WContainer();
WPanel target = new WPanel();
WFieldErrorIndicator indicator = new WFieldErrorIndicator(target);
root.add(target);
root.add(indicator);
// Simulate Error Message
setActiveContext(createUIContext());
List<Diagnostic> diags = new ArrayList<>();
diags.add(new DiagnosticImpl(Diagnostic.ERROR, target, "Test Error"));
root.showErrorIndicators(diags);
// Validate Schema
assertSchemaMatch(root);
// Check Attributes
assertXpathEvaluatesTo(indicator.getId(), "//ui:fieldindicator/@id", root);
assertXpathEvaluatesTo("error", "//ui:fieldindicator/@type", root);
assertXpathEvaluatesTo(target.getId(), "//ui:fieldindicator/@for", root);
// Check Message
assertXpathEvaluatesTo("Test Error", "//ui:fieldindicator/ui:message", root);
}
use of com.github.bordertech.wcomponents.WContainer in project wcomponents by BorderTech.
the class WFieldWarningIndicatorRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
WContainer root = new WContainer();
WPanel target = new WPanel();
WFieldWarningIndicator indicator = new WFieldWarningIndicator(target);
root.add(target);
root.add(indicator);
setActiveContext(createUIContext());
List<Diagnostic> diags = new ArrayList<>();
diags.add(new DiagnosticImpl(Diagnostic.WARNING, target, getMaliciousContent()));
root.showWarningIndicators(diags);
assertSafeContent(root);
}
Aggregations