From bda7e54cb6eadddf07fb19d88479c642c4831a66 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Fri, 11 Aug 2017 15:27:27 +0300 Subject: Provide API for setting row heights in Grid for different sections (#9810) Fixes #9425 --- .../tests/components/grid/basics/GridBasics.java | 12 ++++++++++++ .../components/grid/basics/GridRowHeightTest.java | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+) (limited to 'uitest') diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java b/uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java index c5b6dbd490..21eb8b502a 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java @@ -539,6 +539,10 @@ public class GridBasics extends AbstractTestUIWithLog { rowMenu.addItem("Deselect all", menuItem -> { grid.getSelectionModel().deselectAll(); }); + + MenuItem rowHeight = rowMenu.addItem("Body Row Height", null); + Stream.of(-1, 20, 50, 100).forEach(i -> rowHeight.addItem("" + i, + menuItem -> grid.setBodyRowHeight(i))); } private void createSelectionMenu(MenuItem stateItem) { @@ -640,6 +644,10 @@ public class GridBasics extends AbstractTestUIWithLog { headerMenu.addItem("Merge Header Cells [0,6..7]", menuItem -> { mergeHeaderСells(0, "6+7", 6, 7); }); + + MenuItem rowHeight = headerMenu.addItem("Header Row Height", null); + Stream.of(-1, 20, 50, 100).forEach(i -> rowHeight.addItem("" + i, + menuItem -> grid.setHeaderRowHeight(i))); } private void mergeHeaderСells(int rowIndex, String jointCellText, @@ -703,6 +711,10 @@ public class GridBasics extends AbstractTestUIWithLog { footerMenu.addItem("Merge Footer Cells [0,6..7]", menuItem -> { mergeFooterСells(0, "6+7", 6, 7); }); + + MenuItem rowHeight = footerMenu.addItem("Footer Row Height", null); + Stream.of(-1, 20, 50, 100).forEach(i -> rowHeight.addItem("" + i, + menuItem -> grid.setFooterRowHeight(i))); } /* DetailsGenerator related things */ diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridRowHeightTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridRowHeightTest.java index 73811bddc7..c99c31d4f7 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridRowHeightTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridRowHeightTest.java @@ -5,6 +5,26 @@ import org.junit.Test; public class GridRowHeightTest extends GridBasicsTest { + @Test + public void testSeparateRowHeights() { + selectMenuPath("Component", "Footer", "Add default footer row"); + + int initialHeaderHeight = getHeaderHeight(); + + Assert.assertNotEquals("Header height should not be 50px initially", 50, + initialHeaderHeight); + + selectMenuPath("Component", "Body rows", "Body Row Height", "" + 100); + selectMenuPath("Component", "Header", "Header Row Height", "" + 20); + selectMenuPath("Component", "Footer", "Footer Row Height", "" + 50); + + checkRowHeights(20, 100, 50); + + selectMenuPath("Component", "Header", "Header Row Height", "" + -1); + + checkRowHeights(initialHeaderHeight, 100, 50); + } + @Test public void testRowHeights() { selectMenuPath("Component", "Footer", "Add default footer row"); -- cgit v1.2.3