diff options
author | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2018-05-04 14:53:21 +0300 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2018-05-04 14:53:21 +0300 |
commit | 7aa9c79617009e6b33b710873ebdbddd9b91a463 (patch) | |
tree | a1bc5db9f27f32aeabb00104855841f592c71a37 /uitest | |
parent | a50b5d5fcd55fe0bf0241c77d040ebfd65baa233 (diff) | |
download | vaadin-framework-7aa9c79617009e6b33b710873ebdbddd9b91a463.tar.gz vaadin-framework-7aa9c79617009e6b33b710873ebdbddd9b91a463.zip |
Fix Grid initial data when changing TabSheet Tab (#10872)
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/components/grid/GridInTabSheet.java | 27 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/grid/GridInTabSheetTest.java | 17 |
2 files changed, 41 insertions, 3 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridInTabSheet.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridInTabSheet.java index e04f25262e..e50aa9759b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridInTabSheet.java +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridInTabSheet.java @@ -5,25 +5,46 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; import java.util.stream.IntStream; +import com.vaadin.annotations.Widgetset; import com.vaadin.data.ValueProvider; import com.vaadin.data.provider.DataProvider; import com.vaadin.data.provider.ListDataProvider; import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractReindeerTestUI; +import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Grid; import com.vaadin.ui.Grid.SelectionMode; import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; import com.vaadin.ui.renderers.NumberRenderer; -public class GridInTabSheet extends AbstractReindeerTestUI { +@Widgetset("com.vaadin.DefaultWidgetSet") +public class GridInTabSheet extends AbstractTestUIWithLog { + + public class DataCommunicator<T> + extends com.vaadin.data.provider.DataCommunicator<T> { + @Override + protected void onRequestRows(int firstRowIndex, int numberOfRows, + int firstCachedRowIndex, int cacheSize) { + log("RequestRows: [" + firstRowIndex + "," + numberOfRows + "," + + firstCachedRowIndex + "," + cacheSize + "]"); + super.onRequestRows(firstRowIndex, numberOfRows, + firstCachedRowIndex, cacheSize); + } + } + + public class Grid<T> extends com.vaadin.ui.Grid<T> { + + public Grid() { + super(new DataCommunicator<>()); + } + } private AtomicInteger index = new AtomicInteger(0); @Override protected void setup(VaadinRequest request) { TabSheet sheet = new TabSheet(); + final Grid<Integer> grid = new Grid<>(); grid.setSelectionMode(SelectionMode.MULTI); grid.addColumn(ValueProvider.identity(), new NumberRenderer()) diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridInTabSheetTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridInTabSheetTest.java index e20ec622c7..785bda8261 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridInTabSheetTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridInTabSheetTest.java @@ -2,6 +2,8 @@ package com.vaadin.tests.components.grid; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; import org.junit.Test; @@ -68,6 +70,21 @@ public class GridInTabSheetTest extends MultiBrowserTest { assertNoNotification(); } + @Test + public void testNoDataRequestFromClientWhenSwitchingTab() { + setDebug(true); + openTestURL(); + + TabSheetElement tabsheet = $(TabSheetElement.class).first(); + tabsheet.openTab("Label"); + tabsheet.openTab("Grid"); + + getLogs().forEach(logText -> assertTrue( + "There should be no logged requests, was: " + logText, + logText.trim().isEmpty())); + assertNoNotification(); + } + private void removeGridRow() { $(ButtonElement.class).caption("Remove row from Grid").first().click(); } |