diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2019-05-20 09:35:49 +0300 |
---|---|---|
committer | Sun Zhe <31067185+ZheSun88@users.noreply.github.com> | 2019-05-20 09:35:49 +0300 |
commit | 994f39b9ed46519ca3bfdc8914291e364e44694f (patch) | |
tree | 6f3e41040e88ea962af9ac77b611af2dd6387734 /uitest | |
parent | 4cd5f44e360ec68373d5a1b9b498c5553c04dc26 (diff) | |
download | vaadin-framework-994f39b9ed46519ca3bfdc8914291e364e44694f.tar.gz vaadin-framework-994f39b9ed46519ca3bfdc8914291e364e44694f.zip |
Don't attempt to scroll to the beginning or end if Grid has no rows. (#11570)
Fixes #11558
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/components/grid/GridScrollWithoutRows.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridScrollWithoutRows.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridScrollWithoutRows.java new file mode 100644 index 0000000000..7de07a5b32 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridScrollWithoutRows.java @@ -0,0 +1,61 @@ +package com.vaadin.tests.components.grid; + +import java.util.ArrayList; +import java.util.List; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Grid; +import com.vaadin.ui.Grid.SelectionMode; + +/** + * There is no corresponding TB test as this problem can only be reproduced + * using SuperDevMode. + */ +public class GridScrollWithoutRows extends AbstractTestUI { + + private int counter = 0; + + @Override + protected void setup(VaadinRequest request) { + List<Integer> data = new ArrayList<>(); + + Grid<Integer> grid = new Grid<>(); + grid.addColumn(Integer::valueOf).setCaption("ID").setId("id"); + grid.addColumn(Integer::valueOf).setCaption("FOO").setId("foo"); + grid.setItems(data); + + grid.setSelectionMode(SelectionMode.NONE); + grid.setWidth("250px"); + grid.setHeightByRows(3); + addComponent(grid); + + addComponent(new Button("Add row", e -> { + data.add(counter); + ++counter; + grid.getDataProvider().refreshAll(); + })); + Button beginningButton = new Button("Scroll to beginning", e -> { + grid.scrollToStart(); + }); + beginningButton.setId("beginning"); + addComponent(beginningButton); + Button endButton = new Button("Scroll to end", e -> { + grid.scrollToEnd(); + }); + endButton.setId("end"); + addComponent(endButton); + } + + @Override + protected String getTestDescription() { + return "It should be possible to scroll to beginning or end without assertion errors " + + "even when there are no rows (requires SuperDevMode)."; + } + + @Override + protected Integer getTicketNumber() { + return 11558; + } +} |