]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix RpcDataProviderExtension to send initial data on reload (#15465)
authorTeemu Suo-Anttila <teemusa@vaadin.com>
Mon, 29 Dec 2014 14:03:05 +0000 (16:03 +0200)
committerTeemu Suo-Anttila <teemusa@vaadin.com>
Wed, 31 Dec 2014 07:47:29 +0000 (09:47 +0200)
Change-Id: I0a2edc9a9ba1f48299e165d398adf7b73972349f

server/src/com/vaadin/data/RpcDataProviderExtension.java
uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java
uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridStructureTest.java

index 8e119f0d942ef4b3e01be7e922a24e5897223984..e8818aa828c75e8fec93e07c741e51981d77f7db 100644 (file)
@@ -698,7 +698,8 @@ public class RpcDataProviderExtension extends AbstractExtension {
     @Override
     public void beforeClientResponse(boolean initial) {
         super.beforeClientResponse(initial);
-        if (!clientInitialized) {
+
+        if (initial) {
             clientInitialized = true;
 
             /*
index 91dff944cbcd51ff70f9a512a2c7239bc7acd3e2..0e339ec0ae06bc3200747cb43c971d4f17099d9a 100644 (file)
@@ -121,4 +121,15 @@ public abstract class GridBasicFeaturesTest extends MultiBrowserTest {
                 .findElement(
                         By.xpath("//div[contains(@class, \"v-grid-scroller-vertical\")]"));
     }
+
+    /**
+     * Reloads the page without restartApplication. This occasionally breaks
+     * stuff.
+     */
+    protected void reopenTestURL() {
+        String testUrl = getTestUrl();
+        testUrl = testUrl.replace("?restartApplication", "?");
+        testUrl = testUrl.replace("?&", "?");
+        driver.get(testUrl);
+    }
 }
index 9a9f85ccb94d6c1ca1826df80a6aca7e4e4b24eb..97a4fb8f4a9431e6f90158b446860641062ba9f2 100644 (file)
@@ -447,4 +447,32 @@ public class GridStructureTest extends GridBasicFeaturesTest {
         assertEquals("Scroll position should've not have changed", scrollPos,
                 getGridVerticalScrollPos());
     }
+
+    @Test
+    public void testReloadPage() throws InterruptedException {
+        setDebug(true);
+        openTestURL();
+
+        reopenTestURL();
+
+        // After opening the URL Grid can be stuck in a state where it thinks it
+        // should wait for something that's not going to happen.
+        testBench().disableWaitForVaadin();
+
+        // Wait until page is loaded completely.
+        int count = 0;
+        while (!isElementPresent(GridElement.class)) {
+            if (count == 100) {
+                fail("Reloading page failed");
+            }
+            sleep(100);
+            ++count;
+        }
+
+        // Wait a bit more for notification to occur.
+        sleep(1000);
+
+        assertFalse("Exception occurred when reloading page",
+                isElementPresent(NotificationElement.class));
+    }
 }