summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/push/BasicPushTest.java
diff options
context:
space:
mode:
authorSauli Tähkäpää <sauli@vaadin.com>2014-04-09 10:58:53 +0300
committerVaadin Code Review <review@vaadin.com>2014-04-14 11:09:44 +0000
commit487963914e6ff7ab8def7af809ef2db4b79faa55 (patch)
treec26e634ed2dee151cb781231b5f04d1e27aca720 /uitest/src/com/vaadin/tests/push/BasicPushTest.java
parente697d8b318c88d0acecd1fbb23231667fda5b4b8 (diff)
downloadvaadin-framework-487963914e6ff7ab8def7af809ef2db4b79faa55.tar.gz
vaadin-framework-487963914e6ff7ab8def7af809ef2db4b79faa55.zip
Redo Push reconnect tests.
Change-Id: I75330f67f6a57658e95b9510502bf6a1e38924ad
Diffstat (limited to 'uitest/src/com/vaadin/tests/push/BasicPushTest.java')
-rw-r--r--uitest/src/com/vaadin/tests/push/BasicPushTest.java71
1 files changed, 34 insertions, 37 deletions
diff --git a/uitest/src/com/vaadin/tests/push/BasicPushTest.java b/uitest/src/com/vaadin/tests/push/BasicPushTest.java
index 670876e0f4..7f4492aeba 100644
--- a/uitest/src/com/vaadin/tests/push/BasicPushTest.java
+++ b/uitest/src/com/vaadin/tests/push/BasicPushTest.java
@@ -15,9 +15,10 @@
*/
package com.vaadin.tests.push;
-import org.junit.Assert;
import org.junit.Test;
+import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedCondition;
import com.vaadin.tests.annotations.TestCategory;
import com.vaadin.tests.tb3.AbstractTB3Test;
@@ -26,49 +27,28 @@ import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("push")
public abstract class BasicPushTest extends MultiBrowserTest {
+ @Override
+ public void setup() throws Exception {
+ super.setup();
+ }
+
@Test
public void testPush() throws InterruptedException {
openTestURL();
- // Test client initiated push
- Assert.assertEquals(0, getClientCounter());
getIncrementButton().click();
- Assert.assertEquals("Client counter not incremented by button click",
- 1, getClientCounter());
+ testBench().disableWaitForVaadin();
+
+ waitUntilClientCounterChanges(1);
+
getIncrementButton().click();
getIncrementButton().click();
getIncrementButton().click();
- Assert.assertEquals("Four clicks should have incremented counter to 4",
- 4, getClientCounter());
+ waitUntilClientCounterChanges(4);
// Test server initiated push
getServerCounterStartButton().click();
- try {
- Assert.assertEquals(0, getServerCounter());
- sleep(3000);
- int serverCounter = getServerCounter();
- if (serverCounter < 1) {
- // No push has happened
- Assert.fail("No push has occured within 3s");
- }
- sleep(3000);
- if (getServerCounter() <= serverCounter) {
- // No push has happened
- Assert.fail("Only one push took place within 6s");
-
- }
- } finally {
- // Avoid triggering push assertions
- getServerCounterStopButton().click();
- }
- }
-
- private int getServerCounter() {
- return getServerCounter(this);
- }
-
- private int getClientCounter() {
- return getClientCounter(this);
+ waitUntilServerCounterChanges();
}
public static int getClientCounter(AbstractTB3Test t) {
@@ -81,10 +61,6 @@ public abstract class BasicPushTest extends MultiBrowserTest {
return getIncrementButton(this);
}
- private WebElement getServerCounterStopButton() {
- return getServerCounterStopButton(this);
- }
-
private WebElement getServerCounterStartButton() {
return getServerCounterStartButton(this);
}
@@ -107,4 +83,25 @@ public abstract class BasicPushTest extends MultiBrowserTest {
return t.vaadinElementById(BasicPush.INCREMENT_BUTTON_ID);
}
+ private void waitUntilClientCounterChanges(final int expectedValue) {
+ waitUntil(new ExpectedCondition<Boolean>() {
+
+ @Override
+ public Boolean apply(WebDriver input) {
+ return BasicPushTest.getClientCounter(BasicPushTest.this) == expectedValue;
+ }
+ }, 10);
+ }
+
+ private void waitUntilServerCounterChanges() {
+ final int counter = BasicPushTest.getServerCounter(this);
+ waitUntil(new ExpectedCondition<Boolean>() {
+
+ @Override
+ public Boolean apply(WebDriver input) {
+ return BasicPushTest.getServerCounter(BasicPushTest.this) > counter;
+ }
+ }, 10);
+ }
+
} \ No newline at end of file