diff options
Diffstat (limited to 'uitest')
2 files changed, 78 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/DataCommunicatorInfiniteLoop.java b/uitest/src/main/java/com/vaadin/tests/components/grid/DataCommunicatorInfiniteLoop.java new file mode 100644 index 0000000000..385a8ef09e --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/DataCommunicatorInfiniteLoop.java @@ -0,0 +1,62 @@ +package com.vaadin.tests.components.grid; + +import java.util.stream.Stream; + +import com.vaadin.data.provider.DataProvider; +import com.vaadin.data.provider.DataProviderListener; +import com.vaadin.data.provider.Query; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.Registration; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Grid; + +public class DataCommunicatorInfiniteLoop extends AbstractTestUI { + + private static class CustomDataProvider + implements DataProvider<String, Void> { + + private boolean sendRealCount = false; + + @Override + public boolean isInMemory() { + return false; + } + + @Override + public int size(Query<String, Void> query) { + if (sendRealCount) { + return 1; + } else { + sendRealCount = true; + return 2; + } + } + + @Override + public Stream<String> fetch(Query<String, Void> query) { + return Stream.of("one item").skip(query.getOffset()); + } + + @Override + public void refreshItem(String item) { + } + + @Override + public void refreshAll() { + } + + @Override + public Registration addDataProviderListener( + DataProviderListener<String> listener) { + return () -> { + }; + } + } + + @Override + protected void setup(VaadinRequest request) { + Grid<String> grid = new Grid<>(new CustomDataProvider()); + grid.addColumn(string -> string); + addComponent(grid); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/DataCommunicatorInfiniteLoopTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/DataCommunicatorInfiniteLoopTest.java new file mode 100644 index 0000000000..b911ad27f9 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/DataCommunicatorInfiniteLoopTest.java @@ -0,0 +1,16 @@ +package com.vaadin.tests.components.grid; + +import org.junit.Test; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class DataCommunicatorInfiniteLoopTest extends SingleBrowserTest { + + @Test + public void grid_does_not_get_stuck_in_infinite_loop() { + openTestURL(); + waitUntil(driver -> driver.findElement(By.className("v-grid-body")) + .findElements(By.className("v-grid-row")).size() == 1); + } +} |