diff options
author | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2017-04-20 17:08:54 +0300 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2017-04-20 16:08:54 +0200 |
commit | 421b959bfe8fa473eaca70e07b663b480f8b7da0 (patch) | |
tree | 059e2196ed174197a2a47d4f40702de3344bb7e9 /uitest | |
parent | 779c260b674705a86235f76b5d38685b2062b193 (diff) | |
download | vaadin-framework-421b959bfe8fa473eaca70e07b663b480f8b7da0.tar.gz vaadin-framework-421b959bfe8fa473eaca70e07b663b480f8b7da0.zip |
Fix issues in Grid with undefined height (#9118)
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/components/grid/GridUndefinedHeight.java | 40 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/grid/GridUndefinedHeightTest.java | 47 |
2 files changed, 87 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridUndefinedHeight.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridUndefinedHeight.java new file mode 100644 index 0000000000..5043729a2a --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridUndefinedHeight.java @@ -0,0 +1,40 @@ +package com.vaadin.tests.components.grid; + +import com.vaadin.annotations.Theme; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.grid.HeightMode; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Grid; +import com.vaadin.ui.VerticalLayout; + +@Theme("valo") +public class GridUndefinedHeight extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + + final Grid grid = new Grid(); + grid.addColumn("toString", String.class); + grid.addRow("Foo"); + grid.addRow("Bar"); + grid.addRow("Baz"); + grid.setHeightMode(HeightMode.UNDEFINED); + + layout.addComponents(grid, + new Button("Add header row", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + grid.appendHeaderRow(); + } + })); + layout.setHeight("600px"); + layout.setExpandRatio(grid, 1.0f); + + addComponent(layout); + } + +}
\ No newline at end of file diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridUndefinedHeightTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridUndefinedHeightTest.java new file mode 100644 index 0000000000..19ca8c9f88 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridUndefinedHeightTest.java @@ -0,0 +1,47 @@ +package com.vaadin.tests.components.grid; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.GridElement; +import com.vaadin.testbench.parallel.TestCategory; +import com.vaadin.tests.tb3.SingleBrowserTest; + +@TestCategory("grid") +public class GridUndefinedHeightTest extends SingleBrowserTest { + + @Before + public void before() { + setDebug(true); + openTestURL(); + } + + @Test + public void grid_undefined_height() { + GridElement grid = $(GridElement.class).first(); + int oneRow = grid.getRow(0).getSize().getHeight(); + int gridHeight = grid.getSize().getHeight(); + int rows = 4; // Header Row + 3 Body Rows + + Assert.assertEquals("Grid height mismatch", oneRow * rows, gridHeight, 1); + + assertNoErrorNotifications(); + } + + @Test + public void grid_undefined_height_add_header() { + // Add header row to Grid + $(ButtonElement.class).first().click(); + + GridElement grid = $(GridElement.class).first(); + int oneRow = grid.getRow(0).getSize().getHeight(); + int gridHeight = grid.getSize().getHeight(); + int rows = 5; // 2 Header Rows + 3 Body Rows + + Assert.assertEquals("Grid height mismatch", oneRow * rows, gridHeight); + + assertNoErrorNotifications(); + } +}
\ No newline at end of file |