Search in sources :

Example 21 with WPanel

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

the class FlowLayoutRenderer_Test method testRenderAlignment.

@Test
public void testRenderAlignment() throws IOException, SAXException, XpathException {
    WPanel panel = new WPanel();
    String expected;
    for (FlowLayout.Alignment a : FlowLayout.Alignment.values()) {
        panel.setLayout(new FlowLayout(a));
        assertSchemaMatch(panel);
        assertXpathExists("//ui:panel/ui:flowlayout", panel);
        expected = a.toString().toLowerCase();
        assertXpathEvaluatesTo(expected, "//ui:panel/ui:flowlayout/@align", panel);
    }
}
Also used : FlowLayout(com.github.bordertech.wcomponents.layout.FlowLayout) WPanel(com.github.bordertech.wcomponents.WPanel) Test(org.junit.Test)

Example 22 with WPanel

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

the class FlowLayoutRenderer_Test method testRenderGap.

@Test
public void testRenderGap() throws IOException, SAXException, XpathException {
    WPanel panel = new WPanel();
    for (FlowLayout.Alignment a : FlowLayout.Alignment.values()) {
        panel.setLayout(new FlowLayout(a, GAP));
        assertSchemaMatch(panel);
        assertXpathEvaluatesTo(GAP.toString(), "//ui:panel/ui:flowlayout/@gap", panel);
    }
}
Also used : FlowLayout(com.github.bordertech.wcomponents.layout.FlowLayout) WPanel(com.github.bordertech.wcomponents.WPanel) Test(org.junit.Test)

Example 23 with WPanel

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

the class GridLayoutRenderer_Test method testDoRenderWhenEmpty.

@Test
public void testDoRenderWhenEmpty() throws IOException, SAXException, XpathException {
    WPanel panel = new WPanel();
    panel.setLayout(new GridLayout(0, 1));
    assertSchemaMatch(panel);
    assertXpathExists("//ui:panel/ui:gridlayout", panel);
    assertXpathNotExists("//ui:panel/ui:gridlayout/ui:cell", panel);
    assertXpathEvaluatesTo("0", "//ui:panel/ui:gridlayout/@rows", panel);
    assertXpathEvaluatesTo("1", "//ui:panel/ui:gridlayout/@cols", panel);
    assertXpathNotExists("//ui:panel/ui:gridlayout/@hgap", panel);
    assertXpathNotExists("//ui:panel/ui:gridlayout/@vgap", panel);
}
Also used : GridLayout(com.github.bordertech.wcomponents.layout.GridLayout) WPanel(com.github.bordertech.wcomponents.WPanel) Test(org.junit.Test)

Example 24 with WPanel

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

the class GridLayoutRenderer_Test method testDoRender.

@Test
public void testDoRender() throws IOException, SAXException, XpathException {
    final String text1 = "GridRenderer_Test.testPaint.text1";
    final String text2 = "GridRenderer_Test.testPaint.text2";
    WPanel panel = new WPanel();
    panel.setLayout(new GridLayout(1, 2, GAP, BIG_GAP));
    assertSchemaMatch(panel);
    assertXpathEvaluatesTo("1", "//ui:panel/ui:gridlayout/@rows", panel);
    assertXpathEvaluatesTo("2", "//ui:panel/ui:gridlayout/@cols", panel);
    assertXpathEvaluatesTo(GAP.toString(), "//ui:panel/ui:gridlayout/@hgap", panel);
    assertXpathEvaluatesTo(BIG_GAP.toString(), "//ui:panel/ui:gridlayout/@vgap", panel);
    assertXpathNotExists("//ui:panel/ui:gridlayout/ui:cell", panel);
    panel.add(new WText(text1));
    panel.add(new WText(text2));
    assertXpathEvaluatesTo("2", "count(//ui:panel/ui:gridlayout/ui:cell)", panel);
    assertXpathEvaluatesTo(text1, "normalize-space(//ui:panel/ui:gridlayout/ui:cell[1])", panel);
    assertXpathEvaluatesTo(text2, "normalize-space(//ui:panel/ui:gridlayout/ui:cell[2])", panel);
}
Also used : GridLayout(com.github.bordertech.wcomponents.layout.GridLayout) WText(com.github.bordertech.wcomponents.WText) WPanel(com.github.bordertech.wcomponents.WPanel) Test(org.junit.Test)

Example 25 with WPanel

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

the class ListLayoutRenderer_Test method testDoRenderWhenEmpty.

@Test
public void testDoRenderWhenEmpty() throws IOException, SAXException, XpathException {
    WPanel panel = new WPanel();
    panel.setLayout(new ListLayout(ListLayout.Type.FLAT, ListLayout.Alignment.LEFT, ListLayout.Separator.NONE, false));
    assertSchemaMatch(panel);
    assertXpathExists("//ui:panel/ui:listlayout", panel);
    assertXpathNotExists("//ui:panel/ui:listlayout/ui:cell", panel);
    assertXpathNotExists("//ui:panel/ui:listlayout/@gap", panel);
    assertXpathNotExists("//ui:panel/ui:listlayout/@align", panel);
    assertXpathNotExists("//ui:panel/ui:listlayout/@separator", panel);
    assertXpathNotExists("//ui:panel/ui:listlayout/@ordered", panel);
    assertXpathEvaluatesTo("flat", "//ui:panel/ui:listlayout/@type", panel);
    panel.setLayout(new ListLayout(ListLayout.Type.STRIPED, ListLayout.Alignment.CENTER, ListLayout.Separator.NONE, false));
    assertXpathEvaluatesTo("striped", "//ui:panel/ui:listlayout/@type", panel);
    assertXpathEvaluatesTo("center", "//ui:panel/ui:listlayout/@align", panel);
    assertXpathNotExists("//ui:panel/ui:listlayout/ui:cell", panel);
    assertXpathNotExists("//ui:panel/ui:listlayout/@gap", panel);
    assertXpathNotExists("//ui:panel/ui:listlayout/@separator", panel);
    assertXpathNotExists("//ui:panel/ui:listlayout/@ordered", panel);
    panel.setLayout(new ListLayout(ListLayout.Type.STACKED, ListLayout.Alignment.RIGHT, ListLayout.Separator.NONE, false, GAP));
    assertXpathEvaluatesTo("stacked", "//ui:panel/ui:listlayout/@type", panel);
    assertXpathEvaluatesTo("right", "//ui:panel/ui:listlayout/@align", panel);
    assertXpathEvaluatesTo(GAP.toString(), "//ui:panel/ui:listlayout/@gap", panel);
    assertXpathNotExists("//ui:panel/ui:listlayout/ui:cell", panel);
    assertXpathNotExists("//ui:panel/ui:listlayout/@separator", panel);
    assertXpathNotExists("//ui:panel/ui:listlayout/@ordered", panel);
}
Also used : ListLayout(com.github.bordertech.wcomponents.layout.ListLayout) 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