| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 return "NoResponseException after request ${request.toJson()}"; | 117 return "NoResponseException after request ${request.toJson()}"; |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 /** | 121 /** |
| 122 * A mock [ServerCommunicationChannel] for testing [AnalysisServer]. | 122 * A mock [ServerCommunicationChannel] for testing [AnalysisServer]. |
| 123 */ | 123 */ |
| 124 class MockServerChannel implements ServerCommunicationChannel { | 124 class MockServerChannel implements ServerCommunicationChannel { |
| 125 StreamController<Request> requestController = new StreamController<Request>(); | 125 StreamController<Request> requestController = new StreamController<Request>(); |
| 126 StreamController<Response> responseController = new StreamController<Response>
(); | 126 StreamController<Response> responseController = new StreamController<Response>
(); |
| 127 StreamController<Notification> notificationController = new StreamController<N
otification>(); | 127 StreamController<Notification> notificationController = new StreamController<N
otification>(sync: true); |
| 128 | 128 |
| 129 List<Response> responsesReceived = []; | 129 List<Response> responsesReceived = []; |
| 130 List<Notification> notificationsReceived = []; | 130 List<Notification> notificationsReceived = []; |
| 131 | 131 |
| 132 MockServerChannel() { | 132 MockServerChannel() { |
| 133 } | 133 } |
| 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)
; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 Response response = item; | 296 Response response = item; |
| 297 var id = response.id; | 297 var id = response.id; |
| 298 RequestError error = response.error; | 298 RequestError error = response.error; |
| 299 mismatchDescription.add('has identifier "$id"'); | 299 mismatchDescription.add('has identifier "$id"'); |
| 300 if (error == null) { | 300 if (error == null) { |
| 301 mismatchDescription.add(' and has no error'); | 301 mismatchDescription.add(' and has no error'); |
| 302 } | 302 } |
| 303 return mismatchDescription; | 303 return mismatchDescription; |
| 304 } | 304 } |
| 305 } | 305 } |
| OLD | NEW |