| Index: pkg/analysis_server/test/mocks.dart
|
| diff --git a/pkg/analysis_server/test/mocks.dart b/pkg/analysis_server/test/mocks.dart
|
| index 5eb4ad5e27b5ab1133e424350cfe25caa54994a4..68f7da975ae0f80974517f5c7a86d5b5b5f6f778 100644
|
| --- a/pkg/analysis_server/test/mocks.dart
|
| +++ b/pkg/analysis_server/test/mocks.dart
|
| @@ -133,6 +133,7 @@ class MockServerChannel implements ServerCommunicationChannel {
|
|
|
| List<Response> responsesReceived = [];
|
| List<Notification> notificationsReceived = [];
|
| + bool _closed = false;
|
|
|
| MockServerChannel() {
|
| }
|
| @@ -144,6 +145,10 @@ class MockServerChannel implements ServerCommunicationChannel {
|
|
|
| @override
|
| void sendNotification(Notification notification) {
|
| + // Don't deliver notifications after the connection is closed.
|
| + if (_closed) {
|
| + return;
|
| + }
|
| notificationsReceived.add(notification);
|
| // Wrap send notification in future to simulate websocket
|
| // TODO(scheglov) ask Dan why and decide what to do
|
| @@ -155,6 +160,10 @@ class MockServerChannel implements ServerCommunicationChannel {
|
| * Simulate request/response pair.
|
| */
|
| Future<Response> sendRequest(Request request) {
|
| + // No further requests should be sent after the connection is closed.
|
| + if (_closed) {
|
| + throw new Exception('sendRequest after connection closed');
|
| + }
|
| // Wrap send request in future to simulate websocket
|
| new Future(() => requestController.add(request));
|
| return waitForResponse(request);
|
| @@ -162,6 +171,10 @@ class MockServerChannel implements ServerCommunicationChannel {
|
|
|
| @override
|
| void sendResponse(Response response) {
|
| + // Don't deliver responses after the connection is closed.
|
| + if (_closed) {
|
| + return;
|
| + }
|
| responsesReceived.add(response);
|
| // Wrap send response in future to simulate websocket
|
| new Future(() => responseController.add(response));
|
| @@ -181,6 +194,11 @@ class MockServerChannel implements ServerCommunicationChannel {
|
| return response.id == id;
|
| });
|
| }
|
| +
|
| + @override
|
| + void close() {
|
| + _closed = true;
|
| + }
|
| }
|
|
|
| /**
|
|
|