From 224cd8e24ac133e00685dc03c0cf30832589421a Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Mon, 15 Apr 2013 16:01:51 +0300 Subject: Simple test for testing push capabilities #11494 Change-Id: I7dc3b861c2fa19bd1cffad93911c525fc5a2d24c --- uitest/src/com/vaadin/tests/push/BasicPush.html | 88 ++++++++++++++++++++ uitest/src/com/vaadin/tests/push/BasicPush.java | 102 ++++++++++++++++++++++++ 2 files changed, 190 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/push/BasicPush.html create mode 100644 uitest/src/com/vaadin/tests/push/BasicPush.java 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 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run-push/com.vaadin.tests.push.BasicPush?restartApplication&debug
assertTextid=gwt-uid-50
clickvaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
assertTextid=gwt-uid-51
clickvaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
assertTextid=gwt-uid-54
clickvaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]
assertTextid=gwt-uid-70
pause3000
assertTextid=gwt-uid-71
pause3000
assertTextid=gwt-uid-72
+ + 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 counter = new ObjectProperty(0); + + private ObjectProperty counter2 = new ObjectProperty(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("
", ContentMode.HTML)); + } + + @Override + public void attach() { + super.attach(); + timer.scheduleAtFixedRate(task, new Date(), 3000); + } + + @Override + public void detach() { + super.detach(); + timer.cancel(); + } +} -- cgit v1.2.3