diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-11-16 11:19:09 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-11-18 12:28:58 +0000 |
commit | 848feaaf30762204cb4d9c7bf8b76fbb8bb675da (patch) | |
tree | 510e6c209096d85257f2be388fe44094ab59726a /uitest | |
parent | 9d6baef98851d0cd5092581f954f9b3ee6908003 (diff) | |
download | vaadin-framework-848feaaf30762204cb4d9c7bf8b76fbb8bb675da.tar.gz vaadin-framework-848feaaf30762204cb4d9c7bf8b76fbb8bb675da.zip |
Add HTML/Component support to Grid Footers
Change-Id: Iaffe3214163f66c0617a5bea4b79f4ae39d0bc08
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java | 15 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridHeaderFooterTest.java | 69 |
2 files changed, 77 insertions, 7 deletions
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 59368b198b..7b48acd400 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 @@ -187,7 +187,8 @@ public class GridBasics extends AbstractTestUIWithLog { new ProgressBarRenderer()).setCaption(COLUMN_CAPTIONS[7]); ((SingleSelectionModel<DataObject>) grid.getSelectionModel()) - .addSelectionChangeListener(e -> log("Selected: " + e.getValue())); + .addSelectionChangeListener( + e -> log("Selected: " + e.getValue())); layout.addComponent(createMenu()); layout.addComponent(grid); @@ -244,6 +245,18 @@ public class GridBasics extends AbstractTestUIWithLog { grid.getDefaultHeaderRow().getCell(col).setComponent(button); }); + MenuItem footerTypeMenu = columnMenu.addItem("Footer Type", null); + footerTypeMenu.addItem("Text Footer", selectedItem -> grid + .getFooterRow(0).getCell(col).setText("Text Footer")); + footerTypeMenu.addItem("HTML Footer", + selectedItem -> grid.getFooterRow(0).getCell(col) + .setHtml("<b>HTML Footer</b>")); + footerTypeMenu.addItem("Widget Footer", selectedItem -> { + final Button button = new Button("Button Footer"); + button.addClickListener(clickEvent -> log("Button clicked!")); + grid.getFooterRow(0).getCell(col).setComponent(button); + }); + columnMenu .addItem("Sortable", selectedItem -> col 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 2d0be2a733..bff780ee75 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 @@ -138,9 +138,8 @@ public class GridHeaderFooterTest extends GridBasicsTest { assertFooterTexts(1, GridBasics.COLUMN_CAPTIONS); } - public void testDynamicallyChangingCellType() throws Exception { - openTestURL(); - + @Test + public void testDynamicallyChangingHeaderCellType() throws Exception { selectMenuPath("Component", "Columns", "Column 0", "Header Type", "Widget Header"); GridCellElement widgetCell = getGridElement().getHeaderCell(0, 0); @@ -163,8 +162,6 @@ public class GridHeaderFooterTest extends GridBasicsTest { @Test public void testButtonInHeader() throws Exception { - openTestURL(); - selectMenuPath("Component", "Columns", "Column 1", "Header Type", "Widget Header"); @@ -176,7 +173,6 @@ public class GridHeaderFooterTest extends GridBasicsTest { @Test public void testRemoveComponentFromHeader() throws Exception { - openTestURL(); selectMenuPath("Component", "Columns", "Column 1", "Header Type", "Widget Header"); selectMenuPath("Component", "Columns", "Column 1", "Header Type", @@ -203,6 +199,67 @@ public class GridHeaderFooterTest extends GridBasicsTest { assertEquals("Column 1", getColumnHidingToggle(1).getText()); } + @Test + public void testDynamicallyChangingFooterCellType() throws Exception { + selectMenuPath("Component", "Columns", "Column 0", "Footer Type", + "Widget Footer"); + GridCellElement widgetCell = getGridElement().getFooterCell(0, 0); + assertTrue(widgetCell.isElementPresent(By.className("v-button"))); + + selectMenuPath("Component", "Columns", "Column 1", "Footer Type", + "HTML Footer"); + GridCellElement htmlCell = getGridElement().getFooterCell(0, 1); + assertEquals("<b>HTML Footer</b>", + htmlCell.findElement( + By.className("v-grid-column-footer-content")) + .getAttribute("innerHTML")); + + selectMenuPath("Component", "Columns", "Column 2", "Footer Type", + "Text Footer"); + GridCellElement textCell = getGridElement().getFooterCell(0, 2); + + assertEquals("text footer", textCell.getText().toLowerCase()); + } + + @Test + public void testButtonInFooter() throws Exception { + selectMenuPath("Component", "Columns", "Column 1", "Footer Type", + "Widget Footer"); + + getGridElement().findElements(By.className("v-button")).get(0).click(); + + assertTrue("Button click should be logged", + logContainsText("Button clicked!")); + } + + @Test + public void testRemoveComponentFromFooter() throws Exception { + selectMenuPath("Component", "Columns", "Column 1", "Footer Type", + "Widget Footer"); + selectMenuPath("Component", "Columns", "Column 1", "Footer Type", + "Text Footer"); + assertTrue("No notifications should've been shown", + !$(NotificationElement.class).exists()); + assertEquals("Footer should've been reverted back to text footer", + "text footer", + getGridElement().getFooterCell(0, 1).getText().toLowerCase()); + } + + @Test + public void testColumnHidingToggleCaption_settingWidgetToFooter_toggleCaptionStays() { + toggleColumnHidable(1); + getSidebarOpenButton().click(); + assertEquals("column 1", + getGridElement().getHeaderCell(0, 1).getText().toLowerCase()); + assertEquals("Column 1", getColumnHidingToggle(1).getText()); + + selectMenuPath("Component", "Columns", "Column 1", "Footer Type", + "Widget Footer"); + + getSidebarOpenButton().click(); + assertEquals("Column 1", getColumnHidingToggle(1).getText()); + } + private void toggleColumnHidable(int index) { selectMenuPath("Component", "Columns", "Column " + index, "Hidable"); } |