diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2018-04-13 18:10:39 +0300 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2018-04-13 18:10:39 +0300 |
commit | 206a4d3146594a1ac1dd84be543e4c1089056560 (patch) | |
tree | 101d98cbaaca9859e032a18d4004059834384d71 /uitest | |
parent | 1719e35ae9377075f26f0daab6e7e2c789186ac0 (diff) | |
download | vaadin-framework-206a4d3146594a1ac1dd84be543e4c1089056560.tar.gz vaadin-framework-206a4d3146594a1ac1dd84be543e4c1089056560.zip |
Add null check to Grid's DnD focus handling (#10822)
Fixes #10699
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/components/grid/GridReorderColumns.java | 58 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/grid/GridReorderColumnsTest.java | 45 |
2 files changed, 103 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridReorderColumns.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridReorderColumns.java new file mode 100644 index 0000000000..792723df2b --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridReorderColumns.java @@ -0,0 +1,58 @@ +package com.vaadin.tests.components.grid; + +import java.util.ArrayList; +import java.util.List; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.data.provider.DataProvider; +import com.vaadin.data.provider.ListDataProvider; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Grid; + +@Widgetset("com.vaadin.DefaultWidgetSet") +public class GridReorderColumns extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + getLayout().setSpacing(true); + + Grid<String> emptyGrid = createGrid(false); + emptyGrid.setId("emptyGrid"); + + Grid<String> contentGrid = createGrid(true); + contentGrid.setId("contentGrid"); + + addComponents(emptyGrid, contentGrid); + } + + private Grid<String> createGrid(boolean includeItem) { + Grid<String> grid = new Grid<>(); + grid.addColumn(t -> t + "1").setCaption("caption1"); + grid.addColumn(t -> t + "2").setCaption("caption2"); + grid.addColumn(t -> t + "3").setCaption("caption3"); + grid.addColumn(t -> t + "4").setCaption("caption4"); + grid.setColumnReorderingAllowed(true); + grid.setHeight("100px"); + + List<String> items = new ArrayList<>(); + if (includeItem) { + items.add("content"); + } + ListDataProvider<String> dataProvider = DataProvider + .ofCollection(items); + grid.setDataProvider(dataProvider); + return grid; + } + + @Override + protected Integer getTicketNumber() { + return 10699; + } + + @Override + protected String getTestDescription() { + return "Column reordering without changing initial focus should complete " + + "without errors on all browsers even if the Grid is empty."; + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridReorderColumnsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridReorderColumnsTest.java new file mode 100644 index 0000000000..f90ed77598 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridReorderColumnsTest.java @@ -0,0 +1,45 @@ +package com.vaadin.tests.components.grid; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.junit.Assert.assertThat; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.elements.GridElement; +import com.vaadin.testbench.elements.GridElement.GridCellElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class GridReorderColumnsTest extends MultiBrowserTest { + + @Test + public void testEmptyGrid() { + openTestURL(); + + testReordering("emptyGrid"); + } + + @Test + public void testContentGrid() { + openTestURL(); + + testReordering("contentGrid"); + } + + private void testReordering(String id) { + GridElement grid = $(GridElement.class).id(id); + GridCellElement headerCell1 = grid.getHeaderCellByCaption("caption1"); + GridCellElement headerCell3 = grid.getHeaderCellByCaption("caption3"); + + assertThat(grid.getHeaderCell(0, 0), is(headerCell1)); + + new Actions(getDriver()).clickAndHold(headerCell1) + .moveToElement(headerCell3, 5, 0).release().perform(); + + waitForElementNotPresent(By.className("dragged-column-header")); + + assertThat(grid.getHeaderCell(0, 0), not(is(headerCell1))); + } +} |