OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 | 4 |
5 library test.runner.browser.browser_manager; | 5 library test.runner.browser.browser_manager; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 | 9 |
10 import 'package:async/async.dart'; | 10 import 'package:async/async.dart'; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 /// Starts the browser identified by [browser] and has it load [url]. | 121 /// Starts the browser identified by [browser] and has it load [url]. |
122 /// | 122 /// |
123 /// If [debug] is true, starts the browser in debug mode. | 123 /// If [debug] is true, starts the browser in debug mode. |
124 static Browser _newBrowser(Uri url, TestPlatform browser, | 124 static Browser _newBrowser(Uri url, TestPlatform browser, |
125 {bool debug: false}) { | 125 {bool debug: false}) { |
126 switch (browser) { | 126 switch (browser) { |
127 case TestPlatform.dartium: return new Dartium(url, debug: debug); | 127 case TestPlatform.dartium: return new Dartium(url, debug: debug); |
128 case TestPlatform.contentShell: | 128 case TestPlatform.contentShell: |
129 return new ContentShell(url, debug: debug); | 129 return new ContentShell(url, debug: debug); |
130 case TestPlatform.chrome: return new Chrome(url); | 130 case TestPlatform.chrome: return new Chrome(url); |
131 case TestPlatform.phantomJS: return new PhantomJS(url); | 131 case TestPlatform.phantomJS: return new PhantomJS(url, debug: debug); |
132 case TestPlatform.firefox: return new Firefox(url); | 132 case TestPlatform.firefox: return new Firefox(url); |
133 case TestPlatform.safari: return new Safari(url); | 133 case TestPlatform.safari: return new Safari(url); |
134 case TestPlatform.internetExplorer: return new InternetExplorer(url); | 134 case TestPlatform.internetExplorer: return new InternetExplorer(url); |
135 default: | 135 default: |
136 throw new ArgumentError("$browser is not a browser."); | 136 throw new ArgumentError("$browser is not a browser."); |
137 } | 137 } |
138 } | 138 } |
139 | 139 |
140 /// Creates a new BrowserManager that communicates with [browser] over | 140 /// Creates a new BrowserManager that communicates with [browser] over |
141 /// [webSocket]. | 141 /// [webSocket]. |
142 BrowserManager._(this._browser, this._platform, CompatibleWebSocket webSocket) | 142 BrowserManager._(this._browser, this._platform, CompatibleWebSocket webSocket) |
143 : _channel = new MultiChannel( | 143 : _channel = new MultiChannel( |
144 webSocket.map(JSON.decode), | 144 webSocket.map(JSON.decode), |
145 mapSink(webSocket, JSON.encode)) { | 145 mapSink(webSocket, JSON.encode)) { |
146 _environment = _loadBrowserEnvironment(); | 146 _environment = _loadBrowserEnvironment(); |
147 _channel.stream.listen(_onMessage, onDone: close); | 147 _channel.stream.listen(_onMessage, onDone: close); |
148 } | 148 } |
149 | 149 |
150 /// Loads [_BrowserEnvironment]. | 150 /// Loads [_BrowserEnvironment]. |
151 Future<_BrowserEnvironment> _loadBrowserEnvironment() async { | 151 Future<_BrowserEnvironment> _loadBrowserEnvironment() async { |
152 var observatoryUrl; | 152 var observatoryUrl; |
153 if (_platform.isDartVM) observatoryUrl = await _browser.observatoryUrl; | 153 if (_platform.isDartVM) observatoryUrl = await _browser.observatoryUrl; |
154 | 154 |
155 var remoteDebuggerUrl; | 155 var remoteDebuggerUrl; |
156 if (_platform == TestPlatform.contentShell) { | 156 if (_platform.isHeadless) { |
157 remoteDebuggerUrl = await _browser.remoteDebuggerUrl; | 157 remoteDebuggerUrl = await _browser.remoteDebuggerUrl; |
158 } | 158 } |
159 | 159 |
160 return new _BrowserEnvironment(this, observatoryUrl, remoteDebuggerUrl); | 160 return new _BrowserEnvironment(this, observatoryUrl, remoteDebuggerUrl); |
161 } | 161 } |
162 | 162 |
163 /// Tells the browser the load a test suite from the URL [url]. | 163 /// Tells the browser the load a test suite from the URL [url]. |
164 /// | 164 /// |
165 /// [url] should be an HTML page with a reference to the JS-compiled test | 165 /// [url] should be an HTML page with a reference to the JS-compiled test |
166 /// suite. [path] is the path of the original test suite file, which is used | 166 /// suite. [path] is the path of the original test suite file, which is used |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 291 |
292 final Uri observatoryUrl; | 292 final Uri observatoryUrl; |
293 | 293 |
294 final Uri remoteDebuggerUrl; | 294 final Uri remoteDebuggerUrl; |
295 | 295 |
296 _BrowserEnvironment(this._manager, this.observatoryUrl, | 296 _BrowserEnvironment(this._manager, this.observatoryUrl, |
297 this.remoteDebuggerUrl); | 297 this.remoteDebuggerUrl); |
298 | 298 |
299 CancelableFuture displayPause() => _manager._displayPause(); | 299 CancelableFuture displayPause() => _manager._displayPause(); |
300 } | 300 } |
OLD | NEW |