summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorelmot <elmot@vaadin.com>2016-11-23 12:30:54 +0200
committerIlia Motornyi <elmot@vaadin.com>2016-11-29 12:09:55 +0000
commit5eaac7ac6e18f9eda7e083617cf07dd631924e0c (patch)
tree46a8cfadbaa75bbf567556f773f809ea2e89d164 /uitest
parent5ab990325f370d767a5ad76b016a852fb2b5330c (diff)
downloadvaadin-framework-5eaac7ac6e18f9eda7e083617cf07dd631924e0c.tar.gz
vaadin-framework-5eaac7ac6e18f9eda7e083617cf07dd631924e0c.zip
Grid merging footer cells
Change-Id: I24895c7ae602ffc9a7812dcc441e99ac670356e2
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java19
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridHeaderFooterTest.java63
2 files changed, 78 insertions, 4 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 4f36eb6207..a39ff27e88 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
@@ -547,6 +547,16 @@ public class GridBasics extends AbstractTestUIWithLog {
headerRow.join(toMerge).setText(jointCellText);
}
+ private void mergeFooterСells(int rowIndex, String jointCellText, int... columnIndexes) {
+ FooterRow footerRow = grid.getFooterRow(rowIndex);
+ List<Column<DataObject, ?>> columns = grid.getColumns();
+ Set<Grid.FooterCell> toMerge = new HashSet<>();
+ for (int columnIndex : columnIndexes) {
+ toMerge.add(footerRow.getCell(columns.get(columnIndex)));
+ }
+ footerRow.join(toMerge).setText(jointCellText);
+ }
+
private void createFooterMenu(MenuItem footerMenu) {
footerMenu.addItem("Add default footer row", menuItem -> {
FooterRow defaultFooter = grid.appendFooterRow();
@@ -574,6 +584,15 @@ public class GridBasics extends AbstractTestUIWithLog {
footerMenu.addItem("Remove first footer row", menuItem -> {
grid.removeFooterRow(0);
});
+ footerMenu.addItem("Merge Footer Cells [0,0..1]", menuItem -> {
+ mergeFooterСells(0, "0+1", 0, 1);
+ });
+ footerMenu.addItem("Merge Footer Cells [1,1..3]", menuItem -> {
+ mergeFooterСells(1, "1+2+3", 1, 2, 3);
+ });
+ footerMenu.addItem("Merge Footer Cells [0,6..7]", menuItem -> {
+ mergeFooterСells(0, "6+7", 6, 7);
+ });
}
/* DetailsGenerator related things */
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 94f30fe279..5e2b0eb9f7 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
@@ -265,16 +265,25 @@ public class GridHeaderFooterTest extends GridBasicsTest {
selectMenuPath("Component", "Header", "Append header row");
selectMenuPath("Component", "Header", "Merge Header Cells [0,0..1]");
- GridCellElement c00 = getGridElement().getHeaderCell(0, 0);
- assertEquals("0+1", c00.getText());
- assertEquals("Colspan of cell [0,0]", "2", c00.getAttribute("colspan"));
+ selectMenuPath("Component", "Footer", "Append footer row");
+ selectMenuPath("Component", "Footer", "Merge Footer Cells [0,0..1]");
+
+ checkMergedHeaderFooter();
selectMenuPath("Component", "Columns", "Column 1", "Remove");
selectMenuPath("Component", "Header", "Append header row");
+ selectMenuPath("Component", "Footer", "Append footer row");
+
+ checkHeaderAfterDelete();
+ checkFooterAfterDelete();
+
+ }
+ private void checkHeaderAfterDelete() {
+ GridCellElement c00;
c00 = getGridElement().getHeaderCell(0, 0);
assertEquals("Column 0", c00.getText());
- assertEquals("Colspan of cell [0,0]", "1", c00.getAttribute("colspan"));
+ assertEquals("Colspan of header cell [0,0]", "1", c00.getAttribute("colspan"));
GridCellElement c01 = getGridElement().getHeaderCell(0, 1);
assertEquals("Column 2", c01.getText());
@@ -290,8 +299,33 @@ public class GridHeaderFooterTest extends GridBasicsTest {
GridCellElement c21 = getGridElement().getHeaderCell(2, 1);
assertEquals("Header cell 1", c21.getText());
+ }
+
+ private void checkFooterAfterDelete() {
+ GridCellElement c10;
+ //footer has an invisible first row
+ c10 = getGridElement().getFooterCell(1, 0);
+ assertEquals("Footer cell 0", c10.getText());
+ assertEquals("Colspan of footer cell [0,0]", "1", c10.getAttribute("colspan"));
+ GridCellElement c11 = getGridElement().getFooterCell(1, 1);
+ assertEquals("Footer cell 2", c11.getText());
+ GridCellElement c20 = getGridElement().getFooterCell(2, 0);
+ assertEquals("Footer cell 0", c20.getText());
+
+ GridCellElement c21 = getGridElement().getFooterCell(2, 1);
+ assertEquals("Footer cell 1", c21.getText());
+ }
+
+ private void checkMergedHeaderFooter() {
+ GridCellElement c00 = getGridElement().getHeaderCell(0, 0);
+ assertEquals("0+1", c00.getText());
+ assertEquals("Colspan of header cell [0,0]", "2", c00.getAttribute("colspan"));
+
+ c00 = getGridElement().getFooterCell(0, 0);
+ assertEquals("0+1", c00.getText());
+ assertEquals("Colspan of footer cell [0,0]", "2", c00.getAttribute("colspan"));
}
@Test
@@ -315,6 +349,27 @@ public class GridHeaderFooterTest extends GridBasicsTest {
}
+ @Test
+ public void testFooterMerge() {
+ selectMenuPath("Component", "Footer", "Append footer row");
+ selectMenuPath("Component", "Footer", "Merge Footer Cells [0,0..1]");
+ selectMenuPath("Component", "Footer", "Merge Footer Cells [1,1..3]");
+ selectMenuPath("Component", "Footer", "Merge Footer Cells [0,6..7]");
+
+ GridCellElement mergedCell1 = getGridElement().getFooterCell(0, 0);
+ assertEquals("0+1", mergedCell1.getText());
+ assertEquals("Colspan, cell [0,0]", "2", mergedCell1.getAttribute("colspan"));
+
+ GridCellElement mergedCell2 = getGridElement().getFooterCell(1, 1);
+ assertEquals("1+2+3", mergedCell2.getText());
+ assertEquals("Colspan of cell [1,1]", "3", mergedCell2.getAttribute("colspan"));
+
+ GridCellElement mergedCell3 = getGridElement().getFooterCell(0, 6);
+ assertEquals("6+7", mergedCell3.getText());
+ assertEquals("Colspan of cell [0,6]", "2", mergedCell3.getAttribute("colspan"));
+
+ }
+
private void toggleColumnHidable(int index) {
selectMenuPath("Component", "Columns", "Column " + index, "Hidable");
}