aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAleksi Hietanen <aleksi@vaadin.com>2017-03-27 11:10:37 +0300
committerPekka Hyvönen <pekka@vaadin.com>2017-03-27 11:10:37 +0300
commit9b7d34fc41c0e088069455639cca2f32750291f6 (patch)
tree1c05c2a6c7abbf177818c2aba507c8e780fa592f /uitest
parente091687db42991012ee477e662fb844e54c1c419 (diff)
downloadvaadin-framework-9b7d34fc41c0e088069455639cca2f32750291f6.tar.gz
vaadin-framework-9b7d34fc41c0e088069455639cca2f32750291f6.zip
Fix infinite loop in data communication (#8927)
* Fix infinite loop in data communication * Switch to less aggressive reset when data communication is out of sync * Remove triggering of reset if reset is already being performed * Avoid redundant collection of streams in DataCommunicator
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/DataCommunicatorInfiniteLoop.java62
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/DataCommunicatorInfiniteLoopTest.java16
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);
+ }
+}