Browse Source

Fixes test issues preventing it from passing

Ensure push is enabled correctly without a fallback and made test more stable

Change-Id: I6c653a96375e05c6ad18e1f5b697c6a584c6c53f
tags/7.1.8
Artur Signell 10 years ago
parent
commit
2c6d010d90

+ 15
- 3
uitest/src/com/vaadin/tests/push/PushLargeData.java View File

@@ -34,6 +34,18 @@ import com.vaadin.ui.UI;

public abstract class PushLargeData extends AbstractTestUIWithLog {

// 1MB
static final int DEFAULT_SIZE_BYTES = 1000 * 1000;

// Every other second
static final int DEFAULT_DELAY_MS = 2000;

// 20 MB is enough for streaming to reconnect
static final int DEFAULT_DATA_TO_PUSH = 20 * 1000 * 1000;

static final int DEFAULT_DURATION_MS = DEFAULT_DATA_TO_PUSH
/ DEFAULT_SIZE_BYTES * DEFAULT_DELAY_MS;

private Label dataLabel = new Label();

private final ExecutorService executor = Executors
@@ -49,9 +61,9 @@ public abstract class PushLargeData extends AbstractTestUIWithLog {
final TextField duration = new TextField("Duration (ms)");
duration.setConverter(Integer.class);

dataSize.setValue((1000 * 1000) + "");
interval.setValue(2000 + "");
duration.setValue(40 * 1000 + "");
dataSize.setValue(DEFAULT_SIZE_BYTES + "");
interval.setValue(DEFAULT_DELAY_MS + "");
duration.setValue(DEFAULT_DURATION_MS + "");

addComponent(dataSize);
addComponent(interval);

+ 5
- 1
uitest/src/com/vaadin/tests/push/PushLargeDataStreaming.java View File

@@ -15,15 +15,19 @@
*/
package com.vaadin.tests.push;

import com.vaadin.annotations.Push;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.ui.Transport;
import com.vaadin.shared.ui.ui.UIState.PushConfigurationState;

@Push(transport = Transport.STREAMING)
public class PushLargeDataStreaming extends PushLargeData {

@Override
protected void setup(VaadinRequest request) {
super.setup(request);
getPushConfiguration().setTransport(Transport.STREAMING);
getPushConfiguration().setFallbackTransport(Transport.STREAMING);
getPushConfiguration().setParameter(
PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none");
}
}

+ 13
- 7
uitest/src/com/vaadin/tests/push/PushLargeDataStreamingTest.java View File

@@ -19,12 +19,12 @@ import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.ExpectedConditions;

import com.vaadin.tests.tb3.WebsocketTest;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class PushLargeDataStreamingTest extends WebsocketTest {
public class PushLargeDataStreamingTest extends MultiBrowserTest {

@Test
public void testWebsocketLargeData() {
public void testStreamingLargeData() {
openTestURL();

// Without this there is a large chance that we will wait for all pushes
@@ -39,17 +39,23 @@ public class PushLargeDataStreamingTest extends WebsocketTest {
}

private void push() {
// Wait for startButton to be present
waitForElementToBePresent(vaadinLocatorById("startButton"));

String logRow0Id = "Log_row_0";
By logRow0 = vaadinLocatorById(logRow0Id);

vaadinElementById("startButton").click();
waitUntil(ExpectedConditions.not(ExpectedConditions
.textToBePresentInElement(logRow0, "Push complete")));
// Wait for push to start
waitUntil(ExpectedConditions.textToBePresentInElement(logRow0,
"Package "));

// Pushes each 2000ms for 40s
sleep(40000);
// Wait for until push should be done
sleep(PushLargeData.DEFAULT_DURATION_MS);

// Wait until push is actually done
waitUntil(ExpectedConditions.textToBePresentInElement(logRow0,
"Push complete"));
}

}

+ 4
- 3
uitest/src/com/vaadin/tests/push/PushLargeDataWebsocket.java View File

@@ -19,14 +19,15 @@ package com.vaadin.tests.push;
import com.vaadin.annotations.Push;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.ui.Transport;
import com.vaadin.shared.ui.ui.UIState.PushConfigurationState;

@Push
@Push(transport = Transport.WEBSOCKET)
public class PushLargeDataWebsocket extends PushLargeData {

@Override
protected void setup(VaadinRequest request) {
super.setup(request);
getPushConfiguration().setTransport(Transport.WEBSOCKET);
getPushConfiguration().setFallbackTransport(Transport.WEBSOCKET);
getPushConfiguration().setParameter(
PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none");
}
}

+ 9
- 5
uitest/src/com/vaadin/tests/push/PushLargeDataWebsocketTest.java View File

@@ -39,17 +39,21 @@ public class PushLargeDataWebsocketTest extends WebsocketTest {
}

private void push() {
// Wait for startButton to be present
waitForElementToBePresent(vaadinLocatorById("startButton"));

String logRow0Id = "Log_row_0";
By logRow0 = vaadinLocatorById(logRow0Id);

testBench(driver).waitForVaadin();
vaadinElementById("startButton").click();
waitUntil(ExpectedConditions.not(ExpectedConditions
.textToBePresentInElement(logRow0, "Push complete")));
// Wait for push to start
waitUntil(ExpectedConditions.textToBePresentInElement(logRow0,
"Package"));

// Pushes each 2000ms for 40s
sleep(40000);
// Wait for until push should be done
sleep(PushLargeData.DEFAULT_DURATION_MS);

// Wait until push is actually done
waitUntil(ExpectedConditions.textToBePresentInElement(logRow0,
"Push complete"));
}

+ 5
- 0
uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java View File

@@ -328,6 +328,11 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
new WebDriverWait(driver, 10).until(ExpectedConditions.not(condition));
}

protected void waitForElementToBePresent(By by) {
waitUntil(ExpectedConditions.not(ExpectedConditions
.invisibilityOfElementLocated(by)));
}

/**
* For tests extending {@link AbstractTestUIWithLog}, returns the element
* for the Nth log row

Loading…
Cancel
Save