summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2013-09-12 17:48:47 +0300
committerVaadin Code Review <review@vaadin.com>2013-09-13 14:02:10 +0000
commit3a4351f9b777009d8e226d26125f758861ddcbb3 (patch)
treeef72438b05286a11ce05a5fa66e114f33fb9a2a6 /uitest
parent3cafce30057055d1731313c8d2833cb4c513ccd3 (diff)
downloadvaadin-framework-3a4351f9b777009d8e226d26125f758861ddcbb3.tar.gz
vaadin-framework-3a4351f9b777009d8e226d26125f758861ddcbb3.zip
Ensure PushConnection is properly cleaned up on disconnect (#12226, #12522)
Change-Id: I0bab199632554655ef92a624f5654852b4b157d1
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/push/EnableDisablePush.html97
-rw-r--r--uitest/src/com/vaadin/tests/push/EnableDisablePush.java119
2 files changed, 216 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/push/EnableDisablePush.html b/uitest/src/com/vaadin/tests/push/EnableDisablePush.html
new file mode 100644
index 0000000000..87dfa8428f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/EnableDisablePush.html
@@ -0,0 +1,97 @@
+<?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>EnableDisablePush</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">EnableDisablePush</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/EnableDisablePush?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runEnableDisablePush::PID_SLog_row_0</td>
+ <td>1. Push enabled</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runEnableDisablePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runEnableDisablePush::PID_SLog_row_0</td>
+ <td>3. Push disabled</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runEnableDisablePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runEnableDisablePush::PID_SLog_row_0</td>
+ <td>5. Poll enabled</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runEnableDisablePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runEnableDisablePush::PID_SLog_row_0</td>
+ <td>7. Push enabled</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runEnableDisablePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runEnableDisablePush::PID_SLog_row_0</td>
+ <td>9. Poll disabled</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runEnableDisablePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runEnableDisablePush::PID_SLog_row_0</td>
+ <td>11. Push disabled, polling enabled</td>
+</tr>
+<tr>
+ <td>pause</td>
+ <td>3500</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runEnableDisablePush::PID_SLog_row_0</td>
+ <td>16. Polling disabled, push enabled</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runEnableDisablePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runEnableDisablePush::PID_SLog_row_0</td>
+ <td>18. Push disabled</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/push/EnableDisablePush.java b/uitest/src/com/vaadin/tests/push/EnableDisablePush.java
new file mode 100644
index 0000000000..1911c66c2d
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/EnableDisablePush.java
@@ -0,0 +1,119 @@
+package com.vaadin.tests.push;
+
+import java.util.Date;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.TimeUnit;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.communication.PushMode;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.UIDetachedException;
+
+public class EnableDisablePush extends AbstractTestUI {
+
+ private int c = 0;
+
+ private Log log = new Log(15);
+
+ private final Timer timer = new Timer(true);
+
+ private final class CounterTask extends TimerTask {
+
+ @Override
+ public void run() {
+
+ try {
+ while (true) {
+ TimeUnit.MILLISECONDS.sleep(1000);
+
+ access(new Runnable() {
+ @Override
+ public void run() {
+ log.log("Counter = " + c++);
+ if (c == 3) {
+ log.log("Disabling polling, enabling push");
+ getPushConfiguration().setPushMode(
+ PushMode.AUTOMATIC);
+ setPollInterval(-1);
+ log.log("Polling disabled, push enabled");
+ }
+ }
+ });
+ }
+ } catch (InterruptedException e) {
+ } catch (UIDetachedException e) {
+ }
+ }
+ };
+
+ @Override
+ protected void setup(VaadinRequest request) {
+
+ getPushConfiguration().setPushMode(PushMode.AUTOMATIC);
+ log.log("Push enabled");
+
+ addComponent(new Button("Disable push", new Button.ClickListener() {
+ @Override
+ public void buttonClick(Button.ClickEvent event) {
+ log.log("Disabling push");
+ getPushConfiguration().setPushMode(PushMode.DISABLED);
+ log.log("Push disabled");
+ }
+ }));
+
+ addComponent(new Button("Enable push", new Button.ClickListener() {
+ @Override
+ public void buttonClick(Button.ClickEvent event) {
+ log.log("Enabling push");
+ getPushConfiguration().setPushMode(PushMode.AUTOMATIC);
+ log.log("Push enabled");
+ }
+ }));
+
+ addComponent(new Button("Disable polling", new Button.ClickListener() {
+ @Override
+ public void buttonClick(Button.ClickEvent event) {
+ log.log("Disabling poll");
+ setPollInterval(-1);
+ log.log("Poll disabled");
+ }
+ }));
+
+ addComponent(new Button("Enable polling", new Button.ClickListener() {
+ @Override
+ public void buttonClick(Button.ClickEvent event) {
+ log.log("Enabling poll");
+ setPollInterval(1000);
+ log.log("Poll enabled");
+ }
+ }));
+
+ addComponent(new Button(
+ "Disable push, re-enable from background thread",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(Button.ClickEvent event) {
+ log.log("Disabling push, enabling polling");
+ getPushConfiguration().setPushMode(PushMode.DISABLED);
+ setPollInterval(1000);
+ timer.schedule(new CounterTask(), new Date());
+ log.log("Push disabled, polling enabled");
+ }
+ }));
+
+ addComponent(log);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Test dynamically enablind and disabling push";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 12226;
+ }
+}