summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorArtur <artur@vaadin.com>2017-03-06 13:20:35 +0200
committerPekka Hyvönen <pekka@vaadin.com>2017-03-06 13:20:35 +0200
commit42064ade8f01440432792b27ecd16a98f29fb74d (patch)
tree6f6616e856fb8c1d693d45102d8fcdc828f39c32 /uitest
parent2eea115f410b19ae9b387151240921feac7c0db7 (diff)
downloadvaadin-framework-42064ade8f01440432792b27ecd16a98f29fb74d.tar.gz
vaadin-framework-42064ade8f01440432792b27ecd16a98f29fb74d.zip
Fix exception when no columns are shown (#8733)
* Fix exception when no columns are shown or all columns are frozen Fixes #8329
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumns.java8
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/InitialFrozenColumns.java (renamed from uitest/src/main/java/com/vaadin/v7/tests/components/grid/InitialFrozenColumns.java)31
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumnsTest.java20
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/InitialFrozenColumnsTest.java (renamed from uitest/src/test/java/com/vaadin/v7/tests/components/grid/InitialFrozenColumnsTest.java)16
4 files changed, 60 insertions, 15 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumns.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumns.java
index 1c0a662abb..d040aa54f3 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumns.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumns.java
@@ -26,6 +26,7 @@ import com.vaadin.tests.data.bean.Person;
import com.vaadin.tests.util.PortableRandom;
import com.vaadin.tests.util.TestDataGenerator;
import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.Column;
import com.vaadin.ui.renderers.NumberRenderer;
public class GridInitiallyHiddenColumns extends AbstractTestUIWithLog {
@@ -36,8 +37,11 @@ public class GridInitiallyHiddenColumns extends AbstractTestUIWithLog {
grid.addColumn(Person::getFirstName).setHidden(true).setHidable(true)
.setCaption("First Name");
- grid.addColumn(Person::getLastName).setHidable(true)
- .setCaption("Last Name");
+ Column<Person, String> col2 = grid.addColumn(Person::getLastName)
+ .setHidable(true).setCaption("Last Name");
+ if (request.getParameter("allHidden") != null) {
+ col2.setHidden(true);
+ }
grid.addColumn(Person::getAge, new NumberRenderer()).setHidden(true)
.setHidable(true).setCaption("Age");
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/InitialFrozenColumns.java b/uitest/src/main/java/com/vaadin/tests/components/grid/InitialFrozenColumns.java
index 07a41337f2..ec49d24dc1 100644
--- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/InitialFrozenColumns.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/InitialFrozenColumns.java
@@ -13,27 +13,34 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.v7.tests.components.grid;
+package com.vaadin.tests.components.grid;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.v7.ui.Grid;
-import com.vaadin.v7.ui.Grid.SelectionMode;
+import com.vaadin.tests.data.bean.Person;
+import com.vaadin.tests.data.bean.Sex;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.SelectionMode;
public class InitialFrozenColumns extends AbstractReindeerTestUI {
@Override
protected void setup(VaadinRequest request) {
- Grid grid = new Grid();
+ Grid<Person> grid = new Grid<>(Person.class);
grid.setSelectionMode(SelectionMode.NONE);
-
- grid.addColumn("foo").setWidth(200);
- grid.addColumn("bar").setWidth(200);
- grid.addColumn("baz").setWidth(200);
-
- grid.addRow("a", "b", "c");
-
- grid.setFrozenColumnCount(2);
+ grid.setColumns();
+ grid.addColumn("firstName").setWidth(200);
+ grid.addColumn("lastName").setWidth(200);
+ grid.addColumn("email").setWidth(200);
+
+ grid.setItems(
+ new Person("First", "last", "email", 242, Sex.UNKNOWN, null));
+
+ int frozen = 2;
+ if (request.getParameter("frozen") != null) {
+ frozen = Integer.parseInt(request.getParameter("frozen"));
+ }
+ grid.setFrozenColumnCount(frozen);
addComponent(grid);
}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumnsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumnsTest.java
index 017ef14e2b..1a909e7a32 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumnsTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumnsTest.java
@@ -50,6 +50,26 @@ public class GridInitiallyHiddenColumnsTest extends SingleBrowserTest {
}
+ @Test
+ public void ensureCorrectlyRenderedAllInitiallyHidden() {
+ openTestURL("debug&allHidden");
+ GridElement grid = $(GridElement.class).first();
+
+ getSidebarOpenButton(grid).click();
+ getColumnHidingToggle(grid, "First Name").click();
+ getColumnHidingToggle(grid, "Last Name").click();
+ getColumnHidingToggle(grid, "Age").click();
+ getSidebarOpenButton(grid).click();
+
+ Assert.assertEquals("Umberto", grid.getCell(0, 0).getText());
+ Assert.assertEquals("Rowling", grid.getCell(0, 1).getText());
+ Assert.assertEquals("40", grid.getCell(0, 2).getText());
+ Assert.assertEquals("Alex", grid.getCell(1, 0).getText());
+ Assert.assertEquals("Barks", grid.getCell(1, 1).getText());
+ Assert.assertEquals("25", grid.getCell(1, 2).getText());
+
+ }
+
// TODO: as to the getX methods reuse ones from GridBasicFeaturesTest?
protected WebElement getSidebarOpenButton(GridElement grid) {
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/InitialFrozenColumnsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/InitialFrozenColumnsTest.java
index fec0087168..58abe75731 100644
--- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/InitialFrozenColumnsTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/InitialFrozenColumnsTest.java
@@ -13,10 +13,12 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.v7.tests.components.grid;
+package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertTrue;
+import java.util.logging.Level;
+
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.WebElement;
@@ -39,4 +41,16 @@ public class InitialFrozenColumnsTest extends MultiBrowserTest {
WebElement cell = $(GridElement.class).first().getCell(0, 0);
assertTrue(cell.getAttribute("class").contains("frozen"));
}
+
+ @Test
+ public void testInitialAllColumnsFrozen() {
+ setDebug(true);
+ openTestURL("frozen=3");
+
+ Assert.assertFalse("Notification was present",
+ isElementPresent(NotificationElement.class));
+ assertNoDebugMessage(Level.SEVERE);
+ WebElement cell = $(GridElement.class).first().getCell(0, 2);
+ assertTrue(cell.getAttribute("class").contains("frozen"));
+ }
}