diff options
author | John Ahlroos <john@vaadin.com> | 2013-04-15 16:01:51 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-04-16 06:26:37 +0000 |
commit | 224cd8e24ac133e00685dc03c0cf30832589421a (patch) | |
tree | 1a4ad5c318f86088e05125887d6eda7cb0802378 /uitest | |
parent | f7ed5d10954ad6085f7b7ad97e651f92ee800a5f (diff) | |
download | vaadin-framework-224cd8e24ac133e00685dc03c0cf30832589421a.tar.gz vaadin-framework-224cd8e24ac133e00685dc03c0cf30832589421a.zip |
Simple test for testing push capabilities #11494
Change-Id: I7dc3b861c2fa19bd1cffad93911c525fc5a2d24c
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/push/BasicPush.html | 88 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/push/BasicPush.java | 102 |
2 files changed, 190 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/push/BasicPush.html b/uitest/src/com/vaadin/tests/push/BasicPush.html new file mode 100644 index 0000000000..f69a573425 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/BasicPush.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</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/push/BasicPush.java b/uitest/src/com/vaadin/tests/push/BasicPush.java new file mode 100644 index 0000000000..17d107bb8c --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/BasicPush.java @@ -0,0 +1,102 @@ +package com.vaadin.tests.push; + +import java.util.Date; +import java.util.Timer; +import java.util.TimerTask; + +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.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Label; + +public class BasicPush extends AbstractTestUI { + + 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() { + runSafely(new Runnable() { + @Override + public void run() { + counter2.setValue(counter2.getValue() + 1); + } + }); + } + }; + + @Override + protected void setup(VaadinRequest request) { + + spacer(); + + /* + * Client initiated push. + */ + Label lbl = new Label(counter); + lbl.setCaption("Client counter (click 'increment' to update):"); + addComponent(lbl); + + addComponent(new Button("Increment", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + counter.setValue(counter.getValue() + 1); + } + })); + + spacer(); + + /* + * Server initiated push. + */ + lbl = new Label(counter2); + lbl.setCaption("Server counter (updates each 3s by server thread) :"); + addComponent(lbl); + + addComponent(new Button("Reset", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + counter2.setValue(0); + } + })); + } + + @Override + protected String getTestDescription() { + return "This test tests the very basic operations of push. " + + "It tests that client initiated changes are " + + "recieved back to the client as well as server " + + "initiated changes are correctly updated to the client."; + } + + @Override + protected Integer getTicketNumber() { + return 11494; + } + + private void spacer() { + addComponent(new Label("<hr/>", ContentMode.HTML)); + } + + @Override + public void attach() { + super.attach(); + timer.scheduleAtFixedRate(task, new Date(), 3000); + } + + @Override + public void detach() { + super.detach(); + timer.cancel(); + } +} |