]> source.dussan.org Git - vaadin-framework.git/commitdiff
Add 'transport' GET parameter to AbstractTestUI (#12094)
authorJohannes Dahlström <johannesd@vaadin.com>
Tue, 18 Jun 2013 09:31:12 +0000 (12:31 +0300)
committerJohannes Dahlström <johannesd@vaadin.com>
Tue, 18 Jun 2013 10:56:57 +0000 (13:56 +0300)
* Value can be 'xhr', 'websocket', or 'streaming'
* xhr disables push even if already enabled
* others set push to automatic if not already set to manual

Change-Id: Iaf929bbb78865fa7d832718841e781e76cdf7277

uitest/src/com/vaadin/tests/components/AbstractTestUI.java

index ec6cf0c57dd970b18312e224381ea12e39e0f954..f567106d60be362101e1965efbee7fc2f4696cea 100644 (file)
@@ -6,11 +6,14 @@ import com.vaadin.annotations.Widgetset;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.server.VaadinServlet;
 import com.vaadin.server.WebBrowser;
+import com.vaadin.shared.communication.PushMode;
 import com.vaadin.shared.ui.label.ContentMode;
+import com.vaadin.shared.ui.ui.Transport;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.Label;
 import com.vaadin.ui.Notification;
 import com.vaadin.ui.Notification.Type;
+import com.vaadin.ui.PushConfiguration;
 import com.vaadin.ui.UI;
 import com.vaadin.ui.VerticalLayout;
 
@@ -35,6 +38,8 @@ public abstract class AbstractTestUI extends UI {
 
         warnIfWidgetsetMaybeNotCompiled();
 
+        setTransport(request);
+
         setup(request);
     }
 
@@ -95,6 +100,26 @@ public abstract class AbstractTestUI extends UI {
         }
     }
 
+    protected void setTransport(VaadinRequest request) {
+        String transport = request.getParameter("transport");
+        PushConfiguration config = getPushConfiguration();
+        PushMode mode = config.getPushMode();
+
+        if ("xhr".equals(transport)) {
+            config.setPushMode(PushMode.DISABLED);
+        } else if ("websocket".equals(transport)) {
+            if (!mode.isEnabled()) {
+                config.setPushMode(PushMode.AUTOMATIC);
+            }
+            config.setTransport(Transport.WEBSOCKET);
+        } else if ("streaming".equals(transport)) {
+            if (!mode.isEnabled()) {
+                config.setPushMode(PushMode.AUTOMATIC);
+            }
+            config.setTransport(Transport.STREAMING);
+        }
+    }
+
     private VerticalLayout layout;
 
     protected VerticalLayout getLayout() {