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:http_parser/http_parser.dart'; | 10 import 'package:http_parser/http_parser.dart'; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 _channel.sink.add({ | 71 _channel.sink.add({ |
72 "command": "loadSuite", | 72 "command": "loadSuite", |
73 "url": url.toString(), | 73 "url": url.toString(), |
74 "channel": suiteChannel.id | 74 "channel": suiteChannel.id |
75 }); | 75 }); |
76 | 76 |
77 // Create a nested MultiChannel because the iframe will be using a channel | 77 // Create a nested MultiChannel because the iframe will be using a channel |
78 // wrapped within the host's channel. | 78 // wrapped within the host's channel. |
79 suiteChannel = new MultiChannel(suiteChannel.stream, suiteChannel.sink); | 79 suiteChannel = new MultiChannel(suiteChannel.stream, suiteChannel.sink); |
80 | 80 |
81 return maybeFirst(suiteChannel.stream) | 81 var completer = new Completer(); |
82 .timeout(new Duration(seconds: 15), onTimeout: () { | 82 suiteChannel.stream.listen((response) { |
| 83 if (response["type"] == "print") { |
| 84 print(response["line"]); |
| 85 } else { |
| 86 completer.complete(response); |
| 87 } |
| 88 }, onDone: () { |
| 89 if (!completer.isCompleted) completer.complete(); |
| 90 }); |
| 91 |
| 92 return completer.future.timeout(new Duration(seconds: 15), onTimeout: () { |
83 throw new LoadException( | 93 throw new LoadException( |
84 path, | 94 path, |
85 "Timed out waiting for the test suite to connect on " | 95 "Timed out waiting for the test suite to connect on " |
86 "${browser.name}."); | 96 "${browser.name}."); |
87 }); | 97 }); |
88 }); | 98 }); |
89 | 99 |
90 if (response == null) return null; | 100 if (response == null) return null; |
91 | 101 |
92 if (response["type"] == "loadException") { | 102 if (response["type"] == "loadException") { |
93 throw new LoadException(path, response["message"]); | 103 throw new LoadException(path, response["message"]); |
94 } | 104 } |
95 | 105 |
96 if (response["type"] == "error") { | 106 if (response["type"] == "error") { |
97 var asyncError = RemoteException.deserialize(response["error"]); | 107 var asyncError = RemoteException.deserialize(response["error"]); |
98 await new Future.error( | 108 await new Future.error( |
99 new LoadException(path, asyncError.error), | 109 new LoadException(path, asyncError.error), |
100 asyncError.stackTrace); | 110 asyncError.stackTrace); |
101 } | 111 } |
102 | 112 |
103 return new Suite(response["tests"].map((test) { | 113 return new Suite(response["tests"].map((test) { |
104 var testMetadata = new Metadata.deserialize(test['metadata']); | 114 var testMetadata = new Metadata.deserialize(test['metadata']); |
105 var testChannel = suiteChannel.virtualChannel(test['channel']); | 115 var testChannel = suiteChannel.virtualChannel(test['channel']); |
106 return new IframeTest(test['name'], testMetadata, testChannel, | 116 return new IframeTest(test['name'], testMetadata, testChannel, |
107 mapper: mapper); | 117 mapper: mapper); |
108 }), metadata: metadata, path: path); | 118 }), metadata: metadata, path: path); |
109 } | 119 } |
110 } | 120 } |
OLD | NEW |