aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/push
diff options
context:
space:
mode:
Diffstat (limited to 'uitest/src/com/vaadin/tests/push')
-rw-r--r--uitest/src/com/vaadin/tests/push/BarInUIDL.html42
-rw-r--r--uitest/src/com/vaadin/tests/push/BarInUIDL.java30
-rw-r--r--uitest/src/com/vaadin/tests/push/BasicPush.html88
-rw-r--r--uitest/src/com/vaadin/tests/push/BasicPush.java136
-rw-r--r--uitest/src/com/vaadin/tests/push/BasicPushStreaming.java34
-rw-r--r--uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java36
-rw-r--r--uitest/src/com/vaadin/tests/push/PushConfiguration.html130
-rw-r--r--uitest/src/com/vaadin/tests/push/PushConfigurationTest.java113
-rw-r--r--uitest/src/com/vaadin/tests/push/PushFromInit.html32
-rw-r--r--uitest/src/com/vaadin/tests/push/PushFromInit.java46
-rw-r--r--uitest/src/com/vaadin/tests/push/PushReattachedComponent.html47
-rw-r--r--uitest/src/com/vaadin/tests/push/PushReattachedComponent.java65
-rw-r--r--uitest/src/com/vaadin/tests/push/PushTransportAnnotation.html46
-rw-r--r--uitest/src/com/vaadin/tests/push/StreamingPush.html88
-rw-r--r--uitest/src/com/vaadin/tests/push/TogglePush.html91
-rw-r--r--uitest/src/com/vaadin/tests/push/TogglePush.java154
-rw-r--r--uitest/src/com/vaadin/tests/push/TogglePushInInit.html69
-rw-r--r--uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.html26
-rw-r--r--uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java11
19 files changed, 605 insertions, 679 deletions
diff --git a/uitest/src/com/vaadin/tests/push/BarInUIDL.html b/uitest/src/com/vaadin/tests/push/BarInUIDL.html
deleted file mode 100644
index 66f03158b6..0000000000
--- a/uitest/src/com/vaadin/tests/push/BarInUIDL.html
+++ /dev/null
@@ -1,42 +0,0 @@
-<?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.BarInUIDL?restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runpushcomvaadintestspushBarInUIDL::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runpushcomvaadintestspushBarInUIDL::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</td>
- <td>Thank you for clicking | bar</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runpushcomvaadintestspushBarInUIDL::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runpushcomvaadintestspushBarInUIDL::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VLabel[0]</td>
- <td>Thank you for clicking | bar</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/push/BarInUIDL.java b/uitest/src/com/vaadin/tests/push/BarInUIDL.java
index 7e414cc89d..ef2568bebe 100644
--- a/uitest/src/com/vaadin/tests/push/BarInUIDL.java
+++ b/uitest/src/com/vaadin/tests/push/BarInUIDL.java
@@ -16,14 +16,44 @@
package com.vaadin.tests.push;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.annotations.Push;
import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.ui.Transport;
import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
+@Push(transport = Transport.STREAMING)
public class BarInUIDL extends AbstractTestUI {
+ public static class BarInUIDLTest extends MultiBrowserTest {
+ @Test
+ public void sendBarInUIDL() {
+ getButton().click();
+ Assert.assertEquals(
+ "Thank you for clicking | bar",
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]")
+ .getText());
+ getButton().click();
+ Assert.assertEquals(
+ "Thank you for clicking | bar",
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VLabel[0]")
+ .getText());
+ }
+
+ private WebElement getButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]");
+ }
+ }
+
/*
* (non-Javadoc)
*
diff --git a/uitest/src/com/vaadin/tests/push/BasicPush.html b/uitest/src/com/vaadin/tests/push/BasicPush.html
deleted file mode 100644
index 173ec90674..0000000000
--- a/uitest/src/com/vaadin/tests/push/BasicPush.html
+++ /dev/null
@@ -1,88 +0,0 @@
-<?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&amp;debug</td>
- <td></td>
-</tr>
-<!--Test client initiated push -->
-<tr>
- <td>assertText</td>
- <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</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>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</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>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</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>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]</td>
- <td>0</td>
-</tr>
-<tr>
- <td>pause</td>
- <td>3000</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]</td>
- <td>1</td>
-</tr>
-<tr>
- <td>pause</td>
- <td>3000</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]</td>
- <td>2</td>
-</tr>
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/push/BasicPush.java b/uitest/src/com/vaadin/tests/push/BasicPush.java
index b80d287a1d..1f184863f7 100644
--- a/uitest/src/com/vaadin/tests/push/BasicPush.java
+++ b/uitest/src/com/vaadin/tests/push/BasicPush.java
@@ -1,40 +1,115 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.vaadin.tests.push;
-import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
-import com.vaadin.annotations.Widgetset;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.annotations.Push;
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.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
-@Widgetset(TestingWidgetSet.NAME)
+@Push
public class BasicPush extends AbstractTestUI {
+ public static abstract class BasicPushTest extends MultiBrowserTest {
+
+ @Test
+ public void testPush() {
+ // Test client initiated push
+ Assert.assertEquals(0, getClientCounter());
+ getIncrementButton().click();
+ Assert.assertEquals(
+ "Client counter not incremented by button click", 1,
+ getClientCounter());
+ getIncrementButton().click();
+ getIncrementButton().click();
+ getIncrementButton().click();
+ Assert.assertEquals(
+ "Four clicks should have incremented counter to 4", 4,
+ getClientCounter());
+
+ // Test server initiated push
+ getServerCounterStartButton().click();
+ try {
+ Assert.assertEquals(0, getServerCounter());
+ sleep(3000);
+ int serverCounter = getServerCounter();
+ if (serverCounter < 1) {
+ // No push has happened
+ Assert.fail("No push has occured within 3s");
+ }
+ sleep(3000);
+ if (getServerCounter() <= serverCounter) {
+ // No push has happened
+ Assert.fail("Only one push took place within 6s");
+
+ }
+ } finally {
+ // Avoid triggering push assertions
+ getServerCounterStopButton().click();
+ }
+ }
+
+ private int getServerCounter() {
+ return Integer.parseInt(getServerCounterElement().getText());
+ }
+
+ private int getClientCounter() {
+ return Integer.parseInt(getClientCounterElement().getText());
+ }
+
+ private WebElement getServerCounterElement() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]");
+ }
+
+ private WebElement getServerCounterStartButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]");
+ }
+
+ private WebElement getServerCounterStopButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]");
+ }
+
+ private WebElement getIncrementButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]");
+ }
+
+ private WebElement getClientCounterElement() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]");
+ }
+ }
+
private ObjectProperty<Integer> counter = new ObjectProperty<Integer>(0);
private ObjectProperty<Integer> counter2 = new ObjectProperty<Integer>(0);
private final Timer timer = new Timer(true);
- private final TimerTask task = new TimerTask() {
-
- @Override
- public void run() {
- access(new Runnable() {
- @Override
- public void run() {
- counter2.setValue(counter2.getValue() + 1);
- }
- });
- }
- };
+ private TimerTask task;
@Override
protected void setup(VaadinRequest request) {
@@ -65,11 +140,37 @@ public class BasicPush extends AbstractTestUI {
lbl.setCaption("Server counter (updates each 3s by server thread) :");
addComponent(lbl);
- addComponent(new Button("Reset", new Button.ClickListener() {
+ addComponent(new Button("Start timer", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
counter2.setValue(0);
+ if (task != null) {
+ task.cancel();
+ }
+ task = new TimerTask() {
+
+ @Override
+ public void run() {
+ access(new Runnable() {
+ @Override
+ public void run() {
+ counter2.setValue(counter2.getValue() + 1);
+ }
+ });
+ }
+ };
+ timer.scheduleAtFixedRate(task, 3000, 3000);
+ }
+ }));
+
+ addComponent(new Button("Stop timer", new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ if (task != null) {
+ task.cancel();
+ task = null;
+ }
}
}));
}
@@ -94,7 +195,6 @@ public class BasicPush extends AbstractTestUI {
@Override
public void attach() {
super.attach();
- timer.scheduleAtFixedRate(task, new Date(), 3000);
}
@Override
diff --git a/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java b/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java
index 37a8afd819..29534e1f5c 100644
--- a/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java
+++ b/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java
@@ -1,12 +1,42 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.vaadin.tests.push;
+import org.junit.Test;
+
import com.vaadin.annotations.Push;
+import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.ui.Transport;
@Push(transport = Transport.STREAMING)
public class BasicPushStreaming extends BasicPush {
@Override
- protected void setup(com.vaadin.server.VaadinRequest request) {
- addComponent(new PushConfigurator(this));
+ public void init(VaadinRequest request) {
+ super.init(request);
+ // Don't use fallback so we can easier detect if streaming fails
+ getPushConfiguration().setFallbackTransport(Transport.STREAMING);
+
}
+
+ public static class BasicPushStreamingTest extends BasicPushTest {
+ @Override
+ @Test
+ public void testPush() {
+ super.testPush();
+ }
+ }
+
}
diff --git a/uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java b/uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java
index 6fc27e8974..4765183fca 100644
--- a/uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java
+++ b/uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java
@@ -1,8 +1,44 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.vaadin.tests.push;
+import java.util.Collection;
+
+import org.openqa.selenium.remote.DesiredCapabilities;
+
import com.vaadin.annotations.Push;
+import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.ui.Transport;
+import com.vaadin.tests.tb3.WebsocketTest;
@Push(transport = Transport.WEBSOCKET)
public class BasicPushWebsocket extends BasicPush {
+
+ @Override
+ public void init(VaadinRequest request) {
+ super.init(request);
+ // Don't use fallback so we can easier detect if websocket fails
+ getPushConfiguration().setFallbackTransport(Transport.WEBSOCKET);
+ }
+
+ public static class BasicPushWebsocketTest extends BasicPushTest {
+ @Override
+ public Collection<DesiredCapabilities> getBrowsersToTest() {
+ return WebsocketTest.getWebsocketBrowsers();
+ }
+ }
+
}
diff --git a/uitest/src/com/vaadin/tests/push/PushConfiguration.html b/uitest/src/com/vaadin/tests/push/PushConfiguration.html
deleted file mode 100644
index c3786b1cc1..0000000000
--- a/uitest/src/com/vaadin/tests/push/PushConfiguration.html
+++ /dev/null
@@ -1,130 +0,0 @@
-<?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>
-<!--Websocket-->
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.push.PushConfigurationTest?debug&amp;restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>assertNotText</td>
- <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td>
- <td>4</td>
-</tr>
-<tr>
- <td>select</td>
- <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[1]/VNativeSelect[0]/domChild[0]</td>
- <td>label=WEBSOCKET</td>
-</tr>
-<tr>
- <td>assertNotText</td>
- <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td>
- <td>4</td>
-</tr>
-<tr>
- <td>select</td>
- <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]</td>
- <td>label=AUTOMATIC</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]</td>
- <td>*fallbackTransport: streaming*transport: websocket*</td>
-</tr>
-<tr>
- <td>assertNotText</td>
- <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td>
- <td>4</td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td>
- <td>4</td>
-</tr>
-<!--Use debug console to verify we used the correct transport type-->
-<tr>
- <td>assertTextPresent</td>
- <td>Push connection established using websocket</td>
- <td></td>
-</tr>
-<tr>
- <td>assertTextNotPresent</td>
- <td>Push connection established using streaming</td>
- <td>Push connection established using streaming</td>
-</tr>
-<tr>
- <td>select</td>
- <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]</td>
- <td>label=DISABLED</td>
-</tr>
-<!--Streaming-->
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.push.PushConfigurationTest?debug&amp;restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>assertNotText</td>
- <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td>
- <td>4</td>
-</tr>
-<tr>
- <td>select</td>
- <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[1]/VNativeSelect[0]/domChild[0]</td>
- <td>label=STREAMING</td>
-</tr>
-<tr>
- <td>assertNotText</td>
- <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td>
- <td>4</td>
-</tr>
-<tr>
- <td>select</td>
- <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]</td>
- <td>label=AUTOMATIC</td>
-</tr>
-<tr>
- <td>assertNotText</td>
- <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td>
- <td>4</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]</td>
- <td>*fallbackTransport: streaming*transport: streaming*</td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td>
- <td>4</td>
-</tr>
-<!--Use debug console to verify we used the correct transport type-->
-<tr>
- <td>assertTextNotPresent</td>
- <td>Push connection established using websocket</td>
- <td></td>
-</tr>
-<tr>
- <td>assertTextPresent</td>
- <td>Push connection established using streaming</td>
- <td></td>
-</tr>
-<tr>
- <td>select</td>
- <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]</td>
- <td>label=DISABLED</td>
-</tr>
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java
index b57e9732cc..f4a537392d 100644
--- a/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java
+++ b/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java
@@ -1,19 +1,132 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.vaadin.tests.push;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.Select;
+
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.tb3.WebsocketTest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
public class PushConfigurationTest extends AbstractTestUI {
+ public static class PushConfigurationWebsocket extends WebsocketTest {
+
+ @Override
+ protected boolean isDebug() {
+ return true;
+ }
+
+ @Test
+ public void testWebsocketAndStreaming() {
+ // Websocket
+ Assert.assertEquals(1, getServerCounter());
+ new Select(getTransportSelect()).selectByVisibleText("WEBSOCKET");
+ new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC");
+ Assert.assertTrue(vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]")
+ .getText()
+ .matches(
+ "^[\\s\\S]*fallbackTransport: streaming[\\s\\S]*transport: websocket[\\s\\S]*$"));
+ int counter = getServerCounter();
+
+ for (int second = 0;; second++) {
+ if (second >= 5) {
+ Assert.fail("timeout");
+ }
+ if (getServerCounter() >= (counter + 2)) {
+ break;
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+ }
+
+ // Use debug console to verify we used the correct transport type
+ Assert.assertTrue(driver.getPageSource().contains(
+ "Push connection established using websocket"));
+ Assert.assertFalse(driver.getPageSource().contains(
+ "Push connection established using streaming"));
+
+ new Select(getPushModeSelect()).selectByVisibleText("DISABLED");
+
+ // Streaming
+ driver.get(getTestUrl());
+ Assert.assertEquals(1, getServerCounter());
+
+ new Select(getTransportSelect()).selectByVisibleText("STREAMING");
+ new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC");
+ Assert.assertTrue(vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]")
+ .getText()
+ .matches(
+ "^[\\s\\S]*fallbackTransport: streaming[\\s\\S]*transport: streaming[\\s\\S]*$"));
+
+ counter = getServerCounter();
+ for (int second = 0;; second++) {
+ if (second >= 5) {
+ Assert.fail("timeout");
+ }
+ if (getServerCounter() >= (counter + 2)) {
+ break;
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+ }
+
+ // Use debug console to verify we used the correct transport type
+ Assert.assertFalse(driver.getPageSource().contains(
+ "Push connection established using websocket"));
+ Assert.assertTrue(driver.getPageSource().contains(
+ "Push connection established using streaming"));
+
+ }
+
+ private WebElement getPushModeSelect() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]");
+ }
+
+ private WebElement getTransportSelect() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[1]/VNativeSelect[0]/domChild[0]");
+ }
+
+ private int getServerCounter() {
+ return Integer.parseInt(getServerCounterElement().getText());
+ }
+
+ private WebElement getServerCounterElement() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]");
+ }
+ }
+
private ObjectProperty<Integer> counter = new ObjectProperty<Integer>(0);
private ObjectProperty<Integer> counter2 = new ObjectProperty<Integer>(0);
diff --git a/uitest/src/com/vaadin/tests/push/PushFromInit.html b/uitest/src/com/vaadin/tests/push/PushFromInit.html
deleted file mode 100644
index d009eb3baf..0000000000
--- a/uitest/src/com/vaadin/tests/push/PushFromInit.html
+++ /dev/null
@@ -1,32 +0,0 @@
-<?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="" />
-<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.PushFromInit?debug&amp;restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>vaadin=runpushcomvaadintestspushPushFromInit::PID_SLog_row_1</td>
- <td>1. Logged in init</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runpushcomvaadintestspushPushFromInit::PID_SLog_row_0</td>
- <td>2. Logged from background thread started in init</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/push/PushFromInit.java b/uitest/src/com/vaadin/tests/push/PushFromInit.java
index 4b442de499..000d5c0bce 100644
--- a/uitest/src/com/vaadin/tests/push/PushFromInit.java
+++ b/uitest/src/com/vaadin/tests/push/PushFromInit.java
@@ -1,11 +1,57 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.vaadin.tests.push;
+import org.junit.Assert;
+import org.junit.Test;
+
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.Button;
public class PushFromInit extends AbstractTestUIWithLog {
+ public static class PushFromInitTB3 extends MultiBrowserTest {
+ @Test
+ public void testPushFromInit() {
+ for (int second = 0;; second++) {
+ if (second >= 30) {
+ Assert.fail("timeout");
+ }
+ try {
+ if ("1. Logged in init".equals(vaadinElementById(
+ "Log_row_1").getText())) {
+ break;
+ }
+ } catch (Exception e) {
+ }
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ }
+ }
+
+ Assert.assertEquals(
+ "2. Logged from background thread started in init",
+ vaadinElementById("Log_row_0").getText());
+
+ }
+ }
+
@Override
protected void setup(VaadinRequest request) {
new Thread() {
diff --git a/uitest/src/com/vaadin/tests/push/PushReattachedComponent.html b/uitest/src/com/vaadin/tests/push/PushReattachedComponent.html
deleted file mode 100644
index e1f6a5f048..0000000000
--- a/uitest/src/com/vaadin/tests/push/PushReattachedComponent.html
+++ /dev/null
@@ -1,47 +0,0 @@
-<?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://192.168.2.162: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.components.panel.PanelChangeContents?restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
- <td>stats</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
- <td>companies</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
- <td>stats</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/push/PushReattachedComponent.java b/uitest/src/com/vaadin/tests/push/PushReattachedComponent.java
new file mode 100644
index 0000000000..35934273a4
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/PushReattachedComponent.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+/**
+ *
+ */
+package com.vaadin.tests.push;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.tests.components.panel.PanelChangeContents;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class PushReattachedComponent extends MultiBrowserTest {
+
+ @Override
+ protected boolean isPushEnabled() {
+ return true;
+ }
+
+ @Override
+ protected Class<?> getUIClass() {
+ return PanelChangeContents.class;
+ }
+
+ @Test
+ public void testReattachComponentUsingPush() {
+ Assert.assertEquals(
+ "stats",
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+ .getText());
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]")
+ .click();
+ Assert.assertEquals(
+ "companies",
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+ .getText());
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]")
+ .click();
+ Assert.assertEquals(
+ "stats",
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+ .getText());
+
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/push/PushTransportAnnotation.html b/uitest/src/com/vaadin/tests/push/PushTransportAnnotation.html
deleted file mode 100644
index 854dd458bb..0000000000
--- a/uitest/src/com/vaadin/tests/push/PushTransportAnnotation.html
+++ /dev/null
@@ -1,46 +0,0 @@
-<?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/com.vaadin.tests.push.BasicPushStreaming?debug&amp;restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForTextPresent</td>
- <td>Push connection established using streaming</td>
- <td></td>
-</tr>
-<tr>
- <td>assertTextNotPresent</td>
- <td>Push connection established using websocket</td>
- <td></td>
-</tr>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.push.BasicPushWebsocket?debug&amp;restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>assertTextNotPresent</td>
- <td>Push connection established using streaming</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForTextPresent</td>
- <td>Push connection established using websocket</td>
- <td></td>
-</tr>
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/push/StreamingPush.html b/uitest/src/com/vaadin/tests/push/StreamingPush.html
deleted file mode 100644
index cf94a09c63..0000000000
--- a/uitest/src/com/vaadin/tests/push/StreamingPush.html
+++ /dev/null
@@ -1,88 +0,0 @@
-<?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&amp;debug&amp;transport=streaming</td>
- <td></td>
-</tr>
-<!--Test client initiated push -->
-<tr>
- <td>assertText</td>
- <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</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>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</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>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</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>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]</td>
- <td>0</td>
-</tr>
-<tr>
- <td>pause</td>
- <td>3000</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]</td>
- <td>1</td>
-</tr>
-<tr>
- <td>pause</td>
- <td>3000</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]</td>
- <td>2</td>
-</tr>
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/push/TogglePush.html b/uitest/src/com/vaadin/tests/push/TogglePush.html
deleted file mode 100644
index b752d2120c..0000000000
--- a/uitest/src/com/vaadin/tests/push/TogglePush.html
+++ /dev/null
@@ -1,91 +0,0 @@
-<?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="" />
-<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.TogglePush?restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>pause</td>
- <td>2000</td>
- <td></td>
-</tr>
-<!--Push is enabled, so text gets updated-->
-<tr>
- <td>assertText</td>
- <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
- <td>Counter has been updated 1 times</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]</td>
- <td>61,6</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>pause</td>
- <td>2000</td>
- <td></td>
-</tr>
-<!--Push is disabled, so text is not updated-->
-<tr>
- <td>assertText</td>
- <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
- <td>Counter has been updated 1 times</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<!--Direct update is visible, and includes previous update-->
-<tr>
- <td>assertText</td>
- <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
- <td>Counter has been updated 3 times</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]</td>
- <td>61,3</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>pause</td>
- <td>2000</td>
- <td></td>
-</tr>
-<!--Push is enabled again, so text gets updated-->
-<tr>
- <td>assertText</td>
- <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
- <td>Counter has been updated 4 times</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/push/TogglePush.java b/uitest/src/com/vaadin/tests/push/TogglePush.java
index c0bdc54ee0..f59ef83fe7 100644
--- a/uitest/src/com/vaadin/tests/push/TogglePush.java
+++ b/uitest/src/com/vaadin/tests/push/TogglePush.java
@@ -1,19 +1,173 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.vaadin.tests.push;
import java.util.Timer;
import java.util.TimerTask;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.communication.PushMode;
import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.Label;
public class TogglePush extends AbstractTestUI {
+ public static class TogglePushInInitTB3 extends MultiBrowserTest {
+ @Override
+ protected boolean isPushEnabled() {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.tb3.AbstractTB3Test#getTestUrl()
+ */
+ @Override
+ protected String getTestUrl() {
+ return null;
+ }
+
+ @Test
+ public void togglePushInInit() {
+ String baseUrl = getBaseURL();
+ if (baseUrl.endsWith("/")) {
+ baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
+ }
+
+ String url = baseUrl + getDeploymentPath();
+
+ // Open with push disabled
+ driver.get(addParameter(url, "push=disabled"));
+
+ Assert.assertFalse(getPushToggle().isSelected());
+
+ getDelayedCounterUpdateButton().click();
+ sleep(2000);
+ Assert.assertEquals("Counter has been updated 0 times",
+ getCounterText());
+
+ // Open with push enabled
+ driver.get(addParameter(url, "push=enabled"));
+ Assert.assertTrue(getPushToggle().isSelected());
+
+ getDelayedCounterUpdateButton().click();
+ sleep(2000);
+ Assert.assertEquals("Counter has been updated 1 times",
+ getCounterText());
+
+ }
+
+ /**
+ * @since
+ * @param url
+ * @param string
+ * @return
+ */
+ private String addParameter(String url, String queryParameter) {
+ if (url.contains("?")) {
+ return url + "&" + queryParameter;
+ } else {
+ return url + "?" + queryParameter;
+ }
+ }
+
+ private String getCounterText() {
+ return vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+ .getText();
+ }
+
+ private WebElement getPushToggle() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]");
+ }
+
+ private WebElement getDelayedCounterUpdateButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]");
+ }
+
+ }
+
+ public static class TogglePushTB3 extends MultiBrowserTest {
+
+ @Override
+ protected boolean isPushEnabled() {
+ return true;
+ }
+
+ @Test
+ public void togglePush() {
+ getDelayedCounterUpdateButton().click();
+ sleep(2000);
+
+ // Push is enabled, so text gets updated
+ Assert.assertEquals("Counter has been updated 1 times",
+ getCounterText());
+
+ // Disable push
+ getPushToggle().click();
+ getDelayedCounterUpdateButton().click();
+ sleep(2000);
+ // Push is disabled, so text is not updated
+ Assert.assertEquals("Counter has been updated 1 times",
+ getCounterText());
+
+ getDirectCounterUpdateButton().click();
+ // Direct update is visible, and includes previous update
+ Assert.assertEquals("Counter has been updated 3 times",
+ getCounterText());
+
+ // Re-enable push
+ getPushToggle().click();
+ getDelayedCounterUpdateButton().click();
+ sleep(2000);
+
+ // Push is enabled again, so text gets updated
+ Assert.assertEquals("Counter has been updated 4 times",
+ getCounterText());
+ }
+
+ private WebElement getDirectCounterUpdateButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]");
+ }
+
+ private WebElement getPushToggle() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]");
+ }
+
+ private String getCounterText() {
+ return vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+ .getText();
+ }
+
+ private WebElement getDelayedCounterUpdateButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]");
+ }
+ }
+
private final Label counterLabel = new Label();
private int counter = 0;
diff --git a/uitest/src/com/vaadin/tests/push/TogglePushInInit.html b/uitest/src/com/vaadin/tests/push/TogglePushInInit.html
deleted file mode 100644
index c735f225e1..0000000000
--- a/uitest/src/com/vaadin/tests/push/TogglePushInInit.html
+++ /dev/null
@@ -1,69 +0,0 @@
-<?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:8071/" />
-<title>TogglePushInInit</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">TogglePushInInit</td></tr>
-</thead><tbody>
-<!--Open with push disabled-->
-<tr>
- <td>open</td>
- <td>/run-push/com.vaadin.tests.push.TogglePush?restartApplication&push=disabled</td>
- <td></td>
-</tr>
-<tr>
- <td>assertValue</td>
- <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]</td>
- <td>off</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>pause</td>
- <td>2000</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
- <td>Counter has been updated 0 times</td>
-</tr>
-<!--Open with push enabled-->
-<tr>
- <td>open</td>
- <td>/run-push/com.vaadin.tests.push.TogglePush?restartApplication&amp;push=enabled</td>
- <td></td>
-</tr>
-<tr>
- <td>assertValue</td>
- <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]</td>
- <td>on</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>pause</td>
- <td>2000</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
- <td>Counter has been updated 1 times</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.html b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.html
deleted file mode 100644
index 89dd7d4e78..0000000000
--- a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.html
+++ /dev/null
@@ -1,26 +0,0 @@
-<?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://192.168.2.162: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/com.vaadin.tests.push.TrackMessageSizeUnitTests?restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestspushTrackMessageSizeUnitTests::PID_SLog_row_0</td>
- <td>1. All tests run</td>
-</tr>
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java
index 062698edf5..d7459f83ab 100644
--- a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java
+++ b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java
@@ -25,18 +25,29 @@ import javax.servlet.ServletContext;
import org.apache.commons.io.IOUtils;
import org.json.JSONArray;
import org.json.JSONException;
+import org.junit.Assert;
+import org.junit.Test;
import com.vaadin.annotations.JavaScript;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinServletService;
import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.JavaScriptFunction;
// Load vaadinPush.js so that jQueryVaadin is defined
@JavaScript("vaadin://vaadinPush.js")
public class TrackMessageSizeUnitTests extends AbstractTestUIWithLog {
+ public static class TrackMessageSizeUnitTestsTB3 extends MultiBrowserTest {
+ @Test
+ public void runTests() {
+ Assert.assertEquals("1. All tests run",
+ vaadinElementById("Log_row_0").getText());
+ }
+ }
+
private String testMethod = "function testSequence(expected, data) {\n"
+ " var request = {trackMessageLength: true, messageDelimiter: '|'};\n"
+ " var response = {partialMessage: ''};\n"