| 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.server; | 5 library test.runner.browser.server; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 import '../../util/one_off_handler.dart'; | 22 import '../../util/one_off_handler.dart'; |
| 23 import '../../utils.dart'; | 23 import '../../utils.dart'; |
| 24 import '../load_exception.dart'; | 24 import '../load_exception.dart'; |
| 25 import 'browser.dart'; | 25 import 'browser.dart'; |
| 26 import 'browser_manager.dart'; | 26 import 'browser_manager.dart'; |
| 27 import 'compiler_pool.dart'; | 27 import 'compiler_pool.dart'; |
| 28 import 'chrome.dart'; | 28 import 'chrome.dart'; |
| 29 import 'dartium.dart'; | 29 import 'dartium.dart'; |
| 30 import 'content_shell.dart'; | 30 import 'content_shell.dart'; |
| 31 import 'firefox.dart'; | 31 import 'firefox.dart'; |
| 32 import 'phantom_js.dart'; |
| 32 | 33 |
| 33 /// A server that serves JS-compiled tests to browsers. | 34 /// A server that serves JS-compiled tests to browsers. |
| 34 /// | 35 /// |
| 35 /// A test suite may be loaded for a given file using [loadSuite]. | 36 /// A test suite may be loaded for a given file using [loadSuite]. |
| 36 class BrowserServer { | 37 class BrowserServer { |
| 37 /// Starts the server. | 38 /// Starts the server. |
| 38 /// | 39 /// |
| 39 /// [root] is the root directory that the server should serve. It defaults to | 40 /// [root] is the root directory that the server should serve. It defaults to |
| 40 /// the working directory. | 41 /// the working directory. |
| 41 /// | 42 /// |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 346 |
| 346 return completer.future; | 347 return completer.future; |
| 347 } | 348 } |
| 348 | 349 |
| 349 /// Starts the browser identified by [browser] and has it load [url]. | 350 /// Starts the browser identified by [browser] and has it load [url]. |
| 350 Browser _newBrowser(Uri url, TestPlatform browser) { | 351 Browser _newBrowser(Uri url, TestPlatform browser) { |
| 351 switch (browser) { | 352 switch (browser) { |
| 352 case TestPlatform.dartium: return new Dartium(url); | 353 case TestPlatform.dartium: return new Dartium(url); |
| 353 case TestPlatform.contentShell: return new ContentShell(url); | 354 case TestPlatform.contentShell: return new ContentShell(url); |
| 354 case TestPlatform.chrome: return new Chrome(url); | 355 case TestPlatform.chrome: return new Chrome(url); |
| 356 case TestPlatform.phantomJS: return new PhantomJS(url); |
| 355 case TestPlatform.firefox: return new Firefox(url); | 357 case TestPlatform.firefox: return new Firefox(url); |
| 356 default: | 358 default: |
| 357 throw new ArgumentError("$browser is not a browser."); | 359 throw new ArgumentError("$browser is not a browser."); |
| 358 } | 360 } |
| 359 } | 361 } |
| 360 | 362 |
| 361 /// Closes the server and releases all its resources. | 363 /// Closes the server and releases all its resources. |
| 362 /// | 364 /// |
| 363 /// Returns a [Future] that completes once the server is closed and its | 365 /// Returns a [Future] that completes once the server is closed and its |
| 364 /// resources have been fully released. | 366 /// resources have been fully released. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 379 if (_pubServeUrl == null) { | 381 if (_pubServeUrl == null) { |
| 380 new Directory(_compiledDir).deleteSync(recursive: true); | 382 new Directory(_compiledDir).deleteSync(recursive: true); |
| 381 } else { | 383 } else { |
| 382 _http.close(); | 384 _http.close(); |
| 383 } | 385 } |
| 384 | 386 |
| 385 _closeCompleter.complete(); | 387 _closeCompleter.complete(); |
| 386 }).catchError(_closeCompleter.completeError); | 388 }).catchError(_closeCompleter.completeError); |
| 387 } | 389 } |
| 388 } | 390 } |
| OLD | NEW |