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

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

Issue 887793003: Avoid redundant notifications when a file is analyzed in multiple contexts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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/lib/src/operation/operation_analysis.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 test.analysis_server; 5 library test.analysis_server;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/constants.dart'; 10 import 'package:analysis_server/src/constants.dart';
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 server.getAnalysisContextForSource(barSource); 218 server.getAnalysisContextForSource(barSource);
219 expect(barContext, isNotNull); 219 expect(barContext, isNotNull);
220 expect(fooContext, isNot(same(barContext))); 220 expect(fooContext, isNot(same(barContext)));
221 expect(fooContext.getKindOf(fooSource), SourceKind.LIBRARY); 221 expect(fooContext.getKindOf(fooSource), SourceKind.LIBRARY);
222 expect(fooContext.getKindOf(barSource), SourceKind.UNKNOWN); 222 expect(fooContext.getKindOf(barSource), SourceKind.UNKNOWN);
223 expect(barContext.getKindOf(fooSource), SourceKind.UNKNOWN); 223 expect(barContext.getKindOf(fooSource), SourceKind.UNKNOWN);
224 expect(barContext.getKindOf(barSource), SourceKind.LIBRARY); 224 expect(barContext.getKindOf(barSource), SourceKind.LIBRARY);
225 }); 225 });
226 } 226 }
227 227
228 /**
229 * Test that having multiple analysis contexts analyze the same file doesn't
230 * cause that file to receive duplicate notifications when it's modified.
231 */
232 Future test_no_duplicate_notifications() async {
233 // Subscribe to STATUS so we'll know when analysis is done.
234 server.serverServices = [ServerService.STATUS].toSet();
235 resourceProvider.newFolder('/foo');
236 resourceProvider.newFolder('/bar');
237 resourceProvider.newFile('/foo/foo.dart', 'import "../bar/bar.dart";');
238 File bar = resourceProvider.newFile('/bar/bar.dart', 'library bar;');
239 server.setAnalysisRoots('0', ['/foo', '/bar'], [], {});
240 Map<AnalysisService, Set<String>> subscriptions = <AnalysisService,
241 Set<String>>{};
242 for (AnalysisService service in AnalysisService.VALUES) {
243 subscriptions[service] = <String>[bar.path].toSet();
244 }
245 server.setAnalysisSubscriptions(subscriptions);
246 await pumpEventQueue(100);
247 expect(server.statusAnalyzing, isFalse);
248 channel.notificationsReceived.clear();
249 server.updateContent('0', {
250 bar.path: new AddContentOverlay('library bar; void f() {}')
251 });
252 await pumpEventQueue(100);
253 expect(server.statusAnalyzing, isFalse);
254 expect(channel.notificationsReceived, isNotEmpty);
255 Set<String> notificationTypesReceived = new Set<String>();
256 for (Notification notification in channel.notificationsReceived) {
257 String notificationType = notification.event;
258 switch (notificationType) {
259 case 'server.status':
260 case 'analysis.errors':
261 // It's normal for these notifications to be sent multiple times.
262 break;
263 case 'analysis.outline':
264 // It's normal for this notification to be sent twice.
265 // TODO(paulberry): why?
danrubel 2015/01/29 21:37:00 Do we send an outline once when it is parsed and a
266 break;
267 default:
268 if (!notificationTypesReceived.add(notificationType)) {
269 fail('Notification type $notificationType received more than once');
270 }
271 break;
272 }
273 }
274 return null; // Work around dartbug.com/22091
275 }
276
228 Future test_prioritySourcesChangedEvent() { 277 Future test_prioritySourcesChangedEvent() {
229 resourceProvider.newFolder('/foo'); 278 resourceProvider.newFolder('/foo');
230 279
231 int eventCount = 0; 280 int eventCount = 0;
232 Source firstSource = null; 281 Source firstSource = null;
233 server.onPriorityChange.listen((PriorityChangeEvent event) { 282 server.onPriorityChange.listen((PriorityChangeEvent event) {
234 ++eventCount; 283 ++eventCount;
235 firstSource = event.firstSource; 284 firstSource = event.firstSource;
236 }); 285 });
237 286
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 @override 382 @override
334 Response handleRequest(Request request) { 383 Response handleRequest(Request request) {
335 if (request.method == 'echo') { 384 if (request.method == 'echo') {
336 return new Response(request.id, result: { 385 return new Response(request.id, result: {
337 'echo': true 386 'echo': true
338 }); 387 });
339 } 388 }
340 return null; 389 return null;
341 } 390 }
342 } 391 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/operation/operation_analysis.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698