diff options
author | Henri Sara <henri.sara@gmail.com> | 2017-03-29 11:18:07 +0300 |
---|---|---|
committer | Pekka Hyvönen <pekka@vaadin.com> | 2017-03-29 11:18:07 +0300 |
commit | f9a9f2c4be0e38d936acab88cba45799fa83ff4a (patch) | |
tree | 59d2d5bbeb39ce2c942981c112e9a4bd3c6fed8d /uitest | |
parent | 92ccddf4f2465dae1f43e6087ca25ae41cae637d (diff) | |
download | vaadin-framework-f9a9f2c4be0e38d936acab88cba45799fa83ff4a.tar.gz vaadin-framework-f9a9f2c4be0e38d936acab88cba45799fa83ff4a.zip |
Add Grid.setRowHeight() (#8935)
Fixes #8667
Diffstat (limited to 'uitest')
4 files changed, 65 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridComponents.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridComponents.java index 2eb48f7697..1a546a767d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridComponents.java +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridComponents.java @@ -50,6 +50,8 @@ public class GridComponents extends AbstractTestUIWithLog { button.setId(string.replace(' ', '_').toLowerCase()); return button; }, new ComponentRenderer()); + // make sure the buttons and focus outlines fit completely in a row + grid.setRowHeight(40); addComponent(grid); grid.setSizeFull(); 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 4c7283dfcc..944f729efe 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 @@ -382,6 +382,10 @@ public class GridBasics extends AbstractTestUIWithLog { MenuItem heightMenu = sizeMenu.addItem("Height", null); Stream.of(50, 100, 200, 400).map(i -> i + "px").forEach( i -> addGridMethodMenu(heightMenu, i, i, grid::setHeight)); + + MenuItem rowHeightMenu = sizeMenu.addItem("Row Height", null); + Stream.of(-1, 20, 40, 100).forEach(i -> addGridMethodMenu(rowHeightMenu, + String.valueOf(i), (double) i, grid::setRowHeight)); } private void createStateMenu(MenuItem stateMenu) { diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java index 89226c147e..b74386e2d9 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java @@ -72,6 +72,8 @@ public class GridComponentsTest extends MultiBrowserTest { public void testRow0() { openTestURL(); assertRowExists(0, "Row 0"); + Assert.assertEquals("Grid row height is not what it should be", 40, + $(GridElement.class).first().getRow(0).getSize().getHeight()); } @Test 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 new file mode 100644 index 0000000000..73811bddc7 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridRowHeightTest.java @@ -0,0 +1,57 @@ +package com.vaadin.tests.components.grid.basics; + +import org.junit.Assert; +import org.junit.Test; + +public class GridRowHeightTest extends GridBasicsTest { + + @Test + public void testRowHeights() { + selectMenuPath("Component", "Footer", "Add default footer row"); + + int initialHeaderHeight = getHeaderHeight(); + int initialBodyRowHeight = getBodyRowHeight(); + int initialFooterHeight = getFooterHeight(); + + // set automatic size and check that no change + setRowHeight(-1); + checkRowHeights(initialHeaderHeight, initialBodyRowHeight, + initialFooterHeight); + + // set explicit size and check height + setRowHeight(20); + checkRowHeights(20, 20, 20); + + // set automatic size and check that initial size + setRowHeight(-1); + checkRowHeights(initialHeaderHeight, initialBodyRowHeight, + initialFooterHeight); + } + + private void checkRowHeights(int expectedHeaderHeight, + int expectedBodyRowHeight, int expectedFooterHeight) { + Assert.assertEquals("Header height does not match expected value", + expectedHeaderHeight, getHeaderHeight()); + Assert.assertEquals("Body row height does not match expected value", + expectedBodyRowHeight, getBodyRowHeight()); + Assert.assertEquals("Footer height does not match expected value", + expectedFooterHeight, getFooterHeight()); + } + + private void setRowHeight(int height) { + selectMenuPath("Component", "Size", "Row Height", "" + height); + } + + private int getHeaderHeight() { + return getGridElement().getHeader().getSize().getHeight(); + } + + private int getBodyRowHeight() { + return getGridElement().getRow(0).getSize().getHeight(); + } + + private int getFooterHeight() { + return getGridElement().getFooter().getSize().getHeight(); + } + +} |