Search in sources :

Example 66 with WPanel

use of com.github.bordertech.wcomponents.WPanel in project wcomponents by BorderTech.

the class WPanelRenderer_Test method testRendererCorrectlyConfigured.

@Test
public void testRendererCorrectlyConfigured() {
    WPanel panel = new WPanel();
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(panel) instanceof WPanelRenderer);
}
Also used : WPanel(com.github.bordertech.wcomponents.WPanel) Test(org.junit.Test)

Example 67 with WPanel

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

Example 68 with WPanel

use of com.github.bordertech.wcomponents.WPanel 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);
}
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 69 with WPanel

use of com.github.bordertech.wcomponents.WPanel in project wcomponents by BorderTech.

the class WHiddenCommentRenderer_Test method testMultipleComments.

@Test
public void testMultipleComments() throws IOException, SAXException, XpathException {
    String textString1 = "test comment1";
    String textString2 = "test comment2";
    WHiddenComment comment1 = new WHiddenComment(textString1);
    WHiddenComment comment2 = new WHiddenComment(textString2);
    WPanel panel = new WPanel();
    panel.add(comment1);
    panel.add(comment2);
    // Validate
    assertSchemaMatch(panel);
    assertXpathEvaluatesTo("2", "count(//ui:comment)", panel);
}
Also used : WHiddenComment(com.github.bordertech.wcomponents.WHiddenComment) WPanel(com.github.bordertech.wcomponents.WPanel) Test(org.junit.Test)

Example 70 with WPanel

use of com.github.bordertech.wcomponents.WPanel in project wcomponents by BorderTech.

the class BorderLayoutRenderer_Test method testDoRenderWhenEmpty.

@Test
public void testDoRenderWhenEmpty() throws IOException, SAXException, XpathException {
    WPanel container = new WPanel();
    container.setLayout(new BorderLayout());
    assertSchemaMatch(container);
    assertXpathExists("//ui:panel/ui:borderlayout", container);
    assertXpathNotExists("//ui:panel/ui:borderlayout/@hgap", container);
    assertXpathNotExists("//ui:panel/ui:borderlayout/@vgap", container);
    assertXpathNotExists("//ui:panel/ui:borderlayout/ui:north", container);
    assertXpathNotExists("//ui:panel/ui:borderlayout/ui:south", container);
    assertXpathNotExists("//ui:panel/ui:borderlayout/ui:east", container);
    assertXpathNotExists("//ui:panel/ui:borderlayout/ui:west", container);
    assertXpathNotExists("//ui:panel/ui:borderlayout/ui:center", container);
}
Also used : BorderLayout(com.github.bordertech.wcomponents.layout.BorderLayout) WPanel(com.github.bordertech.wcomponents.WPanel) Test(org.junit.Test)

Aggregations

WPanel (com.github.bordertech.wcomponents.WPanel)77 Test (org.junit.Test)39 WHeading (com.github.bordertech.wcomponents.WHeading)17 WText (com.github.bordertech.wcomponents.WText)17 FlowLayout (com.github.bordertech.wcomponents.layout.FlowLayout)16 WButton (com.github.bordertech.wcomponents.WButton)13 ColumnLayout (com.github.bordertech.wcomponents.layout.ColumnLayout)10 WContainer (com.github.bordertech.wcomponents.WContainer)9 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)9 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)8 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)8 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)7 WLabel (com.github.bordertech.wcomponents.WLabel)7 Action (com.github.bordertech.wcomponents.Action)6 WTextField (com.github.bordertech.wcomponents.WTextField)6 ArrayList (java.util.ArrayList)6 Size (com.github.bordertech.wcomponents.Size)5 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)5 BorderLayout (com.github.bordertech.wcomponents.layout.BorderLayout)5 Alignment (com.github.bordertech.wcomponents.layout.ColumnLayout.Alignment)5