aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcaalador <mikael.grankvist@gmail.com>2017-02-08 14:54:57 +0200
committerPekka Hyvönen <pekka@vaadin.com>2017-02-08 14:54:57 +0200
commit0f97714b635174e4eabfbb5a708ffb366bfcadb4 (patch)
tree30d60c762928bd276a76db3c7540c0eaf466f448
parente345f53937c2d98bf14d278ba178e6008fd16504 (diff)
downloadvaadin-framework-0f97714b635174e4eabfbb5a708ffb366bfcadb4.tar.gz
vaadin-framework-0f97714b635174e4eabfbb5a708ffb366bfcadb4.zip
Fix removing and adding a column in grid (#8437)
* Added column should also be added to footer (#590) When adding (readding) a column the column should also be added to footer as it will be removed and iterator will request footer for it. * Add test for re-add column (#590) * To lowerCase using Locale * Fixed compilation problem. Too little sleep for a friday evening...
-rw-r--r--server/src/main/java/com/vaadin/ui/Grid.java1
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridColspans.java2
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridColspansTest.java38
3 files changed, 32 insertions, 9 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java
index 60dc623374..5132229ec8 100644
--- a/server/src/main/java/com/vaadin/ui/Grid.java
+++ b/server/src/main/java/com/vaadin/ui/Grid.java
@@ -2211,6 +2211,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
getState().columnOrder.add(identifier);
getHeader().addColumn(identifier);
+ getFooter().addColumn(identifier);
if (getDefaultHeaderRow() != null) {
getDefaultHeaderRow().getCell(column).setText(column.getCaption());
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridColspans.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridColspans.java
index ce29ca3d9e..961e44593a 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridColspans.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridColspans.java
@@ -85,7 +85,7 @@ public class GridColspans extends AbstractTestUI {
if (column != null) {
grid.removeColumn(column);
} else {
- grid.addColumn(Person::getFirstName).setId("firstName");
+ grid.addColumn(Person::getFirstName).setId("firstName").setCaption("First name");
}
}));
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColspansTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColspansTest.java
index 2d0a12187d..27b9e805bd 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColspansTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColspansTest.java
@@ -17,6 +17,7 @@ package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import java.util.Locale;
import org.junit.Before;
import org.junit.Test;
@@ -56,14 +57,35 @@ public class GridColspansTest extends MultiBrowserTest {
GridElement grid = $(GridElement.class).first();
assertEquals("Failed initial condition.", "all the stuff",
- grid.getHeaderCell(0, 1).getText().toLowerCase());
+ grid.getHeaderCell(0, 1).getText().toLowerCase(Locale.ENGLISH));
assertEquals("Failed initial condition.", "first name",
- grid.getHeaderCell(2, 1).getText().toLowerCase());
+ grid.getHeaderCell(2, 1).getText().toLowerCase(Locale.ENGLISH));
$(ButtonElement.class).caption("Show/Hide firstName").first().click();
assertEquals("Header text changed on column hide.", "all the stuff",
- grid.getHeaderCell(0, 1).getText().toLowerCase());
+ grid.getHeaderCell(0, 1).getText().toLowerCase(Locale.ENGLISH));
assertEquals("Failed initial condition.", "last name",
- grid.getHeaderCell(2, 1).getText().toLowerCase());
+ grid.getHeaderCell(2, 1).getText().toLowerCase(Locale.ENGLISH));
+ }
+
+ @Test
+ public void testHideAndReAddFirstCOlumn() {
+ openTestURL();
+
+ GridElement grid = $(GridElement.class).first();
+
+ assertEquals("Failed initial condition.", "first name",
+ grid.getHeaderCell(2, 1).getText().toLowerCase(Locale.ENGLISH));
+
+ $(ButtonElement.class).caption("Show/Hide firstName").first().click();
+
+ assertEquals("Failed initial condition.", "last name",
+ grid.getHeaderCell(2, 1).getText().toLowerCase(Locale.ENGLISH));
+
+ $(ButtonElement.class).caption("Show/Hide firstName").first().click();
+
+ assertEquals("Failed to find first name in last column", "first name",
+ grid.getHeaderCell(2, 5).getText().toLowerCase(Locale.ENGLISH));
+
}
@Test
@@ -73,18 +95,18 @@ public class GridColspansTest extends MultiBrowserTest {
GridElement grid = $(GridElement.class).first();
GridCellElement headerCell = grid.getHeaderCell(1, 1);
assertEquals("Failed initial condition.", "full name",
- headerCell.getText().toLowerCase());
+ headerCell.getText().toLowerCase(Locale.ENGLISH));
assertEquals("Failed initial condition.", "first name",
- grid.getHeaderCell(2, 1).getText().toLowerCase());
+ grid.getHeaderCell(2, 1).getText().toLowerCase(Locale.ENGLISH));
$(ButtonElement.class).get(1).click();
headerCell = grid.getHeaderCell(1, 1);
assertEquals("Joined Header text not changed on column reorder.",
- "misc", headerCell.getText().toLowerCase());
+ "misc", headerCell.getText().toLowerCase(Locale.ENGLISH));
assertEquals("Unexpected colspan", "1",
headerCell.getAttribute("colspan"));
headerCell = grid.getHeaderCell(1, 2);
assertEquals("Header text not changed on column reorder", "full name",
- headerCell.getText().toLowerCase());
+ headerCell.getText().toLowerCase(Locale.ENGLISH));
assertEquals("Unexpected colspan", "2",
headerCell.getAttribute("colspan"));