| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 mocks; | 5 library mocks; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 @MirrorsUsed(targets: 'mocks', override: '*') | 10 @MirrorsUsed(targets: 'mocks', override: '*') |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 134 |
| 135 @override | 135 @override |
| 136 void listen(void onRequest(Request request), {Function onError, void onDone()}
) { | 136 void listen(void onRequest(Request request), {Function onError, void onDone()}
) { |
| 137 requestController.stream.listen(onRequest, onError: onError, onDone: onDone)
; | 137 requestController.stream.listen(onRequest, onError: onError, onDone: onDone)
; |
| 138 } | 138 } |
| 139 | 139 |
| 140 @override | 140 @override |
| 141 void sendNotification(Notification notification) { | 141 void sendNotification(Notification notification) { |
| 142 notificationsReceived.add(notification); | 142 notificationsReceived.add(notification); |
| 143 // Wrap send notification in future to simulate websocket | 143 // Wrap send notification in future to simulate websocket |
| 144 new Future(() => notificationController.add(notification)); | 144 // TODO(scheglov) ask Dan why and decide what to do |
| 145 // new Future(() => notificationController.add(notification)); |
| 146 notificationController.add(notification); |
| 145 } | 147 } |
| 146 | 148 |
| 147 /** | 149 /** |
| 148 * Simulate request/response pair. | 150 * Simulate request/response pair. |
| 149 */ | 151 */ |
| 150 Future<Response> sendRequest(Request request) { | 152 Future<Response> sendRequest(Request request) { |
| 151 var id = request.id; | 153 var id = request.id; |
| 152 // Wrap send request in future to simulate websocket | 154 // Wrap send request in future to simulate websocket |
| 153 new Future(() => requestController.add(request)); | 155 new Future(() => requestController.add(request)); |
| 154 pumpEventQueue().then((_) => responseController.addError( | 156 pumpEventQueue().then((_) => responseController.addError( |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 Response response = item; | 296 Response response = item; |
| 295 var id = response.id; | 297 var id = response.id; |
| 296 RequestError error = response.error; | 298 RequestError error = response.error; |
| 297 mismatchDescription.add('has identifier "$id"'); | 299 mismatchDescription.add('has identifier "$id"'); |
| 298 if (error == null) { | 300 if (error == null) { |
| 299 mismatchDescription.add(' and has no error'); | 301 mismatchDescription.add(' and has no error'); |
| 300 } | 302 } |
| 301 return mismatchDescription; | 303 return mismatchDescription; |
| 302 } | 304 } |
| 303 } | 305 } |
| OLD | NEW |