Search in sources :

Example 71 with WPanel

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

the class BorderLayoutRenderer_Test method testDoRender.

@Test
public void testDoRender() throws IOException, SAXException, XpathException {
    final String northText = "BorderRenderer_Test.testPaint.northText";
    final String westText = "BorderRenderer_Test.testPaint.westText";
    final String southText = "BorderRenderer_Test.testPaint.southText";
    final String eastText = "BorderRenderer_Test.testPaint.eastText";
    final String centerText = "BorderRenderer_Test.testPaint.centerText";
    WPanel container = new WPanel();
    container.setLayout(new BorderLayout(GAP, BIG_GAP));
    assertSchemaMatch(container);
    assertXpathEvaluatesTo(GAP.toString(), "//ui:panel/ui:borderlayout/@hgap", container);
    assertXpathEvaluatesTo(BIG_GAP.toString(), "//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);
    container.add(new WText(northText), BorderLayout.NORTH);
    container.add(new WText(westText), BorderLayout.WEST);
    assertXpathEvaluatesTo(northText, "normalize-space(//ui:panel/ui:borderlayout/ui:north)", container);
    assertXpathNotExists("//ui:panel/ui:borderlayout/ui:south", container);
    assertXpathNotExists("//ui:panel/ui:borderlayout/ui:east", container);
    assertXpathEvaluatesTo(westText, "normalize-space(//ui:panel/ui:borderlayout/ui:west)", container);
    assertXpathNotExists("//ui:panel/ui:borderlayout/ui:center", container);
    container.add(new WText(southText), BorderLayout.SOUTH);
    container.add(new WText(eastText), BorderLayout.EAST);
    container.add(new WText(centerText));
    assertXpathEvaluatesTo(northText, "normalize-space(//ui:panel/ui:borderlayout/ui:north)", container);
    assertXpathEvaluatesTo(westText, "normalize-space(//ui:panel/ui:borderlayout/ui:west)", container);
    assertXpathEvaluatesTo(southText, "normalize-space(//ui:panel/ui:borderlayout/ui:south)", container);
    assertXpathEvaluatesTo(eastText, "normalize-space(//ui:panel/ui:borderlayout/ui:east)", container);
    assertXpathEvaluatesTo(centerText, "normalize-space(//ui:panel/ui:borderlayout/ui:center)", container);
}
Also used : BorderLayout(com.github.bordertech.wcomponents.layout.BorderLayout) WText(com.github.bordertech.wcomponents.WText) WPanel(com.github.bordertech.wcomponents.WPanel) Test(org.junit.Test)

Example 72 with WPanel

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

the class ColumnLayoutRenderer_Test method testDoRender.

@Test
public void testDoRender() throws IOException, SAXException, XpathException {
    final int[] cols = new int[] { 1, 100 };
    final Alignment[] aligns = new Alignment[] { Alignment.RIGHT, Alignment.CENTER };
    final String text1 = "ColumnRenderer_Test.testPaint.text1";
    final String text2 = "ColumnRenderer_Test.testPaint.text2";
    WPanel container = new WPanel();
    container.setLayout(new ColumnLayout(cols));
    // One element -> 1 row, 2 cols (one empty)
    container.add(new WText(text1));
    assertSchemaMatch(container);
    assertXpathEvaluatesTo("1", "count(//ui:panel/ui:columnlayout)", container);
    assertXpathEvaluatesTo(String.valueOf(cols.length), "count(//ui:panel/ui:columnlayout/ui:column)", container);
    assertXpathEvaluatesTo(text1, "normalize-space(//ui:panel/ui:columnlayout/ui:cell[1])", container);
    assertXpathEvaluatesTo("", "normalize-space(//ui:panel/ui:columnlayout/ui:cell[2])", container);
    // Two elements -> 1 row, 2 cols
    container.add(new WText(text2));
    assertSchemaMatch(container);
    assertXpathEvaluatesTo("1", "count(//ui:panel/ui:columnlayout)", container);
    assertXpathEvaluatesTo(String.valueOf(cols.length), "count(//ui:panel/ui:columnlayout/ui:column)", container);
    assertXpathEvaluatesTo(String.valueOf(cols[0]), "//ui:panel/ui:columnlayout/ui:column[1]/@width", container);
    assertXpathEvaluatesTo(String.valueOf(cols[1]), "//ui:panel/ui:columnlayout/ui:column[2]/@width", container);
    assertXpathEvaluatesTo(text1, "normalize-space(//ui:panel/ui:columnlayout/ui:cell[1])", container);
    assertXpathEvaluatesTo(text2, "normalize-space(//ui:panel/ui:columnlayout/ui:cell[2])", container);
    assertXpathEvaluatesTo("", "//ui:panel/ui:columnlayout/@hgap", container);
    assertXpathEvaluatesTo("", "//ui:panel/ui:columnlayout/@vgap", container);
    // Test hgap, vgap
    container.setLayout(new ColumnLayout(cols, GAP, BIG_GAP));
    assertSchemaMatch(container);
    assertXpathEvaluatesTo(GAP.toString(), "//ui:panel/ui:columnlayout/@hgap", container);
    assertXpathEvaluatesTo(BIG_GAP.toString(), "//ui:panel/ui:columnlayout/@vgap", container);
    // Test Alignment
    container.setLayout(new ColumnLayout(cols, aligns));
    assertSchemaMatch(container);
    assertXpathEvaluatesTo("", "//ui:panel/ui:columnlayout/@hgap", container);
    assertXpathEvaluatesTo("", "//ui:panel/ui:columnlayout/@vgap", container);
    assertXpathEvaluatesTo("right", "//ui:panel/ui:columnlayout/ui:column[1]/@align", container);
    assertXpathEvaluatesTo("center", "//ui:panel/ui:columnlayout/ui:column[2]/@align", container);
    // Test Alignment, hgap, vgap
    container.setLayout(new ColumnLayout(cols, aligns, GAP, BIG_GAP));
    assertSchemaMatch(container);
    assertXpathEvaluatesTo(GAP.toString(), "//ui:panel/ui:columnlayout/@hgap", container);
    assertXpathEvaluatesTo(BIG_GAP.toString(), "//ui:panel/ui:columnlayout/@vgap", container);
    assertXpathEvaluatesTo("right", "//ui:panel/ui:columnlayout/ui:column[1]/@align", container);
    assertXpathEvaluatesTo("center", "//ui:panel/ui:columnlayout/ui:column[2]/@align", container);
}
Also used : Alignment(com.github.bordertech.wcomponents.layout.ColumnLayout.Alignment) WText(com.github.bordertech.wcomponents.WText) WPanel(com.github.bordertech.wcomponents.WPanel) ColumnLayout(com.github.bordertech.wcomponents.layout.ColumnLayout) Test(org.junit.Test)

Example 73 with WPanel

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

the class FlowLayoutRenderer_Test method testDoRenderWhenEmpty.

// The expected render of the default constructor.
@Test
public void testDoRenderWhenEmpty() throws IOException, SAXException, XpathException {
    WPanel panel = new WPanel();
    panel.setLayout(new FlowLayout());
    assertSchemaMatch(panel);
    assertXpathExists("//ui:panel/ui:flowlayout", panel);
    assertXpathEvaluatesTo("center", "//ui:panel/ui:flowlayout/@align", panel);
    assertXpathNotExists("//ui:panel/ui:flowlayout/ui:cell", panel);
    assertXpathNotExists("//ui:panel/ui:flowlayout/@gap", panel);
    assertXpathNotExists("//ui:panel/ui:flowlayout/@valign", panel);
}
Also used : FlowLayout(com.github.bordertech.wcomponents.layout.FlowLayout) WPanel(com.github.bordertech.wcomponents.WPanel) Test(org.junit.Test)

Example 74 with WPanel

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

the class FlowLayoutRenderer_Test method testRenderContentAlignment.

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

Example 75 with WPanel

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

the class FlowLayoutRenderer_Test method testHVGaps.

// Test that use of deprecated two-gap constructors output the expected gap
@Test
public void testHVGaps() throws IOException, SAXException, XpathException {
    WPanel panel = new WPanel();
    String expected;
    for (FlowLayout.Alignment a : FlowLayout.Alignment.values()) {
        panel.setLayout(new FlowLayout(a, 3, 16));
        assertSchemaMatch(panel);
        expected = a == FlowLayout.VERTICAL ? BIG_GAP.toString() : GAP.toString();
        assertXpathEvaluatesTo(expected, "//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)

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