| 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 unittest.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:shelf/shelf.dart' as shelf; | 12 import 'package:shelf/shelf.dart' as shelf; |
| 13 import 'package:shelf/shelf_io.dart' as shelf_io; | 13 import 'package:shelf/shelf_io.dart' as shelf_io; |
| 14 import 'package:shelf_static/shelf_static.dart'; | 14 import 'package:shelf_static/shelf_static.dart'; |
| 15 import 'package:shelf_web_socket/shelf_web_socket.dart'; | 15 import 'package:shelf_web_socket/shelf_web_socket.dart'; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 _browser.onExit.catchError((error, stackTrace) { | 85 _browser.onExit.catchError((error, stackTrace) { |
| 86 if (_browserManagerCompleter.isCompleted) return; | 86 if (_browserManagerCompleter.isCompleted) return; |
| 87 _browserManagerCompleter.completeError(error, stackTrace); | 87 _browserManagerCompleter.completeError(error, stackTrace); |
| 88 }); | 88 }); |
| 89 } | 89 } |
| 90 return _browserManagerCompleter.future; | 90 return _browserManagerCompleter.future; |
| 91 } | 91 } |
| 92 Completer<BrowserManager> _browserManagerCompleter; | 92 Completer<BrowserManager> _browserManagerCompleter; |
| 93 | 93 |
| 94 BrowserServer._(this._packageRoot, bool color) | 94 BrowserServer._(this._packageRoot, bool color) |
| 95 : _compiledDir = Directory.systemTemp.createTempSync('unittest_').path, | 95 : _compiledDir = Directory.systemTemp.createTempSync('test_').path, |
| 96 _compilers = new CompilerPool(color: color); | 96 _compilers = new CompilerPool(color: color); |
| 97 | 97 |
| 98 /// Starts the underlying server. | 98 /// Starts the underlying server. |
| 99 Future _load() { | 99 Future _load() { |
| 100 var staticPath = p.join(libDir(packageRoot: _packageRoot), | 100 var staticPath = p.join(libDir(packageRoot: _packageRoot), |
| 101 'src/runner/browser/static'); | 101 'src/runner/browser/static'); |
| 102 var cascade = new shelf.Cascade() | 102 var cascade = new shelf.Cascade() |
| 103 .add(_webSocketHandler.handler) | 103 .add(_webSocketHandler.handler) |
| 104 .add(createStaticHandler(staticPath, defaultDocument: 'index.html')) | 104 .add(createStaticHandler(staticPath, defaultDocument: 'index.html')) |
| 105 .add(createStaticHandler(_compiledDir, defaultDocument: 'index.html')); | 105 .add(createStaticHandler(_compiledDir, defaultDocument: 'index.html')); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 /// Returns a [Future] that completes once the server is closed and its | 154 /// Returns a [Future] that completes once the server is closed and its |
| 155 /// resources have been fully released. | 155 /// resources have been fully released. |
| 156 Future close() { | 156 Future close() { |
| 157 new Directory(_compiledDir).deleteSync(recursive: true); | 157 new Directory(_compiledDir).deleteSync(recursive: true); |
| 158 return _server.close().then((_) { | 158 return _server.close().then((_) { |
| 159 if (_browserManagerCompleter == null) return null; | 159 if (_browserManagerCompleter == null) return null; |
| 160 return _browserManager.then((_) => _browser.close()); | 160 return _browserManager.then((_) => _browser.close()); |
| 161 }); | 161 }); |
| 162 } | 162 } |
| 163 } | 163 } |
| OLD | NEW |