Skip to content

Commit

Permalink
JasonLeyba: Fix //javascript/webdriver:test_e2e:run, which was broken…
Browse files Browse the repository at this point in the history
… by r15211.

r15281
  • Loading branch information
jleyba committed Dec 28, 2011
1 parent e48aaa8 commit e31d23a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ class JsTestSuiteBuilder {
private static final boolean NO_REFRESH_DRIVER = false;

private Function<String, Test> testFactory = null;
// private Class<? extends WebDriver> driverClazz = null;
private Supplier<WebDriver> driverSupplier = new WebDriverBuilder();

/**
* @param driverClazz The type of {@link WebDriver} that should be used to
* run the tests.
* @param driverSupplier The supplier to use for acquiring {@link WebDriver}
* instances when running the tests.
* @return A self reference.
*/
public JsTestSuiteBuilder withDriverClazz(
Class<? extends WebDriver> driverClazz) {
// this.driverClazz = checkNotNull(driverClazz);
public JsTestSuiteBuilder withDriverSupplier(
Supplier<WebDriver> driverSupplier) {
this.driverSupplier = checkNotNull(driverSupplier);
return this;
}

Expand All @@ -82,14 +82,11 @@ public JsTestSuiteBuilder withTestFactory(
*/
public Test build() {
checkNotNull(testFactory, "No path to test function specified");
// checkNotNull(driverClazz, "No driver class specified");

File testDirectory = getTestDirectory();
ImmutableSet<File> excludedFiles = getExcludedFiles(testDirectory);
String basePath = getTestUrlPath();

Supplier<WebDriver> driverSupplier = new WebDriverBuilder();

TestSuite suite = new TestSuite();
List<File> testFiles = findTestFiles(testDirectory,
new TestFilenameFilter(excludedFiles));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@

package org.openqa.selenium.javascript;

import com.google.common.base.Function;

import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestCase;

import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.json.JSONException;
import org.json.JSONObject;
import org.openqa.selenium.DriverTestDecorator;
import org.openqa.selenium.NeedsDriver;
import org.openqa.selenium.Platform;
Expand All @@ -36,6 +26,17 @@
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.base.Throwables;
import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestCase;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.json.JSONException;
import org.json.JSONObject;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
Expand All @@ -48,7 +49,7 @@ public static Test suite() {
final AppServer appServer = createAppServer(testEventServlet);

Test test = new JsTestSuiteBuilder()
.withDriverClazz(RemoteWebDriverForTest.class)
.withDriverSupplier(createDriverSupplier())
.withTestFactory(new Function<String, Test>() {
public Test apply(String testPath) {
return new WebDriverJsTestCase(testPath, appServer,
Expand All @@ -73,6 +74,18 @@ private static AppServer createAppServer(TestEventServlet resultsServlet) {
appServer.addHandler(context);
return appServer;
}

private static Supplier<WebDriver> createDriverSupplier() {
return new Supplier<WebDriver>() {
public WebDriver get() {
try {
return new RemoteWebDriverForTest();
} catch (MalformedURLException e) {
throw Throwables.propagate(e);
}
}
};
}

private static DesiredCapabilities getCapabilities() {
DesiredCapabilities capabilities = new DesiredCapabilities();
Expand Down

0 comments on commit e31d23a

Please sign in to comment.