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

Side by Side Diff: pkg/analysis_server/test/mocks.dart

Issue 417433003: Send responses for any pending 'analysis.getErrors' requests during context removal. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/test/analysis/get_errors_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // Wrap send notification in future to simulate websocket 148 // Wrap send notification in future to simulate websocket
149 // TODO(scheglov) ask Dan why and decide what to do 149 // TODO(scheglov) ask Dan why and decide what to do
150 // new Future(() => notificationController.add(notification)); 150 // new Future(() => notificationController.add(notification));
151 notificationController.add(notification); 151 notificationController.add(notification);
152 } 152 }
153 153
154 /** 154 /**
155 * Simulate request/response pair. 155 * Simulate request/response pair.
156 */ 156 */
157 Future<Response> sendRequest(Request request) { 157 Future<Response> sendRequest(Request request) {
158 var id = request.id;
159 // Wrap send request in future to simulate websocket 158 // Wrap send request in future to simulate websocket
160 new Future(() => requestController.add(request)); 159 new Future(() => requestController.add(request));
161 pumpEventQueue().then((_) => responseController.addError( 160 return waitForResponse(request);
162 new NoResponseException(request)));
163 return responseController.stream.firstWhere((response) => response.id == id
164 );
165 } 161 }
166 162
167 @override 163 @override
168 void sendResponse(Response response) { 164 void sendResponse(Response response) {
169 responsesReceived.add(response); 165 responsesReceived.add(response);
170 // Wrap send response in future to simulate websocket 166 // Wrap send response in future to simulate websocket
171 new Future(() => responseController.add(response)); 167 new Future(() => responseController.add(response));
172 } 168 }
173 169
174 void expectMsgCount({responseCount: 0, notificationCount: 0}) { 170 void expectMsgCount({responseCount: 0, notificationCount: 0}) {
175 expect(responsesReceived, hasLength(responseCount)); 171 expect(responsesReceived, hasLength(responseCount));
176 expect(notificationsReceived, hasLength(notificationCount)); 172 expect(notificationsReceived, hasLength(notificationCount));
177 } 173 }
174
175 Future<Response> waitForResponse(Request request) {
176 String id = request.id;
177 pumpEventQueue().then((_) {
178 responseController.addError(new NoResponseException(request));
179 });
180 return responseController.stream.firstWhere((response) {
181 return response.id == id;
182 });
183 }
178 } 184 }
179 185
180 /** 186 /**
181 * A mock [AnalysisContext] for testing [AnalysisServer]. 187 * A mock [AnalysisContext] for testing [AnalysisServer].
182 */ 188 */
183 class MockAnalysisContext extends Mock implements AnalysisContext { 189 class MockAnalysisContext extends Mock implements AnalysisContext {
184 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 190 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
185 } 191 }
186 192
187 /** 193 /**
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 /** 326 /**
321 * Dependency list that will be returned by the next call to [computePackageMa p]. 327 * Dependency list that will be returned by the next call to [computePackageMa p].
322 */ 328 */
323 Set<String> dependencies = new Set<String>(); 329 Set<String> dependencies = new Set<String>();
324 330
325 @override 331 @override
326 PackageMapInfo computePackageMap(resource.Folder folder) { 332 PackageMapInfo computePackageMap(resource.Folder folder) {
327 return new PackageMapInfo(packageMap, dependencies); 333 return new PackageMapInfo(packageMap, dependencies);
328 } 334 }
329 } 335 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/analysis/get_errors_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698