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 |
11 import 'package:path/path.dart' as p; | 11 import 'package:path/path.dart' as p; |
12 import 'package:pool/pool.dart'; | 12 import 'package:pool/pool.dart'; |
13 import 'package:shelf/shelf.dart' as shelf; | 13 import 'package:shelf/shelf.dart' as shelf; |
14 import 'package:shelf/shelf_io.dart' as shelf_io; | 14 import 'package:shelf/shelf_io.dart' as shelf_io; |
15 import 'package:shelf_static/shelf_static.dart'; | 15 import 'package:shelf_static/shelf_static.dart'; |
16 import 'package:shelf_web_socket/shelf_web_socket.dart'; | 16 import 'package:shelf_web_socket/shelf_web_socket.dart'; |
17 | 17 |
18 import '../../backend/suite.dart'; | 18 import '../../backend/suite.dart'; |
19 import '../../backend/test_platform.dart'; | 19 import '../../backend/test_platform.dart'; |
20 import '../../util/io.dart'; | 20 import '../../util/io.dart'; |
21 import '../../util/path_handler.dart'; | 21 import '../../util/path_handler.dart'; |
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 'firefox.dart'; | 31 import 'firefox.dart'; |
31 | 32 |
32 /// A server that serves JS-compiled tests to browsers. | 33 /// A server that serves JS-compiled tests to browsers. |
33 /// | 34 /// |
34 /// A test suite may be loaded for a given file using [loadSuite]. | 35 /// A test suite may be loaded for a given file using [loadSuite]. |
35 class BrowserServer { | 36 class BrowserServer { |
36 /// Starts the server. | 37 /// Starts the server. |
37 /// | 38 /// |
38 /// [root] is the root directory that the server should serve. It defaults to | 39 /// [root] is the root directory that the server should serve. It defaults to |
39 /// the working directory. | 40 /// the working directory. |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 completer.completeError(error, stackTrace); | 343 completer.completeError(error, stackTrace); |
343 }); | 344 }); |
344 | 345 |
345 return completer.future; | 346 return completer.future; |
346 } | 347 } |
347 | 348 |
348 /// Starts the browser identified by [browser] and has it load [url]. | 349 /// Starts the browser identified by [browser] and has it load [url]. |
349 Browser _newBrowser(Uri url, TestPlatform browser) { | 350 Browser _newBrowser(Uri url, TestPlatform browser) { |
350 switch (browser) { | 351 switch (browser) { |
351 case TestPlatform.dartium: return new Dartium(url); | 352 case TestPlatform.dartium: return new Dartium(url); |
| 353 case TestPlatform.contentShell: return new ContentShell(url); |
352 case TestPlatform.chrome: return new Chrome(url); | 354 case TestPlatform.chrome: return new Chrome(url); |
353 case TestPlatform.firefox: return new Firefox(url); | 355 case TestPlatform.firefox: return new Firefox(url); |
354 default: | 356 default: |
355 throw new ArgumentError("$browser is not a browser."); | 357 throw new ArgumentError("$browser is not a browser."); |
356 } | 358 } |
357 } | 359 } |
358 | 360 |
359 /// Closes the server and releases all its resources. | 361 /// Closes the server and releases all its resources. |
360 /// | 362 /// |
361 /// Returns a [Future] that completes once the server is closed and its | 363 /// Returns a [Future] that completes once the server is closed and its |
(...skipping 15 matching lines...) Expand all Loading... |
377 if (_pubServeUrl == null) { | 379 if (_pubServeUrl == null) { |
378 new Directory(_compiledDir).deleteSync(recursive: true); | 380 new Directory(_compiledDir).deleteSync(recursive: true); |
379 } else { | 381 } else { |
380 _http.close(); | 382 _http.close(); |
381 } | 383 } |
382 | 384 |
383 _closeCompleter.complete(); | 385 _closeCompleter.complete(); |
384 }).catchError(_closeCompleter.completeError); | 386 }).catchError(_closeCompleter.completeError); |
385 } | 387 } |
386 } | 388 } |
OLD | NEW |