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

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

Issue 22420002: Add support for ie in the browser controller (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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
« tools/test.dart ('K') | « tools/test.dart ('k') | no next file » | 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 Browser(); 48 Browser();
49 49
50 factory Browser.byName(String name) { 50 factory Browser.byName(String name) {
51 if (name == 'ff' || name == 'firefox') { 51 if (name == 'ff' || name == 'firefox') {
52 return new Firefox(); 52 return new Firefox();
53 } else if (name == 'chrome') { 53 } else if (name == 'chrome') {
54 return new Chrome(); 54 return new Chrome();
55 } else if (name == 'safari') { 55 } else if (name == 'safari') {
56 return new Safari(); 56 return new Safari();
57 } else if (name.startsWith('ie')) {
58 return new IE();
57 } else { 59 } else {
58 throw "Non supported browser"; 60 throw "Non supported browser";
59 } 61 }
60 } 62 }
61 63
62 static const List<String> SUPPORTED_BROWSERS = 64 static const List<String> SUPPORTED_BROWSERS =
63 const ['safari', 'ff', 'firefox', 'chrome']; 65 const ['safari', 'ff', 'firefox', 'chrome'];
64 66
65 static const List<String> BROWSERS_WITH_WINDOW_SUPPORT = 67 static const List<String> BROWSERS_WITH_WINDOW_SUPPORT =
66 const ['safari', 'ff', 'firefox', 'chrome']; 68 const ['safari', 'ff', 'firefox', 'chrome'];
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 }); 342 });
341 }).catchError((e) { 343 }).catchError((e) {
342 _logEvent("Running $binary --version failed with $e"); 344 _logEvent("Running $binary --version failed with $e");
343 return false; 345 return false;
344 }); 346 });
345 } 347 }
346 348
347 String toString() => "Chrome"; 349 String toString() => "Chrome";
348 } 350 }
349 351
352 class IE extends Browser {
353
354 static const String binary =
355 "c:\\Program Files\\Internet Explorer\\iexplore.exe";
356
357 Future<String> getVersion() {
358 var args = ["query",
359 "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Internet Explorer",
360 "/v",
361 "version"];
362 return Process.run("reg", args).then((result) {
363 if (result.exitCode == 0) {
364 // The string we get back looks like this:
365 // HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer
366 // version REG_SZ 9.0.8112.16421
367 var findString = "REG_SZ";
368 var index = result.stdout.indexOf("REG_SZ") + findString.length;
369 if (index > 0) {
370 return result.stdout.substring(index).trim();
371 }
372 }
373 return "Could not get the version of internet explorer";
374 });
375 }
376
377
378 Future<bool> start(String url) {
379 _logEvent("Starting ie browser on: $url");
380 // Get the version and log that.
381 return getVersion().then((version) {
382 _logEvent("Got version: $version");
383 return startBrowser(binary, [url]);
384 });
385 }
386 String toString() => "IE";
387 }
388
389
350 class AndroidChrome extends Browser { 390 class AndroidChrome extends Browser {
351 static const String viewAction = 'android.intent.action.VIEW'; 391 static const String viewAction = 'android.intent.action.VIEW';
352 static const String mainAction = 'android.intent.action.MAIN'; 392 static const String mainAction = 'android.intent.action.MAIN';
353 static const String chromePackage = 'com.android.chrome'; 393 static const String chromePackage = 'com.android.chrome';
354 static const String browserPackage = 'com.android.browser'; 394 static const String browserPackage = 'com.android.browser';
355 static const String firefoxPackage = 'org.mozilla.firefox'; 395 static const String firefoxPackage = 'org.mozilla.firefox';
356 static const String turnScreenOnPackage = 'com.google.dart.turnscreenon'; 396 static const String turnScreenOnPackage = 'com.google.dart.turnscreenon';
357 397
358 AndroidEmulator _emulator; 398 AndroidEmulator _emulator;
359 AdbDevice _adbDevice; 399 AdbDevice _adbDevice;
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 if (request.uri.path.startsWith(driverPath)) { 855 if (request.uri.path.startsWith(driverPath)) {
816 var browserId = request.uri.path.substring(driverPath.length + 1); 856 var browserId = request.uri.path.substring(driverPath.length + 1);
817 textResponse = getDriverPage(browserId); 857 textResponse = getDriverPage(browserId);
818 } else if (request.uri.path.startsWith(nextTestPath)) { 858 } else if (request.uri.path.startsWith(nextTestPath)) {
819 var browserId = request.uri.path.substring(nextTestPath.length + 1); 859 var browserId = request.uri.path.substring(nextTestPath.length + 1);
820 textResponse = getNextTest(browserId); 860 textResponse = getNextTest(browserId);
821 } else { 861 } else {
822 DebugLogger.info("Handling non standard request to: " 862 DebugLogger.info("Handling non standard request to: "
823 "${request.uri.path}"); 863 "${request.uri.path}");
824 } 864 }
865 request.response.headers.set("Cache-Control", "no-cache, no-store, must- revalidate");
866 request.response.headers.set("Pragma", "no-cache");
867 request.response.headers.set("Expires", "0");
825 request.response.write(textResponse); 868 request.response.write(textResponse);
826 request.listen((_) {}, onDone: request.response.close); 869 request.listen((_) {}, onDone: request.response.close);
827 request.response.done.then((_) { 870 request.response.done.then((_) {
828 DebugLogger.info("Done handling request to: ${request.uri.path}"); 871 DebugLogger.info("Done handling request to: ${request.uri.path}");
829 }).catchError((error) { 872 }).catchError((error) {
830 if (!underTermination) { 873 if (!underTermination) {
831 print("URI ${request.uri}"); 874 print("URI ${request.uri}");
832 print("Textresponse $textResponse"); 875 print("Textresponse $textResponse");
833 throw "Error returning content to browser: $error"; 876 throw "Error returning content to browser: $error";
834 } 877 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 } else if (this.responseText == '$terminateSignal') { 978 } else if (this.responseText == '$terminateSignal') {
936 // Don't do anything, we will be killed shortly. 979 // Don't do anything, we will be killed shortly.
937 } else { 980 } else {
938 var elapsed = new Date() - start; 981 var elapsed = new Date() - start;
939 // TODO(ricow): Do something more clever here. 982 // TODO(ricow): Do something more clever here.
940 if (nextTask != undefined) alert('This is really bad'); 983 if (nextTask != undefined) alert('This is really bad');
941 // The task is send to us as: 984 // The task is send to us as:
942 // URL#ID 985 // URL#ID
943 var split = this.responseText.split('#'); 986 var split = this.responseText.split('#');
944 var nextTask = split[0]; 987 var nextTask = split[0];
988
945 current_id = split[1]; 989 current_id = split[1];
946 reportError('Done getting task : ' + elapsed); 990 reportError('Done getting task : ' + elapsed);
947 did_start = false; 991 did_start = false;
948 run(nextTask); 992 run(nextTask);
949 } 993 }
950 } else { 994 } else {
951 reportError('Could not contact the server and get a new task'); 995 reportError('Could not contact the server and get a new task');
952 } 996 }
953 } 997 }
954 } 998 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 </head> 1093 </head>
1050 <body onload="startTesting()"> 1094 <body onload="startTesting()">
1051 Dart test driver, number of tests: <div id="number"></div> 1095 Dart test driver, number of tests: <div id="number"></div>
1052 <iframe id="embedded_iframe"></iframe> 1096 <iframe id="embedded_iframe"></iframe>
1053 </body> 1097 </body>
1054 </html> 1098 </html>
1055 """; 1099 """;
1056 return driverContent; 1100 return driverContent;
1057 } 1101 }
1058 } 1102 }
OLDNEW
« tools/test.dart ('K') | « tools/test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698