Search in sources :

Example 21 with WContainer

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);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) DiagnosticImpl(com.github.bordertech.wcomponents.validation.DiagnosticImpl) WPanel(com.github.bordertech.wcomponents.WPanel) ArrayList(java.util.ArrayList) Diagnostic(com.github.bordertech.wcomponents.validation.Diagnostic) WFieldWarningIndicator(com.github.bordertech.wcomponents.validation.WFieldWarningIndicator) Test(org.junit.Test)

Example 22 with WContainer

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));
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) WInternalLink(com.github.bordertech.wcomponents.WInternalLink) WPanel(com.github.bordertech.wcomponents.WPanel) Test(org.junit.Test)

Example 23 with WContainer

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);
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) WContainer(com.github.bordertech.wcomponents.WContainer) WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Example 24 with WContainer

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);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) WPasswordField(com.github.bordertech.wcomponents.WPasswordField) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 25 with WContainer

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);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) WPhoneNumberField(com.github.bordertech.wcomponents.WPhoneNumberField) WSuggestions(com.github.bordertech.wcomponents.WSuggestions) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Aggregations

WContainer (com.github.bordertech.wcomponents.WContainer)49 Test (org.junit.Test)41 WTextField (com.github.bordertech.wcomponents.WTextField)21 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)17 Equal (com.github.bordertech.wcomponents.subordinate.Equal)16 Rule (com.github.bordertech.wcomponents.subordinate.Rule)16 WSubordinateControl (com.github.bordertech.wcomponents.subordinate.WSubordinateControl)16 SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)15 WButton (com.github.bordertech.wcomponents.WButton)14 GreaterThanOrEqual (com.github.bordertech.wcomponents.subordinate.GreaterThanOrEqual)14 LessThanOrEqual (com.github.bordertech.wcomponents.subordinate.LessThanOrEqual)14 NotEqual (com.github.bordertech.wcomponents.subordinate.NotEqual)14 SubordinateTrigger (com.github.bordertech.wcomponents.SubordinateTrigger)11 WComponentGroup (com.github.bordertech.wcomponents.WComponentGroup)10 Hide (com.github.bordertech.wcomponents.subordinate.Hide)10 Show (com.github.bordertech.wcomponents.subordinate.Show)10 WPanel (com.github.bordertech.wcomponents.WPanel)9 Diagnostic (com.github.bordertech.wcomponents.validation.Diagnostic)6 DiagnosticImpl (com.github.bordertech.wcomponents.validation.DiagnosticImpl)6 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)5