 Chromium Code Reviews
 Chromium Code Reviews Issue 12760007:
  [chromedriver] Move the new chromedriver java tests to use the server.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/webdriver/
    
  
    Issue 12760007:
  [chromedriver] Move the new chromedriver java tests to use the server.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/webdriver/| Index: patch.diff | 
| =================================================================== | 
| --- patch.diff (revision 187341) | 
| +++ patch.diff (working copy) | 
| @@ -1,144 +1,55 @@ | 
| -Index: java/client/test/org/openqa/selenium/testing/drivers/ReflectionBackedDriverSupplier.java | 
| +Index: java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java | 
| =================================================================== | 
| ---- java/client/test/org/openqa/selenium/testing/drivers/ReflectionBackedDriverSupplier.java (revision 18370) | 
| -+++ java/client/test/org/openqa/selenium/testing/drivers/ReflectionBackedDriverSupplier.java (working copy) | 
| -@@ -87,7 +87,7 @@ | 
| - if (DesiredCapabilities.android().getBrowserName().equals(name)) { | 
| - className = "org.openqa.selenium.android.AndroidDriver"; | 
| - } else if (DesiredCapabilities.chrome().getBrowserName().equals(name)) { | 
| -- className = "org.openqa.selenium.testing.drivers.TestChromeDriver"; | 
| -+ className = "org.openqa.selenium.testing.drivers.TestNewChromeDriver"; | 
| - } else if (DesiredCapabilities.firefox().getBrowserName().equals(name)) { | 
| - className = getFirefoxClassName(); | 
| - } else if (DesiredCapabilities.htmlUnit().getBrowserName().equals(name)) { | 
| -Index: java/client/test/org/openqa/selenium/testing/drivers/build.desc | 
| +--- java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java (revision 18456) | 
| ++++ java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java (working copy) | 
| +@@ -74,6 +74,10 @@ | 
| + if (chromePath != null) { | 
| + options.setBinary(new File(chromePath)); | 
| + } | 
| ++ String androidPackage = System.getProperty("webdriver.chrome.android_package"); | 
| ++ if (androidPackage != null && androidPackage != "") { | 
| ++ options.setAndroidPackage(androidPackage); | 
| ++ } | 
| + | 
| + DesiredCapabilities capabilities = DesiredCapabilities.chrome(); | 
| + capabilities.setCapability(ChromeOptions.CAPABILITY, options); | 
| +Index: java/client/src/org/openqa/selenium/chrome/ChromeOptions.java | 
| =================================================================== | 
| ---- java/client/test/org/openqa/selenium/testing/drivers/build.desc (revision 18370) | 
| -+++ java/client/test/org/openqa/selenium/testing/drivers/build.desc (working copy) | 
| -@@ -9,6 +9,7 @@ | 
| - "SauceDriver.java", | 
| - "SynthesizedFirefoxDriver.java", | 
| - "TestChromeDriver.java", | 
| -+ "TestNewChromeDriver.java", | 
| - "TestIgnorance.java", | 
| - "TestInternetExplorerDriver.java", | 
| - "WebDriverBuilder.java", | 
| -Index: java/client/test/org/openqa/selenium/testing/drivers/TestNewChromeDriver.java | 
| -=================================================================== | 
| ---- java/client/test/org/openqa/selenium/testing/drivers/TestNewChromeDriver.java (revision 0) | 
| -+++ java/client/test/org/openqa/selenium/testing/drivers/TestNewChromeDriver.java (revision 0) | 
| -@@ -0,0 +1,56 @@ | 
| -+/* | 
| -+Copyright 2012 Selenium committers | 
| -+Copyright 2012 Software Freedom Conservancy | 
| -+ | 
| -+Licensed under the Apache License, Version 2.0 (the "License"); | 
| -+you may not use this file except in compliance with the License. | 
| -+You may obtain a copy of the License at | 
| -+ | 
| -+ http://www.apache.org/licenses/LICENSE-2.0 | 
| -+ | 
| -+Unless required by applicable law or agreed to in writing, software | 
| -+distributed under the License is distributed on an "AS IS" BASIS, | 
| -+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
| -+See the License for the specific language governing permissions and | 
| -+limitations under the License. | 
| -+*/ | 
| -+ | 
| -+package org.openqa.selenium.testing.drivers; | 
| -+ | 
| -+import org.openqa.selenium.Capabilities; | 
| -+import org.openqa.selenium.chrome.ChromeOptions; | 
| -+import org.openqa.selenium.chrome.NewCommandExecutor; | 
| -+import org.openqa.selenium.remote.DesiredCapabilities; | 
| -+import org.openqa.selenium.remote.RemoteWebDriver; | 
| -+ | 
| -+import java.io.File; | 
| -+ | 
| -+public class TestNewChromeDriver extends RemoteWebDriver { | 
| -+ | 
| -+ public TestNewChromeDriver() { | 
| -+ this(chromeWithCustomCapabilities(null)); | 
| +--- java/client/src/org/openqa/selenium/chrome/ChromeOptions.java (revision 18456) | 
| 
kkania
2013/03/20 23:23:45
if you're changing the revision, update the README
 
craigdh
2013/03/21 00:04:43
Switched back to the revision in the README.
 | 
| ++++ java/client/src/org/openqa/selenium/chrome/ChromeOptions.java (working copy) | 
| +@@ -65,6 +65,7 @@ | 
| + public static final String CAPABILITY = "chromeOptions"; | 
| + | 
| + private File binary; | 
| ++ private String androidPackage; | 
| + private List<String> args = Lists.newArrayList(); | 
| + private List<File> extensionFiles = Lists.newArrayList(); | 
| + private Map<String, Object> experimentalOptions = Maps.newHashMap(); | 
| +@@ -81,6 +82,16 @@ | 
| + } | 
| + | 
| + /** | 
| ++ * Sets the android package name for Chrome. The package should already exist | 
| ++ * on the Android device. | 
| ++ * | 
| ++ * @param package_name Package name of the Chrome package. | 
| ++ */ | 
| ++ public void setAndroidPackage(String package_name) { | 
| ++ androidPackage = checkNotNull(package_name); | 
| + } | 
| + | 
| -+ public TestNewChromeDriver(Capabilities capabilities) { | 
| -+ super(new NewCommandExecutor(), chromeWithCustomCapabilities(capabilities)); | 
| -+ } | 
| -+ | 
| -+ private static DesiredCapabilities chromeWithCustomCapabilities( | 
| -+ Capabilities originalCapabilities) { | 
| -+ ChromeOptions options = new ChromeOptions(); | 
| -+ options.addArguments("disable-extensions"); | 
| -+ String chromePath = System.getProperty("webdriver.chrome.binary"); | 
| -+ if (chromePath != null) { | 
| -+ options.setBinary(new File(chromePath)); | 
| ++ /** | 
| + * @param arguments The arguments to use when starting Chrome. | 
| + * @see #addArguments(java.util.List) | 
| + */ | 
| +@@ -147,6 +158,10 @@ | 
| + options.put("binary", binary.getPath()); | 
| + } | 
| + | 
| ++ if (androidPackage != null && androidPackage != "") { | 
| 
kkania
2013/03/20 23:23:45
what's the point of androidPackage != ""?
 
craigdh
2013/03/21 00:04:43
Not needed. Removed.
 | 
| ++ options.put("android_package", androidPackage); | 
| + } | 
| + | 
| -+ DesiredCapabilities capabilities = DesiredCapabilities.chrome(); | 
| -+ capabilities.setCapability(ChromeOptions.CAPABILITY, options); | 
| -+ | 
| -+ if (originalCapabilities != null) { | 
| -+ capabilities.merge(originalCapabilities); | 
| -+ } | 
| -+ | 
| -+ return capabilities; | 
| -+ } | 
| -+} | 
| -Index: java/client/src/org/openqa/selenium/chrome/NewCommandExecutor.java | 
| -=================================================================== | 
| ---- java/client/src/org/openqa/selenium/chrome/NewCommandExecutor.java (revision 0) | 
| -+++ java/client/src/org/openqa/selenium/chrome/NewCommandExecutor.java (revision 0) | 
| -@@ -0,0 +1,53 @@ | 
| -+/* | 
| -+Copyright 2012 Selenium committers | 
| -+Copyright 2012 Software Freedom Conservancy | 
| -+ | 
| -+Licensed under the Apache License, Version 2.0 (the "License"); | 
| -+you may not use this file except in compliance with the License. | 
| -+You may obtain a copy of the License at | 
| -+ | 
| -+ http://www.apache.org/licenses/LICENSE-2.0 | 
| -+ | 
| -+Unless required by applicable law or agreed to in writing, software | 
| -+distributed under the License is distributed on an "AS IS" BASIS, | 
| -+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
| -+See the License for the specific language governing permissions and | 
| -+limitations under the License. | 
| -+*/ | 
| -+ | 
| -+package org.openqa.selenium.chrome; | 
| -+ | 
| -+import org.openqa.selenium.remote.BeanToJsonConverter; | 
| -+import org.openqa.selenium.remote.Command; | 
| -+import org.openqa.selenium.remote.CommandExecutor; | 
| -+import org.openqa.selenium.remote.JsonToBeanConverter; | 
| -+import org.openqa.selenium.remote.Response; | 
| -+ | 
| -+import java.io.IOException; | 
| -+import java.util.HashMap; | 
| -+import java.util.Map; | 
| -+ | 
| -+/** | 
| -+ * Executes a ChromeDriver command using the new ChromeDriver. | 
| -+ */ | 
| -+public class NewCommandExecutor implements CommandExecutor { | 
| -+ | 
| -+ static { | 
| -+ System.loadLibrary("chromedriver"); | 
| -+ } | 
| -+ | 
| -+ @Override | 
| -+ public Response execute(Command command) throws IOException { | 
| -+ Map<String, Object> jsonCommand = new HashMap<String, Object>(); | 
| -+ jsonCommand.put("name", command.getName()); | 
| -+ jsonCommand.put("parameters", command.getParameters()); | 
| -+ String id = ""; | 
| -+ if (command.getSessionId() != null) | 
| -+ id = command.getSessionId().toString(); | 
| -+ jsonCommand.put("sessionId", id); | 
| -+ String responseText = execute(new BeanToJsonConverter().convert(jsonCommand)); | 
| -+ return new JsonToBeanConverter().convert(Response.class, responseText); | 
| -+ } | 
| -+ | 
| -+ private static native String execute(String command); | 
| -+} | 
| + options.put("args", ImmutableList.copyOf(args)); | 
| + | 
| + List<String> extensions = Lists.newArrayListWithExpectedSize( |