Browse Source

Add overload to openTestURL for giving UI class as a parameter.

Change-Id: Ia964bb1bd185f5b78af1581c58f3f9247fad281c
tags/7.5.0.alpha1
Sauli Tähkäpää 9 years ago
parent
commit
84ca55181f

+ 10
- 5
uitest/src/com/vaadin/tests/applicationservlet/UIProviderInitParameterTest.java View File

@@ -27,6 +27,16 @@ import com.vaadin.tests.tb3.MultiBrowserTest;

public class UIProviderInitParameterTest extends MultiBrowserTest {

@Override
protected void openTestURL(String... parameters) {
driver.get(getTestUrl());
}

@Override
protected String getDeploymentPath() {
return "/uiprovider";
}

@Test
public void testDefault() {
// Test that UI parameter is used by default
@@ -50,9 +60,4 @@ public class UIProviderInitParameterTest extends MultiBrowserTest {
assertEquals("unexpected text found", message, label.getText());
}

@Override
protected String getDeploymentPath() {
return "/uiprovider";
}

}

+ 5
- 0
uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerLongEventTest.java View File

@@ -32,6 +32,11 @@ public class BeanItemContainerLongEventTest extends MultiBrowserTest {
return "/run/BeanItemContainerTestUI?restartApplication";
}

@Override
protected void openTestURL(String... parameters) {
driver.get(getTestUrl());
}

@Test
public void testEventDisplayedInWeekView() {
openTestURL();

+ 2
- 2
uitest/src/com/vaadin/tests/components/grid/GridClientRenderers.java View File

@@ -57,8 +57,8 @@ public class GridClientRenderers extends MultiBrowserTest {
}

@Override
protected String getDeploymentPath() {
String path = super.getDeploymentPath();
protected String getDeploymentPath(Class<?> uiClass) {
String path = super.getDeploymentPath(uiClass);
if (latency > 0) {
path += (path.contains("?") ? "&" : "?") + "latency=" + latency;
}

+ 25
- 15
uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java View File

@@ -33,6 +33,7 @@ import java.util.List;
import java.util.NoSuchElementException;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.impl.client.DefaultHttpClient;
@@ -60,6 +61,7 @@ import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import com.google.gwt.thirdparty.guava.common.base.Joiner;
import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium;
import com.vaadin.server.LegacyApplication;
import com.vaadin.server.UIProvider;
@@ -320,8 +322,8 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
* debug window and/or push (depending on {@link #isDebug()} and
* {@link #isPush()}.
*/
protected void openTestURL() {
openTestURL("");
protected void openTestURL(String... parameters) {
openTestURL(getUIClass(), parameters);
}

/**
@@ -329,13 +331,13 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
* debug window and/or push (depending on {@link #isDebug()} and
* {@link #isPush()}.
*/
protected void openTestURL(String extraParameters) {
String url = getTestUrl();
if (url.contains("?")) {
url = url + "&" + extraParameters;
} else {
url = url + "?" + extraParameters;
protected void openTestURL(Class<?> uiClass, String... parameters) {
String url = getTestURL(uiClass);

if(parameters.length > 0) {
url += "?" + Joiner.on("&").join(parameters);
}

driver.get(url);
}

@@ -345,12 +347,16 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
* @return the full URL for the test
*/
protected String getTestUrl() {
String baseUrl = getBaseURL();
if (baseUrl.endsWith("/")) {
baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
}
return StringUtils.strip(getBaseURL(), "/") + getDeploymentPath();
}

return baseUrl + getDeploymentPath();
/**
* Returns the full URL to be used for the test for the provided UI class.
*
* @return the full URL for the test
*/
protected String getTestURL(Class<?> uiClass) {
return StringUtils.strip(getBaseURL(), "/") + getDeploymentPath(uiClass);
}

/**
@@ -434,7 +440,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
public void tearDown() throws Exception {
if (driver != null) {
try {
openTestURL("&closeApplication");
closeApplication();
} catch (Exception e) {
e.printStackTrace();
}
@@ -443,6 +449,10 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
driver = null;
}

protected void closeApplication() {
openTestURL("closeApplication");
}

/**
* Finds an element based on the part of a TB2 style locator following the
* :: (e.g. vaadin=runLabelModes::PID_Scheckboxaction-Enabled/domChild[0] ->
@@ -833,7 +843,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
* true if /run-push should be used instead of /run
* @return The path to the given UI class
*/
private String getDeploymentPath(Class<?> uiClass) {
protected String getDeploymentPath(Class<?> uiClass) {
String runPath = "/run";
if (isPush()) {
runPath = "/run-push";

Loading…
Cancel
Save