| 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 @TestOn("vm") | 5 @TestOn("vm") |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:test/test.dart'; | 10 import 'package:test/test.dart'; |
| 11 import 'package:test/src/runner/browser/phantom_js.dart'; | 11 import 'package:test/src/runner/browser/phantom_js.dart'; |
| 12 import 'package:test/src/util/io.dart'; | 12 import 'package:test/src/util/io.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_web_socket/shelf_web_socket.dart'; | 15 import 'package:shelf_web_socket/shelf_web_socket.dart'; |
| 16 | 16 |
| 17 import '../../utils.dart'; |
| 18 |
| 17 void main() { | 19 void main() { |
| 18 group("running JavaScript", () { | 20 group("running JavaScript", () { |
| 19 // The JavaScript to serve in the server. We use actual JavaScript here to | 21 // The JavaScript to serve in the server. We use actual JavaScript here to |
| 20 // avoid the pain of compiling to JS in a test | 22 // avoid the pain of compiling to JS in a test |
| 21 var javaScript; | 23 var javaScript; |
| 22 | 24 |
| 23 var servePage = (request) { | 25 var servePage = (request) { |
| 24 var path = request.url.path; | 26 var path = request.url.path; |
| 25 | 27 |
| 26 // We support both shelf 0.5.x and 0.6.x. The former has a leading "/" | 28 // We support both shelf 0.5.x and 0.6.x. The former has a leading "/" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 .then((server) { | 134 .then((server) { |
| 133 var phantomJS = new PhantomJS( | 135 var phantomJS = new PhantomJS( |
| 134 baseUrlForAddress(server.address, server.port)); | 136 baseUrlForAddress(server.address, server.port)); |
| 135 return phantomJS.close().whenComplete(server.close); | 137 return phantomJS.close().whenComplete(server.close); |
| 136 }); | 138 }); |
| 137 }); | 139 }); |
| 138 | 140 |
| 139 test("reports an error in onExit", () { | 141 test("reports an error in onExit", () { |
| 140 var phantomJS = new PhantomJS("http://dart-lang.org", | 142 var phantomJS = new PhantomJS("http://dart-lang.org", |
| 141 executable: "_does_not_exist"); | 143 executable: "_does_not_exist"); |
| 142 expect(phantomJS.onExit, throwsA(new isInstanceOf<ProcessException>())); | 144 expect(phantomJS.onExit, throwsA(isApplicationException(startsWith( |
| 145 "Failed to start PhantomJS: No such file or directory")))); |
| 143 }); | 146 }); |
| 144 } | 147 } |
| OLD | NEW |