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

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

Issue 15904008: Add factory constructor to browser controller. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 | « no previous file | tools/testing/dart/test_runner.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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 String id; 45 String id;
46 46
47 /** Callback that will be executed when the browser has closed */ 47 /** Callback that will be executed when the browser has closed */
48 Function onClose; 48 Function onClose;
49 49
50 /** Print everything (stdout, stderr, usageLog) whenever we add to it */ 50 /** Print everything (stdout, stderr, usageLog) whenever we add to it */
51 bool debugPrint = false; 51 bool debugPrint = false;
52 52
53 // We use this to gracefully handle double calls to close. 53 // We use this to gracefully handle double calls to close.
54 bool underTermination = false; 54 bool underTermination = false;
55
56 Browser();
57
58 factory Browser.byName(String name) {
59 if (name == 'ff' || name == 'firefox') {
60 return new FireFox();
61 } else if (name == 'chrome') {
62 return new Chrome();
63 } else if (name == 'safari') {
64 return new Safari();
65 } else {
66 throw "Non supported browser";
67 }
68 }
55 69
56 void _logEvent(String event) { 70 void _logEvent(String event) {
57 String toLog = "$this ($id) - ${new DateTime.now()}: $event \n"; 71 String toLog = "$this ($id) - ${new DateTime.now()}: $event \n";
58 if (debugPrint) print("usageLog: $toLog"); 72 if (debugPrint) print("usageLog: $toLog");
59 if (logger != null) logger(toLog); 73 if (logger != null) logger(toLog);
60 _usageLog.write(toLog); 74 _usageLog.write(toLog);
61 } 75 }
62 76
63 void _addStdout(String output) { 77 void _addStdout(String output) {
64 if (debugPrint) print("stdout: $output"); 78 if (debugPrint) print("stdout: $output");
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 futures.add(status.browser.close()); 726 futures.add(status.browser.close());
713 } 727 }
714 return Future.wait(futures).then((values) { 728 return Future.wait(futures).then((values) {
715 testingServer.httpServer.close(); 729 testingServer.httpServer.close();
716 printDoubleReportingTests(); 730 printDoubleReportingTests();
717 return !values.contains(false); 731 return !values.contains(false);
718 }); 732 });
719 } 733 }
720 734
721 Browser getInstance() { 735 Browser getInstance() {
722 var browser; 736 var browser = new Browser.byName(browserName);
723 if (browserName == "chrome") {
724 browser = new Chrome();
725 } else if (browserName == "ff") {
726 browser = new Firefox();
727 } else if (browserName == "safari") {
728 browser = new Safari();
729 } else {
730 throw "Non supported browser for browser controller";
731 }
732 browser.logger = logger; 737 browser.logger = logger;
733 return browser; 738 return browser;
734 } 739 }
735 } 740 }
736 741
737 class BrowserTestingServer { 742 class BrowserTestingServer {
738 /// Interface of the testing server: 743 /// Interface of the testing server:
739 /// 744 ///
740 /// GET /driver/BROWSER_ID -- This will get the driver page to fetch 745 /// GET /driver/BROWSER_ID -- This will get the driver page to fetch
741 /// and run tests ... 746 /// and run tests ...
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 </script> 943 </script>
939 </head> 944 </head>
940 <body> 945 <body>
941 Dart test driver, number of tests: <div id="number"></div> 946 Dart test driver, number of tests: <div id="number"></div>
942 </body> 947 </body>
943 </html> 948 </html>
944 """; 949 """;
945 return driverContent; 950 return driverContent;
946 } 951 }
947 } 952 }
OLDNEW
« no previous file with comments | « no previous file | tools/testing/dart/test_runner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698