summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2013-04-18 12:35:10 +0300
committerVaadin Code Review <review@vaadin.com>2013-04-19 11:53:44 +0000
commit0cbba9d6f4a65c04ca0e396c440de0c1c25945ec (patch)
tree115a33465849bfd516494e342e5ada6a5d47173b /uitest
parent457afbaeda4373541a634b12d195dd847948f1e2 (diff)
downloadvaadin-framework-0cbba9d6f4a65c04ca0e396c440de0c1c25945ec.tar.gz
vaadin-framework-0cbba9d6f4a65c04ca0e396c440de0c1c25945ec.zip
Initial support for toggling push on the fly (#11506)
Still missing is the ability to load vaadinPush.js if it has not yet been loaded. Change-Id: Ibe3596c38a7c4e3432b0396072866ee3072e6d30
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/push/TogglePush.html91
-rw-r--r--uitest/src/com/vaadin/tests/push/TogglePush.java82
2 files changed, 173 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/push/TogglePush.html b/uitest/src/com/vaadin/tests/push/TogglePush.html
new file mode 100644
index 0000000000..b752d2120c
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/TogglePush.html
@@ -0,0 +1,91 @@
+<?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
new file mode 100644
index 0000000000..8e9eafeabb
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/TogglePush.java
@@ -0,0 +1,82 @@
+package com.vaadin.tests.push;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+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.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Label;
+
+public class TogglePush extends AbstractTestUI {
+ private final Label counterLabel = new Label();
+ private int counter = 0;
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ updateCounter();
+ addComponent(counterLabel);
+
+ CheckBox pushSetting = new CheckBox("Push enabled");
+ pushSetting.setValue(Boolean.valueOf(getPushMode().isEnabled()));
+ pushSetting.setImmediate(true);
+ pushSetting.addValueChangeListener(new ValueChangeListener() {
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ if (event.getProperty().getValue() == Boolean.TRUE) {
+ setPushMode(PushMode.AUTOMATIC);
+ } else {
+ setPushMode(PushMode.DISABLED);
+ }
+ }
+ });
+ addComponent(pushSetting);
+
+ addComponent(new Button("Update counter now",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ updateCounter();
+ }
+ }));
+
+ addComponent(new Button("Update counter in 1 sec",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ new Timer().schedule(new TimerTask() {
+ @Override
+ public void run() {
+ runSafely(new Runnable() {
+ @Override
+ public void run() {
+ updateCounter();
+ }
+ });
+ }
+ }, 1000);
+ }
+ }));
+ }
+
+ public void updateCounter() {
+ counterLabel.setValue("Counter has been updated " + counter++
+ + " times");
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Basic test for enabling and disabling push on the fly.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return Integer.valueOf(11506);
+ }
+
+}