Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: pkg/analysis_server/test/mocks.dart

Issue 426243005: Make "server.shutdown" exit the analysis server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/test/integration/server_domain_int_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+ }
}
/**
« no previous file with comments | « pkg/analysis_server/test/integration/server_domain_int_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698