diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-04-05 18:33:55 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2013-04-10 14:47:37 +0300 |
commit | 150352f64cdb49a27b110bd32e049c307fcf3486 (patch) | |
tree | 5a40f4a276d3f22d639ba2eb0cfd1e59e27b8049 /uitest/src/com/vaadin/tests/components/ui | |
parent | 2700cd2fe6c48b29478f1b8e14fde1d405a6ab7d (diff) | |
download | vaadin-framework-150352f64cdb49a27b110bd32e049c307fcf3486.tar.gz vaadin-framework-150352f64cdb49a27b110bd32e049c307fcf3486.zip |
Implemented poll interval for UI (#11495)
Change-Id: Ic56b0123970f18e282c75d67863569ac55c72ea8
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/ui')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/ui/UIPolling.html | 53 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/ui/UIPolling.java | 90 |
2 files changed, 143 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/ui/UIPolling.html b/uitest/src/com/vaadin/tests/components/ui/UIPolling.html new file mode 100644 index 0000000000..0e3cc2bc6e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/UIPolling.html @@ -0,0 +1,53 @@ +<?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/run/" /> +<title>WindowMaximizeRestoreTest</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">WindowMaximizeRestoreTest</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/UIPolling?restartApplication</td> + <td></td> +</tr> +<tr> + <td>type</td> + <td>id=gwt-uid-5</td> + <td>500</td> +</tr> +<tr> + <td>pause</td> + <td>2000</td> + <td></td> +</tr> +<!--Ensure polling has taken place--> +<tr> + <td>assertTextPresent</td> + <td>2. 1000ms has passed</td> + <td></td> +</tr> +<tr> + <td>type</td> + <td>id=gwt-uid-5</td> + <td>-1</td> +</tr> +<tr> + <td>pause</td> + <td>2000</td> + <td></td> +</tr> +<!--Ensure polling has stopped--> +<tr> + <td>assertTextNotPresent</td> + <td>8. 4000ms has passed</td> + <td></td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/ui/UIPolling.java b/uitest/src/com/vaadin/tests/components/ui/UIPolling.java new file mode 100644 index 0000000000..a7add63801 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/UIPolling.java @@ -0,0 +1,90 @@ +/* + * 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.components.ui; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.data.util.MethodProperty; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.tests.util.Log; +import com.vaadin.ui.TextField; + +public class UIPolling extends AbstractTestUIWithLog { + + protected static final long SLEEP_TIME = 500; + + private class BackgroundLogger extends Thread { + + @Override + public void run() { + int i = 0; + while (true) { + i++; + try { + Thread.sleep(SLEEP_TIME); + } catch (InterruptedException e) { + } + final int iteration = i; + runSafely(new Runnable() { + @Override + public void run() { + log.log((iteration * SLEEP_TIME) + "ms has passed"); + } + }); + } + } + } + + private BackgroundLogger logger = null; + + @Override + protected void setup(VaadinRequest request) { + log = new Log(20); + log.setNumberLogRows(true); + TextField pollingInterval = new TextField("Poll interval", + new MethodProperty<Integer>(this, "pollInterval")); + pollingInterval.setImmediate(true); + pollingInterval.setValue("-1"); + pollingInterval.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + if (logger != null) { + logger.stop(); + logger = null; + } + if (getPollInterval() >= 0) { + logger = new BackgroundLogger(); + logger.start(); + } + } + }); + addComponent(pollingInterval); + + } + + @Override + protected String getTestDescription() { + return "Tests the polling feature of UI. Set the polling interval using the text field. Enabling polling will at the same time start a background thread which logs every 500ms"; + } + + @Override + protected Integer getTicketNumber() { + return 11495; + } + +} |