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

Unified 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, 11 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/lib/src/operation/operation_analysis.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/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');
« 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