| diff --git a/java/client/src/org/openqa/selenium/chrome/ChromeOptions.java b/java/client/src/org/openqa/selenium/chrome/ChromeOptions.java |
| index 423cfe9..67e0ddb 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 @@ |
| public static final String CAPABILITY = "chromeOptions"; |
| |
| private String binary; |
| + private String androidPackage; |
| private List<String> args = Lists.newArrayList(); |
| private List<File> extensionFiles = Lists.newArrayList(); |
| private Map<String, Object> experimentalOptions = Maps.newHashMap(); |
| @@ -98,6 +99,16 @@ public void setBinary(String path) { |
| } |
| |
| /** |
| + * Sets the Android package name for Chrome. The package should already exist |
| + * on the Android device. |
| + * |
| + * @param package_name Name of Chrome's Android package. |
| + */ |
| + public void setAndroidPackage(String package_name) { |
| + androidPackage = checkNotNull(package_name); |
| + } |
| + |
| + /** |
| * @param arguments The arguments to use when starting Chrome. |
| * @see #addArguments(java.util.List) |
| */ |
| @@ -176,6 +187,10 @@ public JSONObject toJson() throws IOException, JSONException { |
| options.put("binary", binary); |
| } |
| |
| + if (androidPackage != null) { |
| + options.put("androidPackage", androidPackage); |
| + } |
| + |
| options.put("args", ImmutableList.copyOf(args)); |
| |
| List<String> extensions = Lists.newArrayListWithExpectedSize( |
| diff --git a/java/client/src/org/openqa/selenium/remote/HttpCommandExecutor.java b/java/client/src/org/openqa/selenium/remote/HttpCommandExecutor.java |
| index a486201..036a060 100644 |
| --- a/java/client/src/org/openqa/selenium/remote/HttpCommandExecutor.java |
| +++ b/java/client/src/org/openqa/selenium/remote/HttpCommandExecutor.java |
| @@ -64,6 +64,7 @@ |
| import static org.openqa.selenium.remote.DriverCommand.*; |
| |
| public class HttpCommandExecutor implements CommandExecutor, NeedsLocalLogs { |
| + private static final int SO_TIMEOUT = Integer.parseInt(System.getProperty("http.socket.timeout", "60")) * 1000; |
| |
| private static final int MAX_REDIRECTS = 10; |
| |
| @@ -291,6 +292,11 @@ public Response execute(Command command) throws IOException { |
| httpMethod.addHeader("Cache-Control", "no-cache"); |
| } |
| |
| + // Set the timeout for waiting response from server side. |
| + HttpParams params = new BasicHttpParams(); |
| + params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, SO_TIMEOUT); |
| + httpMethod.setParams(params); |
| + |
| log(LogType.PROFILER, new HttpProfilerLogEntry(command.getName(), true)); |
| HttpResponse response = fallBackExecute(context, httpMethod); |
| log(LogType.PROFILER, new HttpProfilerLogEntry(command.getName(), false)); |
| diff --git a/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java b/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java |
| index e5beaf1..5cb9047 100755 |
| --- a/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java |
| +++ b/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java |
| @@ -28,6 +28,7 @@ |
| import org.junit.runner.RunWith; |
| import org.openqa.selenium.Pages; |
| import org.openqa.selenium.WebDriver; |
| +import org.openqa.selenium.WebDriverException; |
| import org.openqa.selenium.environment.GlobalTestEnvironment; |
| import org.openqa.selenium.environment.InProcessTestEnvironment; |
| import org.openqa.selenium.environment.TestEnvironment; |
| @@ -86,7 +87,7 @@ protected void finished(Description description) { |
| logger.info("<<< Finished " + description); |
| } |
| }; |
| - |
| + |
| public WebDriver getWrappedDriver() { |
| return storedDriver.get(); |
| } |
| @@ -94,6 +95,22 @@ public WebDriver getWrappedDriver() { |
| public static WebDriver actuallyCreateDriver() { |
| WebDriver driver = storedDriver.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) { |
| + try { |
| + driver.quit(); |
| + } catch (RuntimeException ignored) { |
| + System.exit(1); |
| + } |
| + driver = null; |
| + } |
| + |
| if (driver == null) { |
| driver = new WebDriverBuilder().get(); |
| storedDriver.set(driver); |
| @@ -107,7 +124,6 @@ public static void removeDriver() { |
| } |
| |
| WebDriver current = storedDriver.get(); |
| - |
| if (current == null) { |
| return; |
| } |
| @@ -115,9 +131,8 @@ public static void removeDriver() { |
| try { |
| current.quit(); |
| } catch (RuntimeException ignored) { |
| - // fall through |
| + System.exit(1); |
| } |
| - |
| storedDriver.remove(); |
| } |
| |
| @@ -126,4 +141,4 @@ protected boolean isIeDriverTimedOutException(IllegalStateException e) { |
| return e.getClass().getName().contains("TimedOutException"); |
| } |
| |
| -} |
| \ 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 f8e3e02..58bd0cc 100755 |
| --- a/java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java |
| +++ b/java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java |
| @@ -76,6 +76,10 @@ private static DesiredCapabilities chromeWithCustomCapabilities( |
| if (chromePath != null) { |
| options.setBinary(new File(chromePath)); |
| } |
| + String androidPackage = System.getProperty("webdriver.chrome.android_package"); |
| + if (androidPackage != null) { |
| + options.setAndroidPackage(androidPackage); |
| + } |
| |
| DesiredCapabilities capabilities = DesiredCapabilities.chrome(); |
| capabilities.setCapability(ChromeOptions.CAPABILITY, options); |
| diff --git a/java/client/test/org/openqa/selenium/testing/drivers/TestIgnorance.java b/java/client/test/org/openqa/selenium/testing/drivers/TestIgnorance.java |
| index c04d79d..8fe0370 100644 |
| --- a/java/client/test/org/openqa/selenium/testing/drivers/TestIgnorance.java |
| +++ b/java/client/test/org/openqa/selenium/testing/drivers/TestIgnorance.java |
| @@ -92,8 +92,28 @@ public boolean isIgnored(AnnotatedElement element) { |
| return ignored; |
| } |
| |
| - // JUnit 4 |
| public boolean isIgnored(FrameworkMethod method, Object test) { |
| + String name = test.getClass().getSimpleName() + "." + method.getName(); |
| + String filter = System.getProperty("filter", ".*"); |
| + String[] patternGroups = filter.split("-"); |
| + String[] positivePatterns = patternGroups[0].split(":"); |
| + String[] negativePatterns = new String[0]; |
| + if (patternGroups.length > 1) |
| + negativePatterns = patternGroups[1].split(":"); |
| + |
| + for (int i = 0; i < negativePatterns.length; i++) { |
| + if (name.matches(negativePatterns[i])) |
| + return true; |
| + } |
| + for (int i = 0; i < positivePatterns.length; i++) { |
| + if (name.matches(positivePatterns[i])) |
| + return false; |
| + } |
| + return true; |
| + } |
| + |
| + // JUnit 4 |
| + public boolean isIgnoredOld(FrameworkMethod method, Object test) { |
| boolean ignored = ignoreComparator.shouldIgnore(test.getClass().getAnnotation(Ignore.class)) || |
| ignoreComparator.shouldIgnore(method.getMethod().getAnnotation(Ignore.class)); |
| |
| @@ -220,4 +240,4 @@ private void addIgnoresForBrowser(Browser browser, IgnoreComparator comparator) |
| } |
| } |
| |
| -} |
| \ No newline at end of file |
| +} |
| diff --git a/rake-tasks/crazy_fun/mappings/java.rb b/rake-tasks/crazy_fun/mappings/java.rb |
| index f723db2..5876840 100644 |
| --- a/rake-tasks/crazy_fun/mappings/java.rb |
| +++ b/rake-tasks/crazy_fun/mappings/java.rb |
| @@ -34,6 +34,7 @@ class JavaMappings |
| fun.add_mapping("java_test", CrazyFunJava::RunTests.new) |
| fun.add_mapping("java_test", CrazyFunJava::CreateSourceJar.new) |
| fun.add_mapping("java_test", CrazyFunJava::CreateUberJar.new) |
| + fun.add_mapping("java_test", CrazyFunJava::CreateProjectSourceJar.new) |
| fun.add_mapping("java_test", CrazyFunJava::CreateProjectJar.new) |
| end |
| end |