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

Side by Side Diff: tools/testing/dart/browser_controller.dart

Issue 18065003: Update checked in binary to version 0.5.19.0 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/release/version.dart ('k') | tools/testing/dart/http_server.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 library browser; 4 library browser;
5 5
6 import "dart:async"; 6 import "dart:async";
7 import "dart:core"; 7 import "dart:core";
8 import "dart:io"; 8 import "dart:io";
9 9
10 import 'android.dart'; 10 import 'android.dart';
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 if (line.contains("CFBundleShortVersionString")) { 260 if (line.contains("CFBundleShortVersionString")) {
261 versionOnNextLine = true; 261 versionOnNextLine = true;
262 } 262 }
263 } 263 }
264 return null; 264 return null;
265 }); 265 });
266 } 266 }
267 267
268 void _createLaunchHTML(var path, var url) { 268 void _createLaunchHTML(var path, var url) {
269 var file = new File("${path}/launch.html"); 269 var file = new File("${path}/launch.html");
270 var randomFile = file.openSync(FileMode.WRITE); 270 var randomFile = file.openSync(mode: FileMode.WRITE);
271 var content = '<script language="JavaScript">location = "$url"</script>'; 271 var content = '<script language="JavaScript">location = "$url"</script>';
272 randomFile.writeStringSync(content); 272 randomFile.writeStringSync(content);
273 randomFile.close(); 273 randomFile.close();
274 } 274 }
275 275
276 Future<bool> start(String url) { 276 Future<bool> start(String url) {
277 _logEvent("Starting Safari browser on: $url"); 277 _logEvent("Starting Safari browser on: $url");
278 return allowPopUps().then((success) { 278 return allowPopUps().then((success) {
279 if (!success) { 279 if (!success) {
280 return false; 280 return false;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 */ 317 */
318 const String binary = "google-chrome"; 318 const String binary = "google-chrome";
319 319
320 Future<bool> start(String url) { 320 Future<bool> start(String url) {
321 _logEvent("Starting chrome browser on: $url"); 321 _logEvent("Starting chrome browser on: $url");
322 // Get the version and log that. 322 // Get the version and log that.
323 return Process.run(binary, ["--version"]).then((var versionResult) { 323 return Process.run(binary, ["--version"]).then((var versionResult) {
324 if (versionResult.exitCode != 0) { 324 if (versionResult.exitCode != 0) {
325 _logEvent("Failed to chrome get version"); 325 _logEvent("Failed to chrome get version");
326 _logEvent("Make sure $binary is a valid program for running chrome"); 326 _logEvent("Make sure $binary is a valid program for running chrome");
327 return new Future.immediate(false); 327 return new Future.value(false);
328 } 328 }
329 version = versionResult.stdout; 329 version = versionResult.stdout;
330 _logEvent("Got version: $version"); 330 _logEvent("Got version: $version");
331 331
332 return new Directory('').createTemp().then((userDir) { 332 return new Directory('').createTemp().then((userDir) {
333 _cleanup = () { userDir.deleteSync(recursive: true); }; 333 _cleanup = () { userDir.deleteSync(recursive: true); };
334 var args = ["--user-data-dir=${userDir.path}", url, 334 var args = ["--user-data-dir=${userDir.path}", url,
335 "--disable-extensions", "--disable-popup-blocking", 335 "--disable-extensions", "--disable-popup-blocking",
336 "--bwsi", "--no-first-run"]; 336 "--bwsi", "--no-first-run"];
337 return startBrowser(binary, args); 337 return startBrowser(binary, args);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 return _adbDevice.startActivity(chromeIntent).then((_) => true); 399 return _adbDevice.startActivity(chromeIntent).then((_) => true);
400 }); 400 });
401 } 401 }
402 402
403 Future<bool> close() { 403 Future<bool> close() {
404 if (_adbDevice != null) { 404 if (_adbDevice != null) {
405 return _adbDevice.forceStop(chromePackage).then((_) { 405 return _adbDevice.forceStop(chromePackage).then((_) {
406 return _adbDevice.killAll().then((_) => true); 406 return _adbDevice.killAll().then((_) => true);
407 }); 407 });
408 } 408 }
409 return new Future.immediate(true); 409 return new Future.value(true);
410 } 410 }
411 411
412 String toString() => "chromeOnAndroid"; 412 String toString() => "chromeOnAndroid";
413 } 413 }
414 414
415 class Firefox extends Browser { 415 class Firefox extends Browser {
416 /** 416 /**
417 * The binary used to run firefox - changing this can be nececcary for 417 * The binary used to run firefox - changing this can be nececcary for
418 * testing or using non standard firefox installation. 418 * testing or using non standard firefox installation.
419 */ 419 */
420 const String binary = "firefox"; 420 const String binary = "firefox";
421 421
422 const String enablePopUp = 422 const String enablePopUp =
423 'user_pref("dom.disable_open_during_load", false);'; 423 'user_pref("dom.disable_open_during_load", false);';
424 const String disableDefaultCheck = 424 const String disableDefaultCheck =
425 'user_pref("browser.shell.checkDefaultBrowser", false);'; 425 'user_pref("browser.shell.checkDefaultBrowser", false);';
426 426
427 Future _createPreferenceFile(var path) { 427 Future _createPreferenceFile(var path) {
428 var file = new File("${path.toString()}/user.js"); 428 var file = new File("${path.toString()}/user.js");
429 var randomFile = file.openSync(FileMode.WRITE); 429 var randomFile = file.openSync(mode: FileMode.WRITE);
430 randomFile.writeStringSync(enablePopUp); 430 randomFile.writeStringSync(enablePopUp);
431 randomFile.writeStringSync(disableDefaultCheck); 431 randomFile.writeStringSync(disableDefaultCheck);
432 randomFile.close(); 432 randomFile.close();
433 } 433 }
434 434
435 435
436 Future<bool> start(String url) { 436 Future<bool> start(String url) {
437 _logEvent("Starting firefox browser on: $url"); 437 _logEvent("Starting firefox browser on: $url");
438 // Get the version and log that. 438 // Get the version and log that.
439 return Process.run(binary, ["--version"]).then((var versionResult) { 439 return Process.run(binary, ["--version"]).then((var versionResult) {
440 if (versionResult.exitCode != 0) { 440 if (versionResult.exitCode != 0) {
441 _logEvent("Failed to firefox get version"); 441 _logEvent("Failed to firefox get version");
442 _logEvent("Make sure $binary is a valid program for running firefox"); 442 _logEvent("Make sure $binary is a valid program for running firefox");
443 return new Future.immediate(false); 443 return new Future.value(false);
444 } 444 }
445 version = versionResult.stdout; 445 version = versionResult.stdout;
446 _logEvent("Got version: $version"); 446 _logEvent("Got version: $version");
447 447
448 return new Directory('').createTemp().then((userDir) { 448 return new Directory('').createTemp().then((userDir) {
449 _createPreferenceFile(userDir.path); 449 _createPreferenceFile(userDir.path);
450 _cleanup = () { userDir.deleteSync(recursive: true); }; 450 _cleanup = () { userDir.deleteSync(recursive: true); };
451 var args = ["-profile", "${userDir.path}", 451 var args = ["-profile", "${userDir.path}",
452 "-no-remote", "-new-instance", url]; 452 "-no-remote", "-new-instance", url];
453 return startBrowser(binary, args); 453 return startBrowser(binary, args);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 793
794 BrowserTestingServer(this.local_ip, this.useIframe); 794 BrowserTestingServer(this.local_ip, this.useIframe);
795 795
796 Future start() { 796 Future start() {
797 return HttpServer.bind(local_ip, 0).then((createdServer) { 797 return HttpServer.bind(local_ip, 0).then((createdServer) {
798 httpServer = createdServer; 798 httpServer = createdServer;
799 void handler(HttpRequest request) { 799 void handler(HttpRequest request) {
800 DebugLogger.info("Handling request to: ${request.uri.path}"); 800 DebugLogger.info("Handling request to: ${request.uri.path}");
801 if (request.uri.path.startsWith(reportPath)) { 801 if (request.uri.path.startsWith(reportPath)) {
802 var browserId = request.uri.path.substring(reportPath.length + 1); 802 var browserId = request.uri.path.substring(reportPath.length + 1);
803 var testId = int.parse(request.queryParameters["id"].split("=")[1]); 803 var testId =
804 804 int.parse(request.uri.queryParameters["id"].split("=")[1]);
805 handleReport(request, browserId, testId); 805 handleReport(request, browserId, testId);
806 // handleReport will asynchroniously fetch the data and will handle 806 // handleReport will asynchroniously fetch the data and will handle
807 // the closing of the streams. 807 // the closing of the streams.
808 return; 808 return;
809 } 809 }
810 var textResponse = ""; 810 var textResponse = "";
811 if (request.uri.path.startsWith(driverPath)) { 811 if (request.uri.path.startsWith(driverPath)) {
812 var browserId = request.uri.path.substring(driverPath.length + 1); 812 var browserId = request.uri.path.substring(driverPath.length + 1);
813 textResponse = getDriverPage(browserId); 813 textResponse = getDriverPage(browserId);
814 } else if (request.uri.path.startsWith(nextTestPath)) { 814 } else if (request.uri.path.startsWith(nextTestPath)) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 925
926 function newTaskHandler() { 926 function newTaskHandler() {
927 if (this.readyState == this.DONE) { 927 if (this.readyState == this.DONE) {
928 if (this.status == 200) { 928 if (this.status == 200) {
929 if (this.responseText == '$waitSignal') { 929 if (this.responseText == '$waitSignal') {
930 setTimeout(getNextTask, 500); 930 setTimeout(getNextTask, 500);
931 } else if (this.responseText == '$terminateSignal') { 931 } else if (this.responseText == '$terminateSignal') {
932 // Don't do anything, we will be killed shortly. 932 // Don't do anything, we will be killed shortly.
933 } else { 933 } else {
934 var elapsed = new Date() - start; 934 var elapsed = new Date() - start;
935 reportError('Done getting task at: ' + elapsed);
936 // TODO(ricow): Do something more clever here. 935 // TODO(ricow): Do something more clever here.
937 if (nextTask != undefined) alert('This is really bad'); 936 if (nextTask != undefined) alert('This is really bad');
938 // The task is send to us as: 937 // The task is send to us as:
939 // URL#ID 938 // URL#ID
940 var split = this.responseText.split('#'); 939 var split = this.responseText.split('#');
941 var nextTask = split[0]; 940 var nextTask = split[0];
942 current_id = split[1]; 941 current_id = split[1];
942 reportError('Done getting task : ' + elapsed);
943 did_start = false; 943 did_start = false;
944 run(nextTask); 944 run(nextTask);
945 } 945 }
946 } else { 946 } else {
947 reportError('Could not contact the server and get a new task'); 947 reportError('Could not contact the server and get a new task');
948 } 948 }
949 } 949 }
950 } 950 }
951 951
952 function getNextTask() { 952 function getNextTask() {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 </head> 1045 </head>
1046 <body onload="startTesting()"> 1046 <body onload="startTesting()">
1047 Dart test driver, number of tests: <div id="number"></div> 1047 Dart test driver, number of tests: <div id="number"></div>
1048 <iframe id="embedded_iframe"></iframe> 1048 <iframe id="embedded_iframe"></iframe>
1049 </body> 1049 </body>
1050 </html> 1050 </html>
1051 """; 1051 """;
1052 return driverContent; 1052 return driverContent;
1053 } 1053 }
1054 } 1054 }
OLDNEW
« no previous file with comments | « tools/release/version.dart ('k') | tools/testing/dart/http_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698