OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.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 pub_tests; | 5 library pub_tests; |
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 180 } |
181 | 181 |
182 /// Reads lines from pub serve's stdout until it prints the build success | 182 /// Reads lines from pub serve's stdout until it prints the build success |
183 /// message. | 183 /// message. |
184 /// | 184 /// |
185 /// The schedule will not proceed until the output is found. If not found, it | 185 /// The schedule will not proceed until the output is found. If not found, it |
186 /// will eventually time out. | 186 /// will eventually time out. |
187 void waitForBuildSuccess() { | 187 void waitForBuildSuccess() { |
188 nextLine() { | 188 nextLine() { |
189 return _pubServer.nextLine().then((line) { | 189 return _pubServer.nextLine().then((line) { |
190 if (line.contains("successfully")) return; | 190 if (line.contains("successfully")) return null; |
191 | 191 |
192 // This line wasn't it, so ignore it and keep trying. | 192 // This line wasn't it, so ignore it and keep trying. |
193 return nextLine(); | 193 return nextLine(); |
194 }); | 194 }); |
195 } | 195 } |
196 | 196 |
197 schedule(nextLine); | 197 schedule(nextLine); |
198 } | 198 } |
199 | 199 |
200 /// Schedules opening a web socket connection to the currently running pub | 200 /// Schedules opening a web socket connection to the currently running pub |
(...skipping 21 matching lines...) Expand all Loading... |
222 /// socket. It omitted, request is JSON encoded to a string first. | 222 /// socket. It omitted, request is JSON encoded to a string first. |
223 void webSocketShouldReply(request, expectation, {bool encodeRequest: true}) { | 223 void webSocketShouldReply(request, expectation, {bool encodeRequest: true}) { |
224 schedule(() => _ensureWebSocket().then((_) { | 224 schedule(() => _ensureWebSocket().then((_) { |
225 if (encodeRequest) request = JSON.encode(request); | 225 if (encodeRequest) request = JSON.encode(request); |
226 _webSocket.add(request); | 226 _webSocket.add(request); |
227 return _webSocketBroadcastStream.first.then((value) { | 227 return _webSocketBroadcastStream.first.then((value) { |
228 expect(JSON.decode(value), expectation); | 228 expect(JSON.decode(value), expectation); |
229 }); | 229 }); |
230 }), "send $request to web socket and expect reply that $expectation"); | 230 }), "send $request to web socket and expect reply that $expectation"); |
231 } | 231 } |
OLD | NEW |