diff options
author | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2017-04-19 14:27:13 +0300 |
---|---|---|
committer | Aleksi Hietanen <aleksi@vaadin.com> | 2017-04-19 14:27:13 +0300 |
commit | 8b95318c6c700c946478567193cb0e3040c1dad2 (patch) | |
tree | 64730e6bc737cd1259c78d22cc3a71d62b1fdc16 /uitest | |
parent | 7d1b06cbc4dd07b8b40fbc63d148027fd4c9cf4b (diff) | |
download | vaadin-framework-8b95318c6c700c946478567193cb0e3040c1dad2.tar.gz vaadin-framework-8b95318c6c700c946478567193cb0e3040c1dad2.zip |
Fix issues in Grid with undefined height (#9104)
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/components/grid/GridUndefinedHeight.java | 39 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/grid/GridUndefinedHeightTest.java | 74 |
2 files changed, 113 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..77480b3eef --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridUndefinedHeight.java @@ -0,0 +1,39 @@ +package com.vaadin.tests.components.grid; + +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.Grid; +import com.vaadin.ui.VerticalLayout; + +public class GridUndefinedHeight extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + + Grid<String> grid = new Grid<>(); + grid.setItems("Foo", "Bar", "Baz"); + grid.setHeightMode(HeightMode.UNDEFINED); + grid.addColumn(Object::toString).setCaption("toString()"); + + com.vaadin.v7.ui.Grid oldGrid = new com.vaadin.v7.ui.Grid(); + oldGrid.addColumn("toString", String.class); + oldGrid.addRow("Foo"); + oldGrid.addRow("Bar"); + oldGrid.addRow("Baz"); + oldGrid.setHeightMode( + com.vaadin.v7.shared.ui.grid.HeightMode.UNDEFINED); + + layout.addComponents(grid, oldGrid, new Button("Add header row", e -> { + grid.appendHeaderRow(); + oldGrid.appendHeaderRow(); + })); + layout.setHeight("600px"); + layout.setExpandRatio(grid, 1.0f); + layout.setExpandRatio(oldGrid, 1.0f); + addComponent(layout); + } + +} 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..07ccf6a95b --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridUndefinedHeightTest.java @@ -0,0 +1,74 @@ +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); + + assertNoErrorNotifications(); + } + + @Test + public void gridv7_undefined_height() { + GridElement grid = $(GridElement.class).get(1); + 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); + + 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(); + } + + @Test + public void gridv7_undefined_height_add_header() { + // Add header row to Grid + $(ButtonElement.class).first().click(); + + GridElement grid = $(GridElement.class).get(1); + 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(); + } +} |