diff --git a/.idea/modules.xml b/.idea/modules.xml index b0f8c1ce4bddd..cf35a2d32d7cf 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,6 @@ - diff --git a/Rakefile b/Rakefile index 5ef499498de55..df4d13cb3dbb4 100644 --- a/Rakefile +++ b/Rakefile @@ -16,7 +16,6 @@ verbose(false) # The CrazyFun build grammar. There's no magic here, just ruby require 'rake-tasks/crazy_fun' -require 'rake-tasks/crazy_fun/mappings/android' require 'rake-tasks/crazy_fun/mappings/export' require 'rake-tasks/crazy_fun/mappings/folder' require 'rake-tasks/crazy_fun/mappings/gcc' @@ -72,7 +71,6 @@ crazy_fun = CrazyFun.new # # If crazy fun doesn't know how to handle a particular output type ("java_library" # in the example above) then it will throw an exception, stopping the build -AndroidMappings.new.add_all(crazy_fun) ExportMappings.new.add_all(crazy_fun) FolderMappings.new.add_all(crazy_fun) GccMappings.new.add_all(crazy_fun) @@ -89,7 +87,7 @@ VisualStudioMappings.new.add_all(crazy_fun) # need to fall back to prebuilt binaries. The prebuilt binaries are stored in # a directory structure identical to that used in the "build" folder, but # rooted at one of the following locations: -["android/prebuilt", "cpp/prebuilt", "ide/main/prebuilt", "javascript/firefox-driver/prebuilt"].each do |pre| +["cpp/prebuilt", "ide/main/prebuilt", "javascript/firefox-driver/prebuilt"].each do |pre| crazy_fun.prebuilt_roots << pre end @@ -103,7 +101,7 @@ crazy_fun.create_tasks(Dir["**/build.desc"]) task :default => [:test] -task :all => [:'selenium-java', :'android'] +task :all => [:'selenium-java'] task :all_zip => [:'selenium-java_zip'] task :chrome => [ "//java/client/src/org/openqa/selenium/chrome" ] task :common_core => [ "//common:core" ] @@ -142,7 +140,6 @@ task :test_javascript => [ '//javascript/webdriver:test:run', '//javascript/selenium-atoms:test:run', '//javascript/selenium-core:test:run'] -task :test_android => ["//java/client/test/org/openqa/selenium/android:android-test:run"] task :test_chrome => [ "//java/client/test/org/openqa/selenium/chrome:test:run" ] task :test_chrome_atoms => [ '//javascript/atoms:test_chrome:run', @@ -179,9 +176,6 @@ task :test_support => [ "//java/client/test/org/openqa/selenium/support:LargeTests:run" ] task :test_iphone => [:test_iphone_server, '//java/client/test/org/openqa/selenium/iphone:test:run'] -task :android => [:android_client, :android_server] -task :android_client => ['//java/client/src/org/openqa/selenium/android'] -task :android_server => ['//android:android-server'] # TODO(simon): test-core should go first, but it's changing the least for now. task :test_selenium => [ :'test-rc', :'test-v1-emulation', :'test-core'] @@ -231,9 +225,6 @@ task :test_java => [ :test_java_webdriver, :test_selenium, "test_grid", - # Android should be installed and the tests should be ran - # before commits. - :test_android ] task :test_rb => [ @@ -270,13 +261,8 @@ task :clean do rm_rf 'build/' rm_rf 'iphone/build/' rm_rf 'iphone/src/objc/atoms.h' - rm_rf 'android/bin/' - rm_rf 'android/build/' - rm_rf 'android/libs/' - rm_rf 'android/client/bin/' rm_rf 'java/client/build/' rm_rf 'dist/' - Android::Clean.new() end task :dotnet => [ "//dotnet", "//dotnet:support", "//dotnet:core", "//dotnet:webdriverbackedselenium" ] @@ -671,7 +657,6 @@ task :release => [ '//java/server/src/org/openqa/selenium/server:server:zip', '//java/server/src/org/openqa/grid/selenium:selenium:zip', '//java/client/src/org/openqa/selenium:client-combined:zip', - '//android:android-server' ] do |t| # Unzip each of the deps and rename the pieces that need renaming renames = { diff --git a/android/.classpath b/android/.classpath deleted file mode 100644 index dd7a9bbdece81..0000000000000 --- a/android/.classpath +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/android/.gitignore b/android/.gitignore deleted file mode 100644 index 378eac25d3117..0000000000000 --- a/android/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build diff --git a/android/.project b/android/.project deleted file mode 100644 index a47bab00bf4d7..0000000000000 --- a/android/.project +++ /dev/null @@ -1,53 +0,0 @@ - - - android - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - - - 1350421776287 - - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-.svn - - - - 1350421776302 - - 6 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-build.desc - - - - diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml deleted file mode 100644 index 4adac2c88e149..0000000000000 --- a/android/AndroidManifest.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/android/android.eml b/android/android.eml deleted file mode 100644 index 5b067e0622c75..0000000000000 --- a/android/android.eml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/android/android.iml b/android/android.iml deleted file mode 100644 index fa1349a1a8feb..0000000000000 --- a/android/android.iml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/android/build.desc b/android/build.desc deleted file mode 100644 index 293bec8119d76..0000000000000 --- a/android/build.desc +++ /dev/null @@ -1,24 +0,0 @@ - -android_r(name = "r", - manifest = "AndroidManifest.xml", - resource = "res", - out = "gen/org/openqa/selenium/android/app") - -# Don't include the src directory: Android's build.xml will build it for us. Madness. -# We also depend on ":r" without actually building it for the same reason -java_library(name = "server", - deps = [ - ":r", - "//java/client/src/org/openqa/selenium/android:android_library", - "//java/client/src/org/openqa/selenium/browserlaunchers:proxies", - "//java/server/src/org/openqa/selenium/remote/server:server_very_core", - "//java/server/src/org/openqa/selenium/remote/server:webbit-http-api", - "//third_party/java/webbit:webbit:uber", - ]) - -android_binary(name = "android-server", - manifest = "AndroidManifest.xml", - resource_dir = "res", - deps = [ - ":server:project", - ]) diff --git a/android/build.xml b/android/build.xml deleted file mode 100644 index 9f8678bc10d79..0000000000000 --- a/android/build.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/android/gen/org/openqa/selenium/android/app/R.java b/android/gen/org/openqa/selenium/android/app/R.java deleted file mode 100644 index ccdc981968bb3..0000000000000 --- a/android/gen/org/openqa/selenium/android/app/R.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package org.openqa.selenium.android.app; - -/* This stub is for using by IDE only. It is NOT the R class actually packed into APK */ -public final class R { -} \ No newline at end of file diff --git a/android/prebuilt/android-server.apk b/android/prebuilt/android-server.apk deleted file mode 100644 index c3f37c85d6e8b..0000000000000 Binary files a/android/prebuilt/android-server.apk and /dev/null differ diff --git a/android/project.properties b/android/project.properties deleted file mode 100644 index 8da376af8d494..0000000000000 --- a/android/project.properties +++ /dev/null @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-15 diff --git a/android/res/drawable/alert_dialog_icon.png b/android/res/drawable/alert_dialog_icon.png deleted file mode 100644 index 0a7de04767eef..0000000000000 Binary files a/android/res/drawable/alert_dialog_icon.png and /dev/null differ diff --git a/android/res/drawable/ic_menu_add.png b/android/res/drawable/ic_menu_add.png deleted file mode 100644 index 6752bfd100729..0000000000000 Binary files a/android/res/drawable/ic_menu_add.png and /dev/null differ diff --git a/android/res/drawable/ic_menu_delete.png b/android/res/drawable/ic_menu_delete.png deleted file mode 100644 index 7d954943d5daf..0000000000000 Binary files a/android/res/drawable/ic_menu_delete.png and /dev/null differ diff --git a/android/res/drawable/ic_menu_share.png b/android/res/drawable/ic_menu_share.png deleted file mode 100644 index 44db9b16e2458..0000000000000 Binary files a/android/res/drawable/ic_menu_share.png and /dev/null differ diff --git a/android/res/drawable/selenium_icon.png b/android/res/drawable/selenium_icon.png deleted file mode 100644 index 127fcad4bc4d8..0000000000000 Binary files a/android/res/drawable/selenium_icon.png and /dev/null differ diff --git a/android/res/layout/single_session_layout.xml b/android/res/layout/single_session_layout.xml deleted file mode 100644 index bf94d5f662703..0000000000000 --- a/android/res/layout/single_session_layout.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml deleted file mode 100644 index 562704aafed2c..0000000000000 --- a/android/res/values/strings.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - Android WebDriver Server - - Navigate to URL ... - - Ready. - - WebDriver Ready - WebDriver not started - WebDriver already running - WebDriver stopped - WebDriver not stopped - WebDriver not running - WebDriver - - - diff --git a/android/res/xml/preferences.xml b/android/res/xml/preferences.xml deleted file mode 100644 index 524f921673034..0000000000000 --- a/android/res/xml/preferences.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - diff --git a/android/src/org/openqa/selenium/android/AndroidApkDriver.java b/android/src/org/openqa/selenium/android/AndroidApkDriver.java deleted file mode 100644 index da607559248c2..0000000000000 --- a/android/src/org/openqa/selenium/android/AndroidApkDriver.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * 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.android; - -import org.openqa.selenium.By; -import org.openqa.selenium.JavascriptExecutor; -import org.openqa.selenium.OutputType; -import org.openqa.selenium.Rotatable; -import org.openqa.selenium.ScreenOrientation; -import org.openqa.selenium.TakesScreenshot; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebDriverException; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.android.app.MainActivity; -import org.openqa.selenium.android.library.AndroidWebDriver; -import org.openqa.selenium.html5.AppCacheStatus; -import org.openqa.selenium.html5.ApplicationCache; -import org.openqa.selenium.html5.BrowserConnection; -import org.openqa.selenium.html5.LocalStorage; -import org.openqa.selenium.html5.Location; -import org.openqa.selenium.html5.LocationContext; -import org.openqa.selenium.html5.SessionStorage; -import org.openqa.selenium.html5.WebStorage; -import org.openqa.selenium.interactions.HasTouchScreen; -import org.openqa.selenium.interactions.TouchScreen; - -import java.util.List; -import java.util.Set; - -public class AndroidApkDriver implements BrowserConnection, HasTouchScreen, JavascriptExecutor, - LocationContext, Rotatable, TakesScreenshot, WebDriver, WebStorage, ApplicationCache { - - private AndroidWebDriver driver; - - public AndroidApkDriver() { - driver = MainActivity.createDriver(); - } - - public void get(String url) { - driver.get(url); - } - - public String getCurrentUrl() { - return driver.getCurrentUrl(); - } - - public String getTitle() { - return driver.getTitle(); - } - - public List findElements(By by) { - return driver.findElements(by); - } - - public WebElement findElement(By by) { - return driver.findElement(by); - } - - public String getPageSource() { - return driver.getPageSource(); - } - - public void close() { - driver.close(); - } - - public void quit() { - driver.quit(); - } - - public Set getWindowHandles() { - return driver.getWindowHandles(); - } - - public String getWindowHandle() { - return driver.getWindowHandle(); - } - - public TargetLocator switchTo() { - return driver.switchTo(); - } - - public Navigation navigate() { - return driver.navigate(); - } - - public Options manage() { - return driver.manage(); - } - - public Object executeScript(String script, Object... args) { - return driver.executeScript(script, args); - } - - public Object executeAsyncScript(String script, Object... args) { - return driver.executeAsyncScript(script, args); - } - - public boolean isOnline() { - return driver.isOnline(); - } - - public void setOnline(boolean online) throws WebDriverException { - driver.setOnline(online); - } - - public TouchScreen getTouch() { - return driver.getTouch(); - } - - public org.openqa.selenium.html5.Location location() { - return driver.location(); - } - - public void setLocation(Location location) { - driver.setLocation(location); - } - - public void rotate(ScreenOrientation orientation) { - driver.rotate(orientation); - } - - public ScreenOrientation getOrientation() { - return driver.getOrientation(); - } - - public X getScreenshotAs(OutputType target) - throws org.openqa.selenium.WebDriverException { - return driver.getScreenshotAs(target); - } - - public LocalStorage getLocalStorage() { - return driver.getLocalStorage(); - } - - public SessionStorage getSessionStorage() { - return driver.getSessionStorage(); - } - - public AppCacheStatus getStatus() { - return driver.getStatus(); - } -} diff --git a/android/src/org/openqa/selenium/android/Platform.java b/android/src/org/openqa/selenium/android/Platform.java deleted file mode 100644 index d860498ac4dec..0000000000000 --- a/android/src/org/openqa/selenium/android/Platform.java +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright 2010 WebDriver committers -Copyright 2010 Google Inc. - -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.android; - -import android.os.Build; - -/** - * Holds data about the android platform. - */ -public class Platform { - public static final int CUPCAKE = 3; - public static final int DONUT = 4; - public static final int ECLAIR = 7; - public static final int FROYO = 8; - public static final int GINGERBREAD = 9; - public static final int GINGERBREAD_MR1 = 10; - public static final int HONEYCOMB = 11; - public static final int HONEYCOMB_MR1 = 12; - public static final int HONEYCOMB_MR2 = 13; - public static final int ICE_CREAM_SANDWICH = 14; - public static final int ICE_CREAM_SANDWICH_MR1 = 15; - public static final int JELLY_BEAN = 16; - public static final int JELLY_BEAN_MR1 = 17; - - public static int sdk() { - return Integer.parseInt(Build.VERSION.SDK); - } -} diff --git a/android/src/org/openqa/selenium/android/app/MainActivity.java b/android/src/org/openqa/selenium/android/app/MainActivity.java deleted file mode 100644 index 9bc6a885ad54d..0000000000000 --- a/android/src/org/openqa/selenium/android/app/MainActivity.java +++ /dev/null @@ -1,110 +0,0 @@ -/* -Copyright 2011 Software Freedom Conservatory. - -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.android.app; - -import static org.openqa.selenium.logging.LogType.DRIVER; -import static org.openqa.selenium.remote.CapabilityType.LOGGING_PREFS; - -import android.app.Activity; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.ServiceConnection; -import android.os.Bundle; -import android.os.IBinder; - -import org.openqa.selenium.android.library.AndroidWebDriver; -import org.openqa.selenium.android.library.Logger; -import org.openqa.selenium.android.server.HttpdService; -import org.openqa.selenium.logging.LoggingPreferences; -import org.openqa.selenium.logging.LoggingHandler; -import org.openqa.selenium.remote.CapabilityType; -import org.openqa.selenium.remote.DesiredCapabilities; - -/** - * Main application activity. - */ -public class MainActivity extends Activity { - - private boolean bound; - private HttpdService httpdService; - private Intent httpdIntent; - public static final String DEBUG_MODE_ARG = "debug"; - private static Activity thisActivity; - private static DesiredCapabilities caps; - - private static AndroidWebDriver driver; - - private ServiceConnection mConnection = new ServiceConnection() { - public void onServiceConnected(ComponentName className, IBinder service) { - bound = true; - httpdService = ((org.openqa.selenium.android.server.WebDriverBinder) service).getService(); - } - - public void onServiceDisconnected(ComponentName arg0) { - bound = false; - } - }; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if (getIntent().hasExtra(DEBUG_MODE_ARG)) { - String debugArg = getIntent().getStringExtra(DEBUG_MODE_ARG); - Logger.setDebugMode(Boolean.parseBoolean(debugArg)); - } - - new Thread(new Runnable() { - public void run() { - httpdIntent = new Intent(MainActivity.this, HttpdService.class); - bindService(httpdIntent, mConnection, Context.BIND_AUTO_CREATE); - } - }).start(); - thisActivity = this; - } - - @Override - protected void onDestroy() { - if (bound) { - unbindService(mConnection); - bound = false; - } - if (httpdService != null) { - httpdService.stopService(httpdIntent); - } - stopService(httpdIntent); - this.getWindow().closeAllPanels(); - super.onDestroy(); - } - - public static void setCapabilities(DesiredCapabilities caps) { - MainActivity.caps = caps; - if (caps.getCapability(LOGGING_PREFS) != null) { - LoggingPreferences prefs = (LoggingPreferences) caps.getCapability(LOGGING_PREFS); - if (prefs.getLevel(DRIVER) != null) { - Logger.setLevel(prefs.getLevel(DRIVER)); - LoggingHandler.getInstance().attachTo(Logger.getLogger(), prefs.getLevel(DRIVER)); - } - } - } - - public static AndroidWebDriver createDriver() { - driver = new AndroidWebDriver(thisActivity); - driver.setAcceptSslCerts(caps.is(CapabilityType.ACCEPT_SSL_CERTS)); - return driver; - } -} diff --git a/android/src/org/openqa/selenium/android/server/AndroidDriverServlet.java b/android/src/org/openqa/selenium/android/server/AndroidDriverServlet.java deleted file mode 100644 index c52b1ef38de51..0000000000000 --- a/android/src/org/openqa/selenium/android/server/AndroidDriverServlet.java +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2010 WebDriver committers -Copyright 2010 Google Inc. - -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.android.server; - -import org.openqa.selenium.android.server.handler.DragElement; -import org.openqa.selenium.android.server.handler.GetCapabilities; -import org.openqa.selenium.android.server.handler.GetCssProperty; -import org.openqa.selenium.android.server.handler.GetElementDisplayed; -import org.openqa.selenium.android.server.handler.GetElementLocation; -import org.openqa.selenium.android.server.handler.GetElementSize; -import org.openqa.selenium.android.server.handler.HoverOverElement; -import org.openqa.selenium.android.server.handler.NewSession; -import org.openqa.selenium.remote.server.DefaultDriverSessions; -import org.openqa.selenium.remote.server.JsonHttpRemoteConfig; -import org.openqa.selenium.remote.server.WebbitHttpRequest; -import org.openqa.selenium.remote.server.WebbitHttpResponse; -import org.openqa.selenium.remote.server.renderer.EmptyResult; -import org.openqa.selenium.remote.server.renderer.JsonResult; -import org.openqa.selenium.remote.server.renderer.RedirectResult; -import org.openqa.selenium.remote.server.rest.ResultType; -import org.webbitserver.HttpControl; -import org.webbitserver.HttpHandler; -import org.webbitserver.HttpRequest; -import org.webbitserver.HttpResponse; - -import java.util.logging.Logger; - -public class AndroidDriverServlet implements HttpHandler { - private final JsonHttpRemoteConfig config; - private final String basePath; - - public AndroidDriverServlet(Logger log, String basePath) { - this.basePath = basePath; - config = new JsonHttpRemoteConfig(new DefaultDriverSessions(), log); - - amend(config); - } - - private void amend(JsonHttpRemoteConfig config) { - final EmptyResult emptyResult = new EmptyResult(); - final JsonResult jsonResult = new JsonResult(":response"); - - config.addNewGetMapping("/session/:sessionId/element/:id/displayed", GetElementDisplayed.class) - .on(ResultType.SUCCESS, jsonResult); - config.addNewGetMapping("/session/:sessionId/element/:id/location", GetElementLocation.class) - .on(ResultType.SUCCESS, jsonResult); - config.addNewGetMapping("/session/:sessionId/element/:id/size", GetElementSize.class) - .on(ResultType.SUCCESS, jsonResult); - config.addNewGetMapping("/session/:sessionId/element/:id/css/:propertyName", GetCssProperty.class) - .on(ResultType.SUCCESS, jsonResult); - - config.addNewPostMapping("/session/:sessionId/element/:id/hover", HoverOverElement.class) - .on(ResultType.SUCCESS, emptyResult); - config.addNewPostMapping("/session/:sessionId/element/:id/drag", DragElement.class) - .on(ResultType.SUCCESS, emptyResult); - config.addNewPostMapping("/session", NewSession.class) - .on(ResultType.SUCCESS, new RedirectResult("/session/:sessionId")); - - config.addNewGetMapping("/session/:sessionId", GetCapabilities.class) - .on(ResultType.SUCCESS, jsonResult, "application/json"); - } - - @Override - public void handleHttpRequest(HttpRequest httpRequest, HttpResponse httpResponse, - HttpControl httpControl) throws Exception { - - config.handleRequest(new WebbitHttpRequest(basePath, httpRequest), new WebbitHttpResponse(httpResponse)); - } -} diff --git a/android/src/org/openqa/selenium/android/server/HealthzHandler.java b/android/src/org/openqa/selenium/android/server/HealthzHandler.java deleted file mode 100644 index 718c0f1e9b307..0000000000000 --- a/android/src/org/openqa/selenium/android/server/HealthzHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.openqa.selenium.android.server; - -import org.openqa.selenium.remote.server.HttpStatusCodes; -import org.webbitserver.HttpControl; -import org.webbitserver.HttpHandler; -import org.webbitserver.HttpRequest; -import org.webbitserver.HttpResponse; - - -public class HealthzHandler implements HttpHandler { - - @Override - public void handleHttpRequest(HttpRequest httpRequest, HttpResponse httpResponse, - HttpControl httpControl) throws Exception { - if (!"GET".equals(httpRequest.method())) { - httpResponse.status(HttpStatusCodes.INTERNAL_SERVER_ERROR); - httpResponse.end(); - return; - } - - httpResponse.header("Content-Type", "text/plain"); - httpResponse.content("{status: 0}"); - httpResponse.end(); - } -} diff --git a/android/src/org/openqa/selenium/android/server/HttpdService.java b/android/src/org/openqa/selenium/android/server/HttpdService.java deleted file mode 100644 index b22a3517a2505..0000000000000 --- a/android/src/org/openqa/selenium/android/server/HttpdService.java +++ /dev/null @@ -1,217 +0,0 @@ -/* -Copyright 2010 WebDriver committers -Copyright 2010 Google Inc. - -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.android.server; - -import com.google.common.base.Throwables; - -import android.app.NotificationManager; -import android.app.Service; -import android.content.Context; -import android.content.Intent; -import android.os.IBinder; -import android.os.Looper; -import android.os.PowerManager; -import android.widget.Toast; - -import org.openqa.selenium.android.Platform; -import org.openqa.selenium.android.app.R; -import org.openqa.selenium.android.library.Logger; -import org.webbitserver.WebServer; -import org.webbitserver.WebServers; - -import java.util.concurrent.Executors; -import java.util.logging.Level; - -public class HttpdService extends Service { - private static final String LOG_TAG = HttpdService.class.getName(); - private static final int PORT = 8080; - - private NotificationManager notificationManager; - private PowerManager.WakeLock wakeLock; - private IBinder binder; - private HttpdThread serverThread; - - @Override - public void onCreate() { - binder = new WebDriverBinder(this); - startHttpd(); - - super.onCreate(); - } - - @Override - public IBinder onBind(Intent intent) { - return binder; - } - - /** - * Android Service Start - * - * @see android.app.Service#onStart(android.content.Intent, int) - */ - @Override - public void onStart(Intent intent, int startId) { - super.onStart(intent, startId); - } - - /** - * Android Service destroy - * - * @see android.app.Service#onDestroy() - */ - @Override - public void onDestroy() { - try { - if (wakeLock != null) { - wakeLock.release(); - wakeLock = null; - } - - if (serverThread != null) { - stopHttpd(); - // Cancel the persistent notification. - notificationManager.cancel(R.string.httpd_started); - // Tell the user we stopped. - Toast.makeText(this, getText(R.string.httpd_stopped), Toast.LENGTH_SHORT).show(); - Logger.log(Level.INFO, LOG_TAG, "onDestroy", "Httpd stopped"); - } else { - Toast.makeText(HttpdService.this, R.string.httpd_not_running, Toast.LENGTH_SHORT).show(); - } - } catch (Exception e) { - Logger.log(Level.INFO, LOG_TAG, "onDestroy", "Error stopping httpd: " + e.getMessage()); - Toast.makeText(this, getText(R.string.httpd_not_stopped), Toast.LENGTH_SHORT).show(); - } - } - - @Override - public void onLowMemory() { - Logger.log(Level.INFO, LOG_TAG, "onLowMemory", "Low on memory"); - super.onLowMemory(); - } - - /** - * Get a reference to the Webbit Server instance - */ - public WebServer getServer() { - return serverThread.getServer(); - } - - protected void configureHandlers(WebServer server) { - server.add("/wd/hub/status", new HealthzHandler()); - server.add("/wd/hub/.*", new AndroidDriverServlet(Logger.getLogger(), "/wd/hub")); - } - - public void startHttpd() { - if (serverThread != null && serverThread.isAlive()) { - Toast.makeText(HttpdService.this, R.string.httpd_already_started, Toast.LENGTH_SHORT).show(); - return; - } - - if (serverThread != null) { - Logger.log(Level.INFO, LOG_TAG, "startHttpd", "Stopping extant httpd."); - stopHttpd(); - } - - serverThread = new HttpdThread(this, PORT); - serverThread.start(); - } - - protected void stopHttpd() { - if (serverThread == null) { - return; - } - if (!serverThread.isAlive()) { - serverThread = null; - return; - } - - Logger.log(Level.FINE, LOG_TAG, "stopServer", "Httpd stopping"); - serverThread.stopLooping(); - serverThread.interrupt(); - try { - serverThread.join(); - } catch (InterruptedException e) { - throw Throwables.propagate(e); - } - serverThread = null; - } - - private class HttpdThread extends Thread { - - private final WebServer server; - private final Context context; - private Looper looper; - - public HttpdThread(Context context, int port) { - this.context = context; - - // Create the server but absolutely do not start it here - server = WebServers.createWebServer(Executors.newCachedThreadPool(), port); - - workAroundFroyoBug(); - configureHandlers(server); - } - - @Override - public void run() { - Looper.prepare(); - looper = Looper.myLooper(); - startServer(); - Looper.loop(); - } - - public WebServer getServer() { - return server; - } - - private void startServer() { - try { - // Get a wake lock to stop the cpu going to sleep - PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); - wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "WebDriver"); - wakeLock.acquire(); - - server.start(); - - notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); - Toast.makeText(HttpdService.this, R.string.httpd_started, Toast.LENGTH_SHORT).show(); - - Logger.log(Level.INFO, LOG_TAG, "startHttpd", "Httpd started"); - } catch (Exception e) { - Logger.log(Level.WARNING, LOG_TAG, "startHttpd", "Error starting httpd " + e); - Toast.makeText(context, getText(R.string.httpd_not_started), Toast.LENGTH_SHORT).show(); - throw new RuntimeException("Httpd failed to start!"); - } - } - - private void workAroundFroyoBug() { - // Workaround a Froyo bug - // http://code.google.com/p/android/issues/detail?id=9431 - if (Platform.FROYO == Platform.sdk()) { - System.setProperty("java.net.preferIPv6Addresses", "false"); - } - } - - public void stopLooping() { - if (looper == null) { - return; - } - looper.quit(); - } - } -} diff --git a/android/src/org/openqa/selenium/android/server/WebDriverBinder.java b/android/src/org/openqa/selenium/android/server/WebDriverBinder.java deleted file mode 100644 index 75407592dfabf..0000000000000 --- a/android/src/org/openqa/selenium/android/server/WebDriverBinder.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -Copyright 2011 WebDriver committers -Copyright 2011 Google Inc. - -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.android.server; - -import android.os.Binder; - -public class WebDriverBinder extends Binder { - private HttpdService httpdService; - - public WebDriverBinder(HttpdService service) { - httpdService = service; - } - - public HttpdService getService() { - return httpdService; - } -} diff --git a/android/src/org/openqa/selenium/android/server/handler/AndroidWebElementHandler.java b/android/src/org/openqa/selenium/android/server/handler/AndroidWebElementHandler.java deleted file mode 100644 index c5ecf290b2153..0000000000000 --- a/android/src/org/openqa/selenium/android/server/handler/AndroidWebElementHandler.java +++ /dev/null @@ -1,41 +0,0 @@ -/* -Copyright 2010 WebDriver committers -Copyright 2010 Google Inc. - -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.android.server.handler; - -import org.openqa.selenium.WebDriverException; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.internal.WrapsElement; -import org.openqa.selenium.remote.server.Session; -import org.openqa.selenium.remote.server.handler.WebElementHandler; - -public abstract class AndroidWebElementHandler extends WebElementHandler { - - protected AndroidWebElementHandler(Session session) { - super(session); - } - - @Override - protected WebElement getElement() { - try { - WrapsElement proxyElement = (WrapsElement) super.getElement(); - return (((WrapsElement) proxyElement.getWrappedElement()).getWrappedElement()); - } catch (Exception e) { - throw new WebDriverException("Cannot get AndroidWebElement", e); - } - } -} diff --git a/android/src/org/openqa/selenium/android/server/handler/DragElement.java b/android/src/org/openqa/selenium/android/server/handler/DragElement.java deleted file mode 100644 index afbc48292e67f..0000000000000 --- a/android/src/org/openqa/selenium/android/server/handler/DragElement.java +++ /dev/null @@ -1,51 +0,0 @@ -/* -Copyright 2010 WebDriver committers -Copyright 2010 Google Inc. - -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.android.server.handler; - -import org.openqa.selenium.android.library.AndroidWebElement; -import org.openqa.selenium.remote.server.JsonParametersAware; -import org.openqa.selenium.remote.server.Session; -import org.openqa.selenium.remote.server.rest.ResultType; - -import java.util.Map; - -public class DragElement extends AndroidWebElementHandler implements JsonParametersAware { - - private volatile int x; - private volatile int y; - - public DragElement(Session session) { - super(session); - } - - public void setJsonParameters(Map allParameters) throws Exception { - x = ((Long) allParameters.get("x")).intValue(); - y = ((Long) allParameters.get("y")).intValue(); - } - - public ResultType call() throws Exception { - AndroidWebElement element = (AndroidWebElement) getElement(); - element.dragAndDropBy(x, y); - return ResultType.SUCCESS; - } - - @Override - public String toString() { - return String.format("[drag element: %s by (x, y): (%d, %d)]", getElementAsString(), x, y); - } -} diff --git a/android/src/org/openqa/selenium/android/server/handler/GetCapabilities.java b/android/src/org/openqa/selenium/android/server/handler/GetCapabilities.java deleted file mode 100644 index 065447a2cfe2f..0000000000000 --- a/android/src/org/openqa/selenium/android/server/handler/GetCapabilities.java +++ /dev/null @@ -1,55 +0,0 @@ -/* -Copyright 2010 WebDriver committers - -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.android.server.handler; - -import com.google.common.collect.Maps; - -import android.os.Build; - -import org.openqa.selenium.Platform; -import org.openqa.selenium.remote.BrowserType; -import org.openqa.selenium.remote.CapabilityType; -import org.openqa.selenium.remote.server.Session; -import org.openqa.selenium.remote.server.handler.GetSessionCapabilities; - -import java.util.Map; - -/** - * @author berrada@google.com (Dounia Berrada) - */ -public class GetCapabilities extends GetSessionCapabilities { - - public GetCapabilities(Session session) { - super(session); - } - - @Override - protected Map describeSession(Map capabilities) { - // Creating a new map because the map received is not modifiable. - Map caps = Maps.newHashMap(); - caps.putAll(capabilities); - caps.put(CapabilityType.TAKES_SCREENSHOT, true); - caps.put(CapabilityType.BROWSER_NAME, BrowserType.ANDROID); - caps.put(CapabilityType.ROTATABLE, true); - caps.put(CapabilityType.PLATFORM, Platform.ANDROID); - caps.put(CapabilityType.SUPPORTS_ALERTS, true); - caps.put(CapabilityType.SUPPORTS_JAVASCRIPT, true); - caps.put(CapabilityType.VERSION, Build.VERSION.SDK); - caps.put(CapabilityType.ACCEPT_SSL_CERTS, true); - return caps; - } -} diff --git a/android/src/org/openqa/selenium/android/server/handler/GetCssProperty.java b/android/src/org/openqa/selenium/android/server/handler/GetCssProperty.java deleted file mode 100644 index 5fe860129d236..0000000000000 --- a/android/src/org/openqa/selenium/android/server/handler/GetCssProperty.java +++ /dev/null @@ -1,46 +0,0 @@ -/* -Copyright 2010 WebDriver committers -Copyright 2010 Google Inc. - -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.android.server.handler; - -import org.openqa.selenium.android.library.AndroidWebElement; -import org.openqa.selenium.remote.server.Session; -import org.openqa.selenium.remote.server.rest.ResultType; - -public class GetCssProperty extends AndroidWebElementHandler { - private volatile String propertyName; - - public GetCssProperty(Session session) { - super(session); - } - - public void setPropertyName(String propertyName) { - this.propertyName = propertyName; - } - - public ResultType call() throws Exception { - AndroidWebElement element = (AndroidWebElement) getElement(); - response.setValue(element.getValueOfCssProperty(propertyName)); - - return ResultType.SUCCESS; - } - - @Override - public String toString() { - return String.format("[get value of css property: %s, %s]", getElementAsString(), propertyName); - } -} diff --git a/android/src/org/openqa/selenium/android/server/handler/GetElementDisplayed.java b/android/src/org/openqa/selenium/android/server/handler/GetElementDisplayed.java deleted file mode 100644 index ff2ce3400726b..0000000000000 --- a/android/src/org/openqa/selenium/android/server/handler/GetElementDisplayed.java +++ /dev/null @@ -1,41 +0,0 @@ -/* -Copyright 2010 WebDriver committers -Copyright 2010 Google Inc. - -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.android.server.handler; - -import org.openqa.selenium.android.library.AndroidWebElement; -import org.openqa.selenium.remote.server.Session; -import org.openqa.selenium.remote.server.rest.ResultType; - -public class GetElementDisplayed extends AndroidWebElementHandler { - - public GetElementDisplayed(Session session) { - super(session); - } - - public ResultType call() throws Exception { - AndroidWebElement element = (AndroidWebElement) getElement(); - response.setValue(element.isDisplayed()); - - return ResultType.SUCCESS; - } - - @Override - public String toString() { - return String.format("[is displayed: %s]", getElementAsString()); - } -} diff --git a/android/src/org/openqa/selenium/android/server/handler/GetElementLocation.java b/android/src/org/openqa/selenium/android/server/handler/GetElementLocation.java deleted file mode 100644 index fc8804aafbfb5..0000000000000 --- a/android/src/org/openqa/selenium/android/server/handler/GetElementLocation.java +++ /dev/null @@ -1,41 +0,0 @@ -/* -Copyright 2010 WebDriver committers -Copyright 2010 Google Inc. - -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.android.server.handler; - -import org.openqa.selenium.android.library.AndroidWebElement; -import org.openqa.selenium.remote.server.Session; -import org.openqa.selenium.remote.server.rest.ResultType; - -public class GetElementLocation extends AndroidWebElementHandler { - - public GetElementLocation(Session session) { - super(session); - } - - public ResultType call() throws Exception { - AndroidWebElement element = (AndroidWebElement) getElement(); - response.setValue(element.getLocation()); - - return ResultType.SUCCESS; - } - - @Override - public String toString() { - return String.format("[get location: %s]", getElementAsString()); - } -} diff --git a/android/src/org/openqa/selenium/android/server/handler/GetElementSize.java b/android/src/org/openqa/selenium/android/server/handler/GetElementSize.java deleted file mode 100644 index 72d9c4d60a16b..0000000000000 --- a/android/src/org/openqa/selenium/android/server/handler/GetElementSize.java +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright 2010 WebDriver committers -Copyright 2010 Google Inc. - -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.android.server.handler; - -import org.openqa.selenium.android.library.AndroidWebElement; -import org.openqa.selenium.remote.server.Session; -import org.openqa.selenium.remote.server.rest.ResultType; - -public class GetElementSize extends AndroidWebElementHandler { - - public GetElementSize(Session session) { - super(session); - } - - public ResultType call() throws Exception { - AndroidWebElement element = (AndroidWebElement) getElement(); - response.setValue(element.getSize()); - return ResultType.SUCCESS; - } - - @Override - public String toString() { - return String.format("[get element size: %s]", getElementAsString()); - } -} diff --git a/android/src/org/openqa/selenium/android/server/handler/HoverOverElement.java b/android/src/org/openqa/selenium/android/server/handler/HoverOverElement.java deleted file mode 100644 index 1256f936ca74d..0000000000000 --- a/android/src/org/openqa/selenium/android/server/handler/HoverOverElement.java +++ /dev/null @@ -1,41 +0,0 @@ -/* -Copyright 2010 WebDriver committers -Copyright 2010 Google Inc. - -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.android.server.handler; - -import org.openqa.selenium.android.library.AndroidWebElement; -import org.openqa.selenium.remote.server.Session; -import org.openqa.selenium.remote.server.rest.ResultType; - -public class HoverOverElement extends AndroidWebElementHandler { - - - public HoverOverElement(Session session) { - super(session); - } - - public ResultType call() throws Exception { - AndroidWebElement element = (AndroidWebElement) getElement(); - element.hover(); - return ResultType.SUCCESS; - } - - @Override - public String toString() { - return String.format("[hover: %s]", getElementAsString()); - } -} diff --git a/android/src/org/openqa/selenium/android/server/handler/NewSession.java b/android/src/org/openqa/selenium/android/server/handler/NewSession.java deleted file mode 100644 index 8398b4b924a1f..0000000000000 --- a/android/src/org/openqa/selenium/android/server/handler/NewSession.java +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright 2011 WebDriver committers -Copyright 2011 Google Inc. - -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.android.server.handler; - -import org.openqa.selenium.android.app.MainActivity; -import org.openqa.selenium.remote.DesiredCapabilities; -import org.openqa.selenium.remote.server.DriverSessions; - -import java.util.Map; - -public class NewSession extends org.openqa.selenium.remote.server.handler.NewSession { - - public NewSession(DriverSessions allSession) { - super(allSession); - } - - @Override - public void setJsonParameters(Map allParameters) - throws Exception { - super.setJsonParameters(allParameters); - MainActivity.setCapabilities((DesiredCapabilities) getCapabilities()); - } - -} diff --git a/java/client/src/org/openqa/selenium/android/AndroidDriver.java b/java/client/src/org/openqa/selenium/android/AndroidDriver.java index 71ff18b4e602f..0bf823f2c5a62 100644 --- a/java/client/src/org/openqa/selenium/android/AndroidDriver.java +++ b/java/client/src/org/openqa/selenium/android/AndroidDriver.java @@ -49,7 +49,10 @@ /** * A driver for running tests on an Android device or emulator. + * + * @deprecated Please use either http://selendroid.io or http://appium.io instead. */ +@Deprecated public class AndroidDriver extends RemoteWebDriver implements TakesScreenshot, Rotatable, BrowserConnection, HasTouchScreen, WebStorage, LocationContext, ApplicationCache { diff --git a/java/client/test/org/openqa/selenium/android/AndroidDriverTests.java b/java/client/test/org/openqa/selenium/android/AndroidDriverTests.java deleted file mode 100644 index 841f14a31e3ca..0000000000000 --- a/java/client/test/org/openqa/selenium/android/AndroidDriverTests.java +++ /dev/null @@ -1,33 +0,0 @@ -/* -Copyright 2010 Selenium committers - -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.android; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.openqa.selenium.StandardSeleniumTests; -import org.openqa.selenium.interactions.touch.TouchTests; - -/** - * Unit tests suite for Android driver. - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - StandardSeleniumTests.class, - TouchTests.class -}) -public class AndroidDriverTests { -} diff --git a/java/client/test/org/openqa/selenium/android/build.desc b/java/client/test/org/openqa/selenium/android/build.desc deleted file mode 100644 index c6e8c6a4ad958..0000000000000 --- a/java/client/test/org/openqa/selenium/android/build.desc +++ /dev/null @@ -1,35 +0,0 @@ - -android_test(name = "android-test", - srcs = [ "AndroidDriverTests.java" ], - binary = "//android:android-server", - deps = [ - ":base", - ]) - -java_test(name = "java-test", - srcs = [ "AndroidDriverTests.java" ], - sysproperties = [ - { "selenium.browser" : "android" }, - ], - deps = [ - ":base", - ]) - -java_test(name = "on-device-test", - srcs = [ "AndroidDriverTests.java" ], - sysproperties = [ - { "selenium.browser" : "android_real_phone" }, - ], - deps = [ - ":base", - ]) - -java_library(name = "base", - srcs = [ - "**/*.java", - ], - deps = [ - "//java/client/src/org/openqa/selenium/android", - "//java/client/test/org/openqa/selenium:base", - "//java/client/test/org/openqa/selenium:tests", - ]) diff --git a/java/client/test/org/openqa/selenium/environment/InProcessTestEnvironment.java b/java/client/test/org/openqa/selenium/environment/InProcessTestEnvironment.java index 9777905054541..92de24f7abc69 100644 --- a/java/client/test/org/openqa/selenium/environment/InProcessTestEnvironment.java +++ b/java/client/test/org/openqa/selenium/environment/InProcessTestEnvironment.java @@ -19,16 +19,13 @@ import org.openqa.selenium.environment.webserver.AppServer; import org.openqa.selenium.environment.webserver.Jetty7AppServer; -import org.openqa.selenium.net.NetworkUtils; -import org.openqa.selenium.testing.drivers.Browser; public class InProcessTestEnvironment implements TestEnvironment { private AppServer appServer; public InProcessTestEnvironment() { - String servingHost = getServingHost(); - appServer = servingHost == null ? new Jetty7AppServer() : new Jetty7AppServer(servingHost); + appServer = new Jetty7AppServer(); appServer.start(); } @@ -43,15 +40,4 @@ public void stop() { public static void main(String[] args) { new InProcessTestEnvironment(); } - - private String getServingHost() { - Browser browser = Browser.detect(); - if (browser == Browser.android) { - return "10.0.2.2"; - } - if (browser == Browser.android_real_phone) { - return new NetworkUtils().getIp4NonLoopbackAddressOfThisMachine().getHostName(); - } - return null; - } } diff --git a/javascript/android-driver/build.desc b/javascript/android-atoms/build.desc similarity index 100% rename from javascript/android-driver/build.desc rename to javascript/android-atoms/build.desc diff --git a/rake-tasks/crazy_fun/mappings/android.rb b/rake-tasks/crazy_fun/mappings/android.rb deleted file mode 100644 index 7b7a9d60072bc..0000000000000 --- a/rake-tasks/crazy_fun/mappings/android.rb +++ /dev/null @@ -1,328 +0,0 @@ -require 'rake-tasks/crazy_fun/mappings/common' -require 'rake-tasks/crazy_fun/mappings/java' - -if Platform.jruby? - require 'third_party/jruby/childprocess.jar' - require 'childprocess' -end - -begin - require 'psych' -rescue LoadError - # only needed for Ruby 1.9.2 -end - -require 'yaml' - - -class AndroidMappings - def add_all(fun) - fun.add_mapping("android_r", Android::CheckResourcePreconditions.new) - fun.add_mapping("android_r", Android::CreateResourceTask.new) - - fun.add_mapping("android_binary", Android::CheckPreconditions.new) - fun.add_mapping("android_binary", Android::CreateTask.new) - fun.add_mapping("android_binary", Android::CreateShortNameTask.new) - fun.add_mapping("android_binary", Android::AddDependencies.new) - fun.add_mapping("android_binary", Android::BuildApk.new) - - fun.add_mapping("android_test", Android::CheckTestPreconditions.new) - fun.add_mapping("android_test", Android::CreateTask.new) - fun.add_mapping("android_test", CrazyFunJava::CreateTask.new) - fun.add_mapping("android_test", CrazyFunJava::CreateShortNameTask.new) - fun.add_mapping("android_test", CrazyFunJava::AddDepedencies.new) - fun.add_mapping("android_test", CrazyFunJava::TidyTempDir.new) - fun.add_mapping("android_test", CrazyFunJava::Javac.new) - fun.add_mapping("android_test", CrazyFunJava::CopyResources.new) - fun.add_mapping("android_test", CrazyFunJava::Jar.new) - fun.add_mapping("android_test", CrazyFunJava::TidyTempDir.new) - fun.add_mapping("android_test", Android::RunEmulator.new) - fun.add_mapping("android_test", CrazyFunJava::RunTests.new) - fun.add_mapping("android_test", Android::KillEmulator.new) - end -end - -module SysProperties - class AndroidSdk - def read_properties() - prop = YAML.load_file('./properties.yml') - properties = prop["default"]["android"] - if (prop[ENV["USER"]]) - properties = prop[ENV["USER"]]["android"] - end - properties - end - end -end - -# Searches for a Android SDK binary in $sdk_path/platforms/$platforms/tools/ -# or $sdk_path/platform-tools/ and returns the pathname of the binary. -# If not found in either of these directory, it raises an exception. -# -# Args: -# - name: [string] -- The name of the binary -# Returns: -# - path: [string] -- The path to the binary -def get_binary(name) - path = Platform.path_for(File.join($sdk_path, "platforms", $platform, "tools", name)) - if (not File.exist? path) - path = Platform.path_for(File.join($sdk_path, "platform-tools", name)) - # Don't throw because some don't have the SDK installed. - # raise StandardError, "Unable to find the binary: " + name if (not File.exist? path) - end - path -end - -module Android - $sys_properties = SysProperties::AndroidSdk.new - $properties = $sys_properties.read_properties() - $sdk_path = ENV['androidsdkpath'] || $properties["androidsdkpath"] - $platform = $properties["androidplatform"] - $aapt = get_binary("aapt") - if windows? - $adb = Platform.path_for(File.join($sdk_path, "platform-tools", "adb.exe")) - $builder = Platform.path_for(File.join($sdk_path, "tools", "apkbuilder.bat")) - $android = Platform.path_for(File.expand_path(File.join($sdk_path, "tools", "android.bat"))) - $emulator = Platform.path_for(File.expand_path(File.join($sdk_path, "tools", "emulator.exe"))) - else - $adb = Platform.path_for(File.join($sdk_path, "platform-tools", "adb")) - $builder = Platform.path_for(File.join($sdk_path, "tools", "apkbuilder")) - $android = Platform.path_for(File.expand_path(File.join($sdk_path, "tools", "android"))) - $emulator = Platform.path_for(File.expand_path(File.join($sdk_path, "tools", "emulator"))) - end - - class CheckPreconditions - def handle(fun, dir, args) - raise StandardError, ":name must be set" if args[:name].nil? - raise StandardError, ":deps must be set" if args[:deps].nil? - end - end - - class CheckTestPreconditions - def handle(fun, dir, args) - raise StandardError, ":name must be set" if args[:name].nil? - raise StandardError, ":deps must be set" if args[:deps].nil? - raise StandardError, ":srcs must be set" if args[:srcs].nil? - raise StandardError, ":binary must be set" if args[:binary].nil? - end - end - - class CheckResourcePreconditions - def handle(fun, dir, args) - raise StandardError, ":name must be set" if args[:name].nil? - raise StandardError, ":manifest must be set" if args[:manifest].nil? - raise StandardError, ":resource must be set" if args[:resource].nil? - raise StandardError, ":out must be set" if args[:out].nil? - end - end - - class CreateTask < Tasks - def handle(fun, dir, args) - artifact_name = output_name(dir, args[:name], "apk") - t_name = task_name(dir, args[:name]) - file artifact_name - if (args[:binary]) - task t_name => [args[:binary]] - end - desc "Compile an android apk" - task t_name => [artifact_name] - Rake::Task[t_name].out = artifact_name - end - end - - class CreateShortNameTask < Tasks - def handle(fun, dir, args) - name = task_name(dir, args[:name]) - - if (name.end_with? "#{args[:name]}:#{args[:name]}") - name = name.sub(/:.*$/, "") - task name => task_name(dir, args[:name]) - - if (!args[:srcs].nil?) - Rake::Task[name].out = output_name(dir, args[:name], "apk") - end - end - end - end - - class BaseAndroid < Tasks - def android_installed?() - android = File.expand_path($android) - File.exists?(android) - end - end - - class CreateResourceTask < BaseAndroid - def handle(fun, dir, args) - task_name = task_name(dir, args[:name]) - out = File.join(dir, args[:out], "R.java") - file out => FileList[File.join(dir, args[:resource], "**", "*")] do - if (android_installed?) - android_jar = File.expand_path(File.join($sdk_path, "platforms", $platform, "android.jar")) - manifest = File.join(dir, args[:manifest]) - resource = File.join(dir, args[:resource]) - java_r = File.join(dir, args[:out]) - cmd = "\"#{$aapt}\" package -f -M #{manifest} -S #{resource} -I #{android_jar} -J #{java_r}" - puts "Building #{task_name} as #{out}" - sh cmd - end - end - task task_name => [out] - Rake::Task[out].out = out - Rake::Task[task_name].out = out - end - end - - class AddDependencies < Tasks - def handle(fun, dir, args) - task = Rake::Task[output_name(dir, args[:name], "apk")] - add_dependencies(task, dir, args[:deps]) - add_dependencies(task, dir, args[:manifest]) - end - end - - class BuildApk < BaseAndroid - def handle(fun, dir, args) - apk = output_name(dir, args[:name], "apk") - file apk do - if (android_installed?) - android_target = $properties["androidtarget"].to_s - sh "\"#{$android}\" update project -p android/ --target #{android_target}", :verbose => true - Dir.chdir("android") do - if windows? - # ant -Dgo=go.bat overrides the go in the build file android/build.xml - sh "ant debug -Dgo=go.bat" - else - sh "ant debug; " - end - end - apk = File.join('build', 'android', 'android-server.apk') - sh "cp android/bin/MainActivity-debug.apk #{apk}" - copy_to_prebuilt(apk, fun) - else - puts apk - puts "Android SDK not installed, copying from prebuilt." - copy_prebuilt(fun, apk) - end - end - end - end - - class RunEmulator < BaseAndroid - def handle(fun, dir, args) - name = task_name(dir, args[:name]) + ":run" - task name do - STDOUT.sync = true - jar_name = Rake::Task[task_name(dir, args[:name])].out - apk = Rake::Task[args[:binary]].out - puts apk - - cmd = "\"#{$adb}\" kill-server" - puts cmd - sh cmd - - if windows? - # sh() wouldn't return on JRuby + Windows, work around by using childprocess - proc = ChildProcess.build(Platform.path_for($adb), "start-server") - proc.io.inherit! - proc.start - proc.poll_for_exit(10) - else - sh "\"#{$adb}\" start-server" - end - - android_target = $properties["androidtarget"].to_s - puts "Using Android target: " + android_target - avdname = "debug_rake_#{android_target}" - sh "echo no | \"#{$android}\" create avd --name #{avdname} --target #{android_target} -c 100M --force --abi x86" - - emulator_image = "#{$platform}-userdata-qemu.img" - - puts "Starting emulator: #{$emulator}" - - # We create the emulator with a pre-generated emulator image. - emulator_options = "" - if !linux? - emulator_options += "-no-boot-anim" - end - if !([nil, 'false'].include? ENV['headless']) - emulator_options += "-no-window" - end - - started = false - load_attempts = 1 - load_attempts_limit = 3 - while !started && load_attempts <= load_attempts_limit do - puts "Attempt to start android emulator #{load_attempts}/#{load_attempts_limit}" - begin - emulator_process = ChildProcess.build($emulator, "-avd", avdname, "-data", "build/android/#{emulator_image}", "-no-audio", "#{emulator_options}") - emulator_process.start - - sleep 5 # Wait for emulator process, just in case - - thread = Thread.new { - puts "Waiting for emulator to get started" - sh "\"#{$adb}\" -e wait-for-device" - sleep 10 - - puts "Loading package into emulator: #{apk}" - theoutput = `"#{$adb}" -e install -r #{apk}` - while (not theoutput.to_s.match(/Success/)) do - puts "Failed to load (emulator not ready?), retrying..." - sleep 5 - theoutput = `"#{$adb}" -e install -r "#{apk}"` - end - } - - end_time = Time.now + (5 * 60) - while thread.alive? && Time.now < end_time do - sleep(15) - end - - if thread.alive? - thread.terminate - emulator_process.stop - load_attempts += 1 - else - started = true - end - ensure - if !started - begin - sh "\"#{$adb}\" emu kill" - rescue - end - end - end - end - - raise LoadError.new("Emulator didn't respond properly - infrastructure failure") unless started - - sh "\"#{$adb}\" shell am start -a android.intent.action.MAIN -n org.openqa.selenium.android.app/.MainActivity" - sleep 5 - - sh "\"#{$adb}\" forward tcp:8080 tcp:8080" - end - end - end - - class KillEmulator < BaseAndroid - def handle(fun, dir, args) - name = task_name(dir, args[:name]) + ":run" - task name do - sh "\"#{$adb}\" emu kill" unless !([nil, 'false'].include? ENV['leaverunning']) - end - end - end - - class Clean < BaseAndroid - def intialize - properties = read_properties() - if (android_installed?) - android_target = "android-" << properties["androidtarget"].to_s - avdname = "debug_rake_#{android_target}" - sh "\"#{$android}\" delete avd -n #{avdname}" - end - end - end -end