From 7cf466fa7f0a1fbf48664a6c8211809f9932a997 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Tue, 1 Aug 2017 11:41:39 +0300 Subject: Add header and footer visibility setting to Grid (#9706) --- .../tests/components/grid/basics/GridBasics.java | 6 ++++++ .../grid/basics/GridHeaderFooterTest.java | 24 ++++++++++++++++++++++ 2 files changed, 30 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 944f729efe..c5b6dbd490 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 @@ -603,6 +603,9 @@ public class GridBasics extends AbstractTestUIWithLog { } private void createHeaderMenu(MenuItem headerMenu) { + headerMenu.addItem("Toggle header visibility", + menuitem -> grid.setHeaderVisible(!grid.isHeaderVisible())); + headerMenu.addItem("Append header row", menuItem -> { HeaderRow row = grid.appendHeaderRow(); @@ -662,6 +665,9 @@ public class GridBasics extends AbstractTestUIWithLog { } private void createFooterMenu(MenuItem footerMenu) { + footerMenu.addItem("Toggle footer visibility", + menuitem -> grid.setFooterVisible(!grid.isFooterVisible())); + footerMenu.addItem("Add default footer row", menuItem -> { FooterRow defaultFooter = grid.appendFooterRow(); grid.getColumns().forEach( diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridHeaderFooterTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridHeaderFooterTest.java index 45dba45954..b7ba76ea73 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridHeaderFooterTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridHeaderFooterTest.java @@ -380,6 +380,30 @@ public class GridHeaderFooterTest extends GridBasicsTest { } + @Test + public void testHideAndShowHeader() { + assertEquals("There should be one header row", 1, + getGridElement().getHeaderCount()); + selectMenuPath("Component", "Header", "Toggle header visibility"); + assertEquals("There should be no header rows", 0, + getGridElement().getHeaderCount()); + selectMenuPath("Component", "Header", "Toggle header visibility"); + assertEquals("There should be one header row again", 1, + getGridElement().getHeaderCount()); + } + + @Test + public void testHideAndShowFooter() { + assertEquals("There should be one footer row", 1, + getGridElement().getFooterCount()); + selectMenuPath("Component", "Footer", "Toggle footer visibility"); + assertEquals("There should be no footer rows", 0, + getGridElement().getFooterCount()); + selectMenuPath("Component", "Footer", "Toggle footer visibility"); + assertEquals("There should be one footer row again", 1, + getGridElement().getFooterCount()); + } + private void toggleColumnHidable(int index) { selectMenuPath("Component", "Columns", "Column " + index, "Hidable"); } -- cgit v1.2.3