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

Unified Diff: tools/testing/dart/browser_controller.dart

Issue 29773006: Changes to run tests on Dartium content shell on Android. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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
Index: tools/testing/dart/browser_controller.dart
===================================================================
--- tools/testing/dart/browser_controller.dart (revision 28998)
+++ tools/testing/dart/browser_controller.dart (working copy)
@@ -531,6 +531,45 @@
String toString() => "chromeOnAndroid";
}
+
+class ContentShellOnAndroid extends Browser {
+ static const String viewAction = 'android.intent.action.VIEW';
+ static const String contentShellPackage = 'org.chromium.content_shell_apk';
+
+ AdbDevice _adbDevice;
+
+ ContentShellOnAndroid(this._adbDevice);
+
+ Future<bool> start(String url) {
+ var contentShellIntent = new Intent(
+ viewAction, contentShellPackage, '.ContentShellActivity', url);
+
+ return _adbDevice.waitForBootCompleted().then((_) {
+ return _adbDevice.forceStop(contentShellIntent.package);
+ }).then((_) {
+ return _adbDevice.killAll();
+ }).then((_) {
+ return _adbDevice.adbRoot();
+ }).then((_) {
+ return _adbDevice.setProp("DART_FORWARDING_PRINT", "1");
+ }).then((_) {
+ return _adbDevice.startActivity(contentShellIntent).then((_) => true);
+ });
+ }
+
+ Future<bool> close() {
+ if (_adbDevice != null) {
+ return _adbDevice.forceStop(contentShellPackage).then((_) {
+ return _adbDevice.killAll().then((_) => true);
+ });
+ }
+ return new Future.value(true);
+ }
+
+ String toString() => "ContentShellOnAndroid";
+}
+
+
class Firefox extends Browser {
static const String enablePopUp =
'user_pref("dom.disable_open_during_load", false);';
@@ -690,7 +729,8 @@
// instead.
bool useIframe =
!Browser.BROWSERS_WITH_WINDOW_SUPPORT.contains(browserName);
- testingServer = new BrowserTestingServer(localIp, useIframe);
+ testingServer = new BrowserTestingServer(
+ globalConfiguration, localIp, useIframe);
return testingServer.start().then((_) {
testingServer.testDoneCallBack = handleResults;
testingServer.testStartedCallBack = handleStarted;
@@ -718,7 +758,12 @@
// TODO(kustermann): This is a hackisch way to accomplish it and should
// be encapsulated
var browsersCompleter = new Completer();
- if (browserName == 'chromeOnAndroid') {
+ var androidBrowserCreationMapping = {
+ 'chromeOnAndroid' : (AdbDevice device) => new AndroidChrome(device),
+ 'ContentShellOnAndroid' : (AdbDevice device) =>
+ new ContentShellOnAndroid(device),
+ };
+ if (androidBrowserCreationMapping.containsKey(browserName)) {
AdbHelper.listDevices().then((deviceIds) {
if (deviceIds.length > 0) {
var browsers = [];
@@ -726,7 +771,7 @@
var id = "BROWSER$i";
var device = new AdbDevice(deviceIds[i]);
adbDeviceMapping[id] = device;
- var browser = new AndroidChrome(device);
+ var browser = androidBrowserCreationMapping[browserName](device);
browsers.add(browser);
// We store this in case we need to kill the browser.
browser.id = id;
@@ -839,6 +884,8 @@
var new_id = id;
if (browserName == 'chromeOnAndroid') {
browser = new AndroidChrome(adbDeviceMapping[id]);
+ } else if (browserName == 'ContentShellOnAndroid') {
+ browser = new ContentShellOnAndroid(adbDeviceMapping[id]);
} else {
browserStatus.remove(id);
browser = getInstance();
@@ -954,6 +1001,7 @@
}
class BrowserTestingServer {
+ final Map globalConfiguration;
/// Interface of the testing server:
///
/// GET /driver/BROWSER_ID -- This will get the driver page to fetch
@@ -985,10 +1033,11 @@
Function testStartedCallBack;
Function nextTestCallBack;
- BrowserTestingServer(this.localIp, this.useIframe);
+ BrowserTestingServer(this.globalConfiguration, this.localIp, this.useIframe);
Future start() {
- return HttpServer.bind(localIp, 0).then((createdServer) {
+ int port = globalConfiguration['test_driver_port'];
+ return HttpServer.bind(localIp, port).then((createdServer) {
httpServer = createdServer;
void handler(HttpRequest request) {
// Don't allow caching of resources from the browser controller, i.e.,
@@ -1039,7 +1088,8 @@
// Set up the error reporting server that enables us to send back
// errors from the browser.
- return HttpServer.bind(localIp, 0).then((createdReportServer) {
+ port = globalConfiguration['test_driver_error_port'];
+ return HttpServer.bind(localIp, port).then((createdReportServer) {
errorReportingServer = createdReportServer;
void errorReportingHandler(HttpRequest request) {
StringBuffer buffer = new StringBuffer();

Powered by Google App Engine
This is Rietveld 408576698