aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2016-10-18 17:31:37 +0300
committerTeemu Suo-Anttila <teemusa@vaadin.com>2016-10-19 11:32:25 +0000
commit5bc6d1802e2da2c600fb8559474e86ec1b3b4bf7 (patch)
treea94fe6dfff1074069633f34ad8788f28a9730016 /uitest/src
parent5fc90cda4c27402414fd31c1b87194968321a2fa (diff)
downloadvaadin-framework-5bc6d1802e2da2c600fb8559474e86ec1b3b4bf7.tar.gz
vaadin-framework-5bc6d1802e2da2c600fb8559474e86ec1b3b4bf7.zip
Implement basic footer support for Grid
Change-Id: I3db51521320767a28bc3acd9586b1453764a15bc
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java31
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridHeaderFooterTest.java60
2 files changed, 83 insertions, 8 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 9fce271c6d..f56767e3d3 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
@@ -20,6 +20,7 @@ import com.vaadin.ui.Component;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Grid.Column;
import com.vaadin.ui.Grid.DetailsGenerator;
+import com.vaadin.ui.Grid.FooterRow;
import com.vaadin.ui.Grid.HeaderRow;
import com.vaadin.ui.Label;
import com.vaadin.ui.MenuBar;
@@ -199,6 +200,7 @@ public class GridBasics extends AbstractReindeerTestUIWithLog {
createDetailsMenu(componentMenu.addItem("Details", null));
createBodyMenu(componentMenu.addItem("Body rows", null));
createHeaderMenu(componentMenu.addItem("Header", null));
+ createFooterMenu(componentMenu.addItem("Footer", null));
createColumnsMenu(componentMenu.addItem("Columns", null));
return menu;
}
@@ -409,6 +411,35 @@ public class GridBasics extends AbstractReindeerTestUIWithLog {
});
}
+ private void createFooterMenu(MenuItem footerMenu) {
+ footerMenu.addItem("Add default footer row", menuItem -> {
+ FooterRow defaultFooter = grid.appendFooterRow();
+ grid.getColumns().forEach(
+ column -> defaultFooter.getCell(column).setText(grid
+ .getDefaultHeaderRow().getCell(column).getText()));
+ footerMenu.removeChild(menuItem);
+ });
+ footerMenu.addItem("Append footer row", menuItem -> {
+ FooterRow row = grid.appendFooterRow();
+
+ int i = 0;
+ for (Column<?, ?> column : grid.getColumns()) {
+ row.getCell(column).setText("Footer cell " + i++);
+ }
+ });
+ footerMenu.addItem("Prepend footer row", menuItem -> {
+ FooterRow row = grid.prependFooterRow();
+
+ int i = 0;
+ for (Column<?, ?> column : grid.getColumns()) {
+ row.getCell(column).setText("Footer cell " + i++);
+ }
+ });
+ footerMenu.addItem("Remove first footer row", menuItem -> {
+ grid.removeFooterRow(0);
+ });
+ }
+
/* DetailsGenerator related things */
private void createDetailsMenu(MenuItem detailsMenu) {
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 5b594a980d..681da7443f 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
@@ -31,8 +31,18 @@ public class GridHeaderFooterTest extends GridBasicsTest {
protected static final String[] HEADER_TEXTS = IntStream
.range(0, GridBasics.COLUMN_CAPTIONS.length)
- .mapToObj(i -> "Header cell " + i)
- .toArray(String[]::new);
+ .mapToObj(i -> "Header cell " + i).toArray(String[]::new);
+
+ protected static final String[] FOOTER_TEXTS = IntStream
+ .range(0, GridBasics.COLUMN_CAPTIONS.length)
+ .mapToObj(i -> "Footer cell " + i).toArray(String[]::new);
+
+ @Override
+ public void setUp() {
+ super.setUp();
+
+ selectMenuPath("Component", "Footer", "Add default footer row");
+ }
@Test
public void initialState_defaultHeaderPresent() {
@@ -103,16 +113,40 @@ public class GridHeaderFooterTest extends GridBasicsTest {
assertNoSortIndicator(headerCell, "sort-desc");
}
+ @Test
+ public void initialState_defaultFooterPresent() {
+ assertEquals(1, getGridElement().getFooterCount());
+ assertFooterTexts(0, GridBasics.COLUMN_CAPTIONS);
+ }
+
+ @Test
+ public void appendFooterRow_addedToBottom() {
+ selectMenuPath("Component", "Footer", "Append footer row");
+
+ assertEquals(2, getGridElement().getFooterCount());
+ assertFooterTexts(0, GridBasics.COLUMN_CAPTIONS);
+ assertFooterTexts(1, FOOTER_TEXTS);
+ }
+
+ @Test
+ public void prependFooterRow_addedToTop() {
+ selectMenuPath("Component", "Footer", "Prepend footer row");
+
+ assertEquals(2, getGridElement().getFooterCount());
+ assertFooterTexts(0, FOOTER_TEXTS);
+ assertFooterTexts(1, GridBasics.COLUMN_CAPTIONS);
+ }
+
protected static void assertText(String expected, GridCellElement e) {
// TBE.getText returns "" if the element is scrolled out of view
- String actual = e.findElement(By.tagName("div")).getAttribute(
- "innerHTML");
+ String actual = e.findElement(By.tagName("div"))
+ .getAttribute("innerHTML");
assertEquals(expected, actual);
}
protected void assertHeaderTexts(int rowIndex, String[] texts) {
- List<GridCellElement> headerCells = getGridElement().getHeaderCells(
- rowIndex);
+ List<GridCellElement> headerCells = getGridElement()
+ .getHeaderCells(rowIndex);
assertEquals(texts.length, headerCells.size());
for (int i = 0; i < headerCells.size(); i++) {
@@ -120,9 +154,19 @@ public class GridHeaderFooterTest extends GridBasicsTest {
}
}
+ protected void assertFooterTexts(int rowIndex, String[] texts) {
+ List<GridCellElement> footerCells = getGridElement()
+ .getFooterCells(rowIndex);
+
+ assertEquals(texts.length, footerCells.size());
+ for (int i = 0; i < footerCells.size(); i++) {
+ assertText(texts[i], footerCells.get(i));
+ }
+ }
+
protected void assertSortIndicator(GridCellElement cell, String classname) {
- assertTrue("Header cell should have sort indicator " + classname, cell
- .getAttribute("class").contains(classname));
+ assertTrue("Header cell should have sort indicator " + classname,
+ cell.getAttribute("class").contains(classname));
}
protected void assertNoSortIndicator(GridCellElement cell,