summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAleksi Hietanen <aleksi@vaadin.com>2017-01-10 14:23:53 +0200
committerGitHub <noreply@github.com>2017-01-10 14:23:53 +0200
commit5e89da2f8a6c457e0c853db55d7443a6abd25aaa (patch)
tree2e18eb49f6ed01ada236613322c92ad0ea9c4f4a /uitest
parent3ef30789d6ac773eed7346dcaa670426fa6f662c (diff)
downloadvaadin-framework-5e89da2f8a6c457e0c853db55d7443a6abd25aaa.tar.gz
vaadin-framework-5e89da2f8a6c457e0c853db55d7443a6abd25aaa.zip
Fix broken method signature of Grid.addColumn (#8180)
Fixes #8129
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridAddColumn.java22
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridAddColumnTest.java68
2 files changed, 90 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridAddColumn.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridAddColumn.java
new file mode 100644
index 0000000000..10fad97259
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridAddColumn.java
@@ -0,0 +1,22 @@
+package com.vaadin.tests.components.grid;
+
+import com.vaadin.data.ValueProvider;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.renderers.NumberRenderer;
+
+public class GridAddColumn extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Grid<String> grid = new Grid<>();
+ grid.addColumn(ValueProvider.identity());
+ grid.addColumn(String::length, new NumberRenderer());
+ grid.addColumn(String::length);
+ grid.addColumn(string -> -string.length());
+ grid.addColumn(string -> new Object());
+ grid.setItems("a", "aa", "aaa");
+ addComponent(grid);
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridAddColumnTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridAddColumnTest.java
new file mode 100644
index 0000000000..f6755d1c31
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridAddColumnTest.java
@@ -0,0 +1,68 @@
+package com.vaadin.tests.components.grid;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.GridElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class GridAddColumnTest extends SingleBrowserTest {
+
+ GridElement grid;
+
+ @Before
+ public void init() {
+ openTestURL();
+ grid = $(GridElement.class).first();
+ }
+
+ @Test
+ public void columns_rendered_correctly() {
+ assertCellEquals(0, 0, "a");
+ assertCellEquals(1, 0, "aa");
+ assertCellEquals(2, 0, "aaa");
+
+ assertCellEquals(0, 1, "1");
+ assertCellEquals(1, 1, "2");
+ assertCellEquals(2, 1, "3");
+
+ assertCellEquals(0, 2, "1");
+ assertCellEquals(1, 2, "2");
+ assertCellEquals(2, 2, "3");
+
+ assertCellEquals(0, 3, "-1");
+ assertCellEquals(1, 3, "-2");
+ assertCellEquals(2, 3, "-3");
+
+ assertCellStartsWith(0, 4, "java.lang.Object@");
+ assertCellStartsWith(1, 4, "java.lang.Object@");
+ assertCellStartsWith(2, 4, "java.lang.Object@");
+ }
+
+ @Test
+ @Ignore // TODO re-enable once #8128 is resolved
+ public void sort_column_with_automatic_conversion() {
+ grid.getHeaderCell(0, 2).click();
+ assertCellEquals(0, 0, "a");
+ assertCellEquals(1, 0, "aa");
+ assertCellEquals(2, 0, "aaa");
+
+ grid.getHeaderCell(0, 3).click();
+ assertCellEquals(0, 0, "aaa");
+ assertCellEquals(1, 0, "aa");
+ assertCellEquals(2, 0, "a");
+ }
+
+ private void assertCellEquals(int rowIndex, int colIndex, String content) {
+ Assert.assertEquals("Cell text should equal", content,
+ grid.getCell(rowIndex, colIndex).getText());
+ }
+
+ private void assertCellStartsWith(int rowIndex, int colIndex,
+ String startsWith) {
+ Assert.assertTrue("Cell text should start with", grid
+ .getCell(rowIndex, colIndex).getText().startsWith(startsWith));
+ }
+}