summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSauli Tähkäpää <sauli@vaadin.com>2015-02-13 15:57:03 +0200
committerVaadin Code Review <review@vaadin.com>2015-02-19 10:46:58 +0000
commit84ca55181fbdb10007905a1959443b301f8fcaf0 (patch)
treece7007b5a471dc0b74dff092b805f3f837f1ac2a
parent278e7ed9fe7ac3017f63c9ecd34e088152eaeb65 (diff)
downloadvaadin-framework-84ca55181fbdb10007905a1959443b301f8fcaf0.tar.gz
vaadin-framework-84ca55181fbdb10007905a1959443b301f8fcaf0.zip
Add overload to openTestURL for giving UI class as a parameter.
Change-Id: Ia964bb1bd185f5b78af1581c58f3f9247fad281c
-rw-r--r--uitest/src/com/vaadin/tests/applicationservlet/UIProviderInitParameterTest.java15
-rw-r--r--uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerLongEventTest.java5
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridClientRenderers.java4
-rw-r--r--uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java40
4 files changed, 42 insertions, 22 deletions
diff --git a/uitest/src/com/vaadin/tests/applicationservlet/UIProviderInitParameterTest.java b/uitest/src/com/vaadin/tests/applicationservlet/UIProviderInitParameterTest.java
index 8197bbe8b8..7f9a375440 100644
--- a/uitest/src/com/vaadin/tests/applicationservlet/UIProviderInitParameterTest.java
+++ b/uitest/src/com/vaadin/tests/applicationservlet/UIProviderInitParameterTest.java
@@ -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";
- }
-
}
diff --git a/uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerLongEventTest.java b/uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerLongEventTest.java
index 0ec196f266..740d451b0f 100644
--- a/uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerLongEventTest.java
+++ b/uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerLongEventTest.java
@@ -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();
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridClientRenderers.java b/uitest/src/com/vaadin/tests/components/grid/GridClientRenderers.java
index 00db02bef3..953e2a24c7 100644
--- a/uitest/src/com/vaadin/tests/components/grid/GridClientRenderers.java
+++ b/uitest/src/com/vaadin/tests/components/grid/GridClientRenderers.java
@@ -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;
}
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
index cd89579c31..3cec3a7bd5 100644
--- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -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";