Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: patch.diff

Issue 13925005: [chromedriver] Fix Android test runner by creating a new driver when needed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/webdriver/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test-nodeps-srcs.jar » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: patch.diff
===================================================================
--- patch.diff (revision 193397)
+++ patch.diff (working copy)
@@ -1,5 +1,5 @@
diff --git a/java/client/src/org/openqa/selenium/chrome/ChromeOptions.java b/java/client/src/org/openqa/selenium/chrome/ChromeOptions.java
-index 322ca9f..bb3918b 100644
+index 322ca9f..79a7109 100644
--- a/java/client/src/org/openqa/selenium/chrome/ChromeOptions.java
+++ b/java/client/src/org/openqa/selenium/chrome/ChromeOptions.java
@@ -71,6 +71,7 @@
@@ -32,34 +32,48 @@
}
+ if (androidPackage != null) {
-+ options.put("android_package", androidPackage);
++ options.put("androidPackage", androidPackage);
+ }
+
options.put("args", ImmutableList.copyOf(args));
List<String> extensions = Lists.newArrayListWithExpectedSize(
-diff --git a/java/client/test/org/openqa/selenium/testing/drivers/ReflectionBackedDriverSupplier.java b/java/client/test/org/openqa/selenium/testing/drivers/ReflectionBackedDriverSupplier.java
-index 3cc5799..7316a41 100644
---- a/java/client/test/org/openqa/selenium/testing/drivers/ReflectionBackedDriverSupplier.java
-+++ b/java/client/test/org/openqa/selenium/testing/drivers/ReflectionBackedDriverSupplier.java
-@@ -29,6 +29,7 @@
+diff --git a/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java b/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java
+index ac6efbf..7fbad26 100644
+--- a/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java
++++ b/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java
+@@ -27,6 +27,7 @@
+ import org.junit.runner.RunWith;
+ import org.openqa.selenium.Pages;
import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.firefox.FirefoxDriver;
- import org.openqa.selenium.firefox.FirefoxProfile;
-+import org.openqa.selenium.remote.Augmenter;
- import org.openqa.selenium.remote.DesiredCapabilities;
- import org.openqa.selenium.testing.InProject;
++import org.openqa.selenium.WebDriverException;
+ import org.openqa.selenium.environment.GlobalTestEnvironment;
+ import org.openqa.selenium.environment.InProcessTestEnvironment;
+ import org.openqa.selenium.environment.TestEnvironment;
+@@ -90,6 +91,16 @@ public WebDriver getWrappedDriver() {
+ public static WebDriver actuallyCreateDriver() {
+ WebDriver driver = storedDriver.get();
-@@ -76,7 +77,8 @@ public WebDriver get() {
- }
++ // If the driver is left in a bad state, create a new one.
++ // This happens on Android after any test that creates its own driver.
++ // Since only one instance of Chrome can run on Android at a time, the
++ // stored driver's browser is destroyed.
++ try {
++ if (driver != null)
++ driver.getCurrentUrl();
++ } catch (WebDriverException e) {
++ driver = null;
++ }
+ if (driver == null) {
+ driver = new WebDriverBuilder().get();
+ storedDriver.set(driver);
+@@ -122,4 +133,4 @@ protected boolean isIeDriverTimedOutException(IllegalStateException e) {
+ return e.getClass().getName().contains("TimedOutException");
+ }
- //TODO: Call constructor with two Capabilities arguments for all driver classes
-- return driverClass.getConstructor(Capabilities.class).newInstance(desiredCapsToUse);
-+ WebDriver d = driverClass.getConstructor(Capabilities.class).newInstance(desiredCapsToUse);
-+ return new Augmenter().augment(d);
- } catch (InvocationTargetException e) {
- throw Throwables.propagate(e.getTargetException());
- } catch (Exception e) {
+-}
+\ No newline at end of file
++}
diff --git a/java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java b/java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java
index e8a1c22..1629284 100644
--- a/java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java
« no previous file with comments | « no previous file | test-nodeps-srcs.jar » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698