]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixes test issues preventing it from passing
authorArtur Signell <artur@vaadin.com>
Tue, 22 Oct 2013 20:24:44 +0000 (23:24 +0300)
committerVaadin Code Review <review@vaadin.com>
Wed, 23 Oct 2013 13:06:25 +0000 (13:06 +0000)
Ensure push is enabled correctly without a fallback and made test more stable

Change-Id: I6c653a96375e05c6ad18e1f5b697c6a584c6c53f

uitest/src/com/vaadin/tests/push/PushLargeData.java
uitest/src/com/vaadin/tests/push/PushLargeDataStreaming.java
uitest/src/com/vaadin/tests/push/PushLargeDataStreamingTest.java
uitest/src/com/vaadin/tests/push/PushLargeDataWebsocket.java
uitest/src/com/vaadin/tests/push/PushLargeDataWebsocketTest.java
uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java

index 8ad005df810a07a2970f881f69020e0793f7bd85..1a9bf16de65a4247baca0bac91440475f7c54c48 100644 (file)
@@ -34,6 +34,18 @@ import com.vaadin.ui.UI;
 
 public abstract class PushLargeData extends AbstractTestUIWithLog {
 
+    // 1MB
+    static final int DEFAULT_SIZE_BYTES = 1000 * 1000;
+
+    // Every other second
+    static final int DEFAULT_DELAY_MS = 2000;
+
+    // 20 MB is enough for streaming to reconnect
+    static final int DEFAULT_DATA_TO_PUSH = 20 * 1000 * 1000;
+
+    static final int DEFAULT_DURATION_MS = DEFAULT_DATA_TO_PUSH
+            / DEFAULT_SIZE_BYTES * DEFAULT_DELAY_MS;
+
     private Label dataLabel = new Label();
 
     private final ExecutorService executor = Executors
@@ -49,9 +61,9 @@ public abstract class PushLargeData extends AbstractTestUIWithLog {
         final TextField duration = new TextField("Duration (ms)");
         duration.setConverter(Integer.class);
 
-        dataSize.setValue((1000 * 1000) + "");
-        interval.setValue(2000 + "");
-        duration.setValue(40 * 1000 + "");
+        dataSize.setValue(DEFAULT_SIZE_BYTES + "");
+        interval.setValue(DEFAULT_DELAY_MS + "");
+        duration.setValue(DEFAULT_DURATION_MS + "");
 
         addComponent(dataSize);
         addComponent(interval);
index 464cbcc75707fde534c0feab8a2c91789ec3e976..7706aa90c6b9e7a33d33a4aa3dc9340790afaee1 100644 (file)
  */
 package com.vaadin.tests.push;
 
+import com.vaadin.annotations.Push;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.shared.ui.ui.Transport;
+import com.vaadin.shared.ui.ui.UIState.PushConfigurationState;
 
+@Push(transport = Transport.STREAMING)
 public class PushLargeDataStreaming extends PushLargeData {
 
     @Override
     protected void setup(VaadinRequest request) {
         super.setup(request);
         getPushConfiguration().setTransport(Transport.STREAMING);
-        getPushConfiguration().setFallbackTransport(Transport.STREAMING);
+        getPushConfiguration().setParameter(
+                PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none");
     }
 }
index c716a6fc7e0e79b3fe51c924122ffdf3fa0067a9..8f10f0fbbad416c1309956f7036aa983030dc9cf 100644 (file)
@@ -19,12 +19,12 @@ import org.junit.Test;
 import org.openqa.selenium.By;
 import org.openqa.selenium.support.ui.ExpectedConditions;
 
-import com.vaadin.tests.tb3.WebsocketTest;
+import com.vaadin.tests.tb3.MultiBrowserTest;
 
-public class PushLargeDataStreamingTest extends WebsocketTest {
+public class PushLargeDataStreamingTest extends MultiBrowserTest {
 
     @Test
-    public void testWebsocketLargeData() {
+    public void testStreamingLargeData() {
         openTestURL();
 
         // Without this there is a large chance that we will wait for all pushes
@@ -39,17 +39,23 @@ public class PushLargeDataStreamingTest extends WebsocketTest {
     }
 
     private void push() {
+        // Wait for startButton to be present
+        waitForElementToBePresent(vaadinLocatorById("startButton"));
+
         String logRow0Id = "Log_row_0";
         By logRow0 = vaadinLocatorById(logRow0Id);
 
         vaadinElementById("startButton").click();
-        waitUntil(ExpectedConditions.not(ExpectedConditions
-                .textToBePresentInElement(logRow0, "Push complete")));
+        // Wait for push to start
+        waitUntil(ExpectedConditions.textToBePresentInElement(logRow0,
+                "Package "));
 
-        // Pushes each 2000ms for 40s
-        sleep(40000);
+        // Wait for until push should be done
+        sleep(PushLargeData.DEFAULT_DURATION_MS);
 
+        // Wait until push is actually done
         waitUntil(ExpectedConditions.textToBePresentInElement(logRow0,
                 "Push complete"));
     }
+
 }
index 974dc880f9ca05f9f7e5b98d1bbfc64faa3c92db..4115a825d119e3254ac8eae3fdb4081a54906c09 100644 (file)
@@ -19,14 +19,15 @@ package com.vaadin.tests.push;
 import com.vaadin.annotations.Push;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.shared.ui.ui.Transport;
+import com.vaadin.shared.ui.ui.UIState.PushConfigurationState;
 
-@Push
+@Push(transport = Transport.WEBSOCKET)
 public class PushLargeDataWebsocket extends PushLargeData {
 
     @Override
     protected void setup(VaadinRequest request) {
         super.setup(request);
-        getPushConfiguration().setTransport(Transport.WEBSOCKET);
-        getPushConfiguration().setFallbackTransport(Transport.WEBSOCKET);
+        getPushConfiguration().setParameter(
+                PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none");
     }
 }
index 83f9efc8dd53cce71c36924bf247781973c0c17b..70a94f743e5fd2567633b426c9c654a0e75699ec 100644 (file)
@@ -39,17 +39,21 @@ public class PushLargeDataWebsocketTest extends WebsocketTest {
     }
 
     private void push() {
+        // Wait for startButton to be present
+        waitForElementToBePresent(vaadinLocatorById("startButton"));
+
         String logRow0Id = "Log_row_0";
         By logRow0 = vaadinLocatorById(logRow0Id);
 
-        testBench(driver).waitForVaadin();
         vaadinElementById("startButton").click();
-        waitUntil(ExpectedConditions.not(ExpectedConditions
-                .textToBePresentInElement(logRow0, "Push complete")));
+        // Wait for push to start
+        waitUntil(ExpectedConditions.textToBePresentInElement(logRow0,
+                "Package"));
 
-        // Pushes each 2000ms for 40s
-        sleep(40000);
+        // Wait for until push should be done
+        sleep(PushLargeData.DEFAULT_DURATION_MS);
 
+        // Wait until push is actually done
         waitUntil(ExpectedConditions.textToBePresentInElement(logRow0,
                 "Push complete"));
     }
index 712ef9439701bac7ad221b4d2926a666cd2df186..218c532bebf38fc61aa8238f34994c26e961fdab 100644 (file)
@@ -328,6 +328,11 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
         new WebDriverWait(driver, 10).until(ExpectedConditions.not(condition));
     }
 
+    protected void waitForElementToBePresent(By by) {
+        waitUntil(ExpectedConditions.not(ExpectedConditions
+                .invisibilityOfElementLocated(by)));
+    }
+
     /**
      * For tests extending {@link AbstractTestUIWithLog}, returns the element
      * for the Nth log row