| 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 import 'package:analysis_server/plugin/protocol/protocol.dart' | 10 import 'package:analysis_server/plugin/protocol/protocol.dart' |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 if (_closed) { | 242 if (_closed) { |
| 243 return; | 243 return; |
| 244 } | 244 } |
| 245 responsesReceived.add(response); | 245 responsesReceived.add(response); |
| 246 // Wrap send response in future to simulate WebSocket. | 246 // Wrap send response in future to simulate WebSocket. |
| 247 new Future(() => responseController.add(response)); | 247 new Future(() => responseController.add(response)); |
| 248 } | 248 } |
| 249 | 249 |
| 250 Future<Response> waitForResponse(Request request) { | 250 Future<Response> waitForResponse(Request request) { |
| 251 String id = request.id; | 251 String id = request.id; |
| 252 pumpEventQueue().then((_) { | |
| 253 responseController.addError(new NoResponseException(request)); | |
| 254 }); | |
| 255 return new Future<Response>(() => | 252 return new Future<Response>(() => |
| 256 responseController.stream.firstWhere((response) => response.id == id)); | 253 responseController.stream.firstWhere((response) => response.id == id)); |
| 257 } | 254 } |
| 258 } | 255 } |
| 259 | 256 |
| 260 /** | 257 /** |
| 261 * A mock [ServerOperation] for testing [AnalysisServer]. | 258 * A mock [ServerOperation] for testing [AnalysisServer]. |
| 262 */ | 259 */ |
| 263 class MockServerOperation implements PerformAnalysisOperation { | 260 class MockServerOperation implements PerformAnalysisOperation { |
| 264 final ServerOperationPriority priority; | 261 final ServerOperationPriority priority; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 } | 431 } |
| 435 return mismatchDescription; | 432 return mismatchDescription; |
| 436 } | 433 } |
| 437 | 434 |
| 438 @override | 435 @override |
| 439 bool matches(item, Map matchState) { | 436 bool matches(item, Map matchState) { |
| 440 Response response = item; | 437 Response response = item; |
| 441 return response != null && response.id == _id && response.error == null; | 438 return response != null && response.id == _id && response.error == null; |
| 442 } | 439 } |
| 443 } | 440 } |
| OLD | NEW |