Chromium Code Reviews| Index: pkg/analysis_server/test/analysis_server_test.dart |
| diff --git a/pkg/analysis_server/test/analysis_server_test.dart b/pkg/analysis_server/test/analysis_server_test.dart |
| index 528324a53ff83f1d3e1d602117b190bf88d90a1f..17ba0ca44ee0c633c6770bd4af1e4bb9526772aa 100644 |
| --- a/pkg/analysis_server/test/analysis_server_test.dart |
| +++ b/pkg/analysis_server/test/analysis_server_test.dart |
| @@ -225,6 +225,55 @@ import "../foo/foo.dart"; |
| }); |
| } |
| + /** |
| + * Test that having multiple analysis contexts analyze the same file doesn't |
| + * cause that file to receive duplicate notifications when it's modified. |
| + */ |
| + Future test_no_duplicate_notifications() async { |
| + // Subscribe to STATUS so we'll know when analysis is done. |
| + server.serverServices = [ServerService.STATUS].toSet(); |
| + resourceProvider.newFolder('/foo'); |
| + resourceProvider.newFolder('/bar'); |
| + resourceProvider.newFile('/foo/foo.dart', 'import "../bar/bar.dart";'); |
| + File bar = resourceProvider.newFile('/bar/bar.dart', 'library bar;'); |
| + server.setAnalysisRoots('0', ['/foo', '/bar'], [], {}); |
| + Map<AnalysisService, Set<String>> subscriptions = <AnalysisService, |
| + Set<String>>{}; |
| + for (AnalysisService service in AnalysisService.VALUES) { |
| + subscriptions[service] = <String>[bar.path].toSet(); |
| + } |
| + server.setAnalysisSubscriptions(subscriptions); |
| + await pumpEventQueue(100); |
| + expect(server.statusAnalyzing, isFalse); |
| + channel.notificationsReceived.clear(); |
| + server.updateContent('0', { |
| + bar.path: new AddContentOverlay('library bar; void f() {}') |
| + }); |
| + await pumpEventQueue(100); |
| + expect(server.statusAnalyzing, isFalse); |
| + expect(channel.notificationsReceived, isNotEmpty); |
| + Set<String> notificationTypesReceived = new Set<String>(); |
| + for (Notification notification in channel.notificationsReceived) { |
| + String notificationType = notification.event; |
| + switch (notificationType) { |
| + case 'server.status': |
| + case 'analysis.errors': |
| + // It's normal for these notifications to be sent multiple times. |
| + break; |
| + case 'analysis.outline': |
| + // It's normal for this notification to be sent twice. |
| + // TODO(paulberry): why? |
|
danrubel
2015/01/29 21:37:00
Do we send an outline once when it is parsed and a
|
| + break; |
| + default: |
| + if (!notificationTypesReceived.add(notificationType)) { |
| + fail('Notification type $notificationType received more than once'); |
| + } |
| + break; |
| + } |
| + } |
| + return null; // Work around dartbug.com/22091 |
| + } |
| + |
| Future test_prioritySourcesChangedEvent() { |
| resourceProvider.newFolder('/foo'); |