diff options
author | John Ahlroos <john@vaadin.com> | 2013-04-17 11:46:19 +0300 |
---|---|---|
committer | John Ahlroos <john@vaadin.com> | 2013-04-17 14:46:21 +0300 |
commit | 0f75f202d333ac507fb3e5efb8e9bd4d4719e098 (patch) | |
tree | bd19061fbde6c5cf665b0bd4fcefd1c78567800d | |
parent | 1c4adacdc2c59a4dd33633806902cb6224141954 (diff) | |
download | vaadin-framework-0f75f202d333ac507fb3e5efb8e9bd4d4719e098.tar.gz vaadin-framework-0f75f202d333ac507fb3e5efb8e9bd4d4719e098.zip |
Added test for testing push with different transports #11494
Change-Id: I0296bdee1925ba93ca7e4e65c68215e025d072f6
6 files changed, 169 insertions, 9 deletions
diff --git a/build/ide.xml b/build/ide.xml index 5b27488d59..e040dc5c8c 100755 --- a/build/ide.xml +++ b/build/ide.xml @@ -82,8 +82,22 @@ </java> </target> + + <target name="default-widgetset"> - <property name="module" value="com.vaadin.DefaultWidgetSet" /> + <antcall target="compile-widgetset"> + <param name="widgetset" value="com.vaadin.DefaultWidgetSet" /> + </antcall> + </target> + + <target name="testing-widgetset"> + <antcall target="compile-widgetset"> + <param name="widgetset" value="com.vaadin.tests.widgetset.TestingWidgetSet" /> + </antcall> + </target> + + <target name="compile-widgetset"> + <property name="module" value="${widgetset}" /> <property name="module.output.dir" location="WebContent/VAADIN/widgetsets" /> <property name="style" value="PRETTY" /> <property name="localWorkers" value="2" /> @@ -119,6 +133,5 @@ <jvmarg value="-Djava.awt.headless=true" /> <jvmarg value="-Dgwt.usearchives=false" /> </java> - - </target> + </target> </project>
\ No newline at end of file diff --git a/client/src/com/vaadin/client/communication/PushConnection.java b/client/src/com/vaadin/client/communication/PushConnection.java index 0731d513ea..e3d2e576e6 100644 --- a/client/src/com/vaadin/client/communication/PushConnection.java +++ b/client/src/com/vaadin/client/communication/PushConnection.java @@ -42,7 +42,7 @@ public class PushConnection { private boolean connected = false; - private AtmosphereConfiguration config = createConfig(); + private AtmosphereConfiguration config; public PushConnection() { } @@ -72,7 +72,10 @@ public class PushConnection { } } - protected JavaScriptObject getConfig() { + protected AtmosphereConfiguration getConfig() { + if (config == null) { + config = createConfig(); + } return config; } @@ -102,8 +105,8 @@ public class PushConnection { */ protected void onTransportFailure() { VConsole.log("Push connection using primary method (" - + config.getTransport() + ") failed. Trying with " - + config.getFallbackTransport()); + + getConfig().getTransport() + ") failed. Trying with " + + getConfig().getFallbackTransport()); } /** @@ -112,7 +115,8 @@ public class PushConnection { * */ protected void onError() { - VConsole.error("Push connection using " + config.getTransport() + VConsole.error("Push connection using " + + getConfig().getTransport() + " failed!"); } @@ -126,11 +130,21 @@ public class PushConnection { return this[key]; }-*/; + protected final native void setStringValue(String key, String value) + /*-{ + this[key] = value; + }-*/; + protected final native int getIntValue(String key) /*-{ return this[key]; }-*/; + protected final native void setIntValue(String key, int value) + /*-{ + this[key] = value; + }-*/; + } public static class AtmosphereConfiguration extends AbstractJSO { @@ -146,6 +160,14 @@ public class PushConnection { public final String getFallbackTransport() { return getStringValue("fallbackTransport"); } + + public final void setTransport(String transport) { + setStringValue("transport", transport); + } + + public final void setFallbackTransport(String fallbackTransport) { + setStringValue("fallbackTransport", fallbackTransport); + } } public static class AtmosphereResponse extends AbstractJSO { @@ -172,7 +194,7 @@ public class PushConnection { } - private static native AtmosphereConfiguration createConfig() + protected native AtmosphereConfiguration createConfig() /*-{ return { transport: 'websocket', diff --git a/uitest/src/com/vaadin/tests/push/BasicPush.java b/uitest/src/com/vaadin/tests/push/BasicPush.java index 17d107bb8c..43f8236999 100644 --- a/uitest/src/com/vaadin/tests/push/BasicPush.java +++ b/uitest/src/com/vaadin/tests/push/BasicPush.java @@ -4,14 +4,17 @@ import java.util.Date; import java.util.Timer; import java.util.TimerTask; +import com.vaadin.annotations.Widgetset; import com.vaadin.data.util.ObjectProperty; import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.widgetset.TestingWidgetSet; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; +@Widgetset(TestingWidgetSet.NAME) public class BasicPush extends AbstractTestUI { private ObjectProperty<Integer> counter = new ObjectProperty<Integer>(0); diff --git a/uitest/src/com/vaadin/tests/push/StreamingPush.html b/uitest/src/com/vaadin/tests/push/StreamingPush.html new file mode 100644 index 0000000000..533f571b9c --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/StreamingPush.html @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run-push/com.vaadin.tests.push.BasicPush?restartApplication&debug&transport=streaming</td> + <td></td> +</tr> +<!--Test client initiated push --> +<tr> + <td>assertText</td> + <td>id=gwt-uid-5</td> + <td>0</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>id=gwt-uid-5</td> + <td>1</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>id=gwt-uid-5</td> + <td>4</td> +</tr> +<!--Test server initiated push--> +<tr> + <td>click</td> + <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>id=gwt-uid-7</td> + <td>0</td> +</tr> +<tr> + <td>pause</td> + <td>3000</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>id=gwt-uid-7</td> + <td>1</td> +</tr> +<tr> + <td>pause</td> + <td>3000</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>id=gwt-uid-7</td> + <td>2</td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/widgetset/TestingWidgetSet.gwt.xml b/uitest/src/com/vaadin/tests/widgetset/TestingWidgetSet.gwt.xml index 919a4a5d69..1b47a86113 100644 --- a/uitest/src/com/vaadin/tests/widgetset/TestingWidgetSet.gwt.xml +++ b/uitest/src/com/vaadin/tests/widgetset/TestingWidgetSet.gwt.xml @@ -7,5 +7,9 @@ <replace-with class="com.vaadin.tests.widgetset.client.CustomUIConnector"> <when-type-is class="com.vaadin.client.ui.ui.UIConnector" /> </replace-with> + + <replace-with class="com.vaadin.tests.widgetset.client.TestingPushConnection"> + <when-type-is class="com.vaadin.client.communication.PushConnection" /> + </replace-with> </module> diff --git a/uitest/src/com/vaadin/tests/widgetset/client/TestingPushConnection.java b/uitest/src/com/vaadin/tests/widgetset/client/TestingPushConnection.java new file mode 100644 index 0000000000..8453daabcd --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/TestingPushConnection.java @@ -0,0 +1,30 @@ +package com.vaadin.tests.widgetset.client; + +import com.google.gwt.user.client.Window; +import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.communication.PushConnection; + +public class TestingPushConnection extends PushConnection { + + private String transport; + + @Override + public void init(ApplicationConnection connection) { + super.init(connection); + transport = Window.Location.getParameter("transport"); + } + + /* + * Force transport + */ + @Override + protected AtmosphereConfiguration createConfig() { + AtmosphereConfiguration conf = super.createConfig(); + if (transport != null) { + conf.setTransport(transport); + conf.setFallbackTransport(transport); + } + return conf; + } + +} |