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

Unified Diff: pkg/analysis_server/test/analysis/notification_analyzedFiles_test.dart

Issue 1233003002: Only send "analysis.analyzedFiles" notification when the set of files changes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
Index: pkg/analysis_server/test/analysis/notification_analyzedFiles_test.dart
diff --git a/pkg/analysis_server/test/analysis/notification_analyzedFiles_test.dart b/pkg/analysis_server/test/analysis/notification_analyzedFiles_test.dart
index 2cf1606591205aae39239a92b289aa03482e2244..c4fbf14ef28c751f25f28e986b56a1a7b225eff3 100644
--- a/pkg/analysis_server/test/analysis/notification_analyzedFiles_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_analyzedFiles_test.dart
@@ -12,6 +12,7 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'package:unittest/unittest.dart';
import '../analysis_abstract.dart';
+import '../mocks.dart';
main() {
groupSep = ' | ';
@@ -21,8 +22,10 @@ main() {
@reflectiveTest
class AnalysisNotificationAnalyzedFilesTest extends AbstractAnalysisTest {
List<String> analyzedFiles;
+ bool analyzedFilesReceived = false;
void assertHasFile(String filePath) {
+ expect(analyzedFilesReceived, isTrue);
expect(analyzedFiles, contains(filePath));
}
@@ -35,6 +38,7 @@ class AnalysisNotificationAnalyzedFilesTest extends AbstractAnalysisTest {
if (notification.event == ANALYSIS_ANALYZED_FILES) {
AnalysisAnalyzedFilesParams params =
new AnalysisAnalyzedFilesParams.fromNotification(notification);
+ analyzedFilesReceived = true;
analyzedFiles = params.directories;
}
}
@@ -55,7 +59,7 @@ class A {}
});
}
- test_definedInInterface_ofInterface() {
+ test_beforeAnalysis() {
addTestFile('''
class A {}
''');
@@ -63,4 +67,52 @@ class A {}
assertHasFile(testFile);
});
}
+
+ test_insignificant_change() async {
+ // Making a change that doesn't affect the set of reachable files should
+ // not trigger the notification to be re-sent.
+ addTestFile('class A {}');
+ await prepareAnalyzedFiles();
+ await waitForTasksFinished();
+ expect(analyzedFilesReceived, isTrue);
+ analyzedFilesReceived = false;
+ modifyTestFile('class B {}');
+ await pumpEventQueue();
+ await waitForTasksFinished();
+ expect(analyzedFilesReceived, isFalse);
+ }
+
+ test_resubscribe_no_changes() async {
+ // Unsubscribing and resubscribing should cause the notification to be
+ // re-sent, even if nothing has changed.
+ addTestFile('class A {}');
+ await prepareAnalyzedFiles();
+ await waitForTasksFinished();
+ expect(analyzedFilesReceived, isTrue);
+ unsubscribeAnalyzedFiles();
+ analyzedFilesReceived = false;
+ await prepareAnalyzedFiles();
+ expect(analyzedFilesReceived, isTrue);
+ assertHasFile(testFile);
+ }
+
+ test_significant_change() async {
+ // Making a change that *does* affect the set of reachable files should
+ // trigger the notification to be re-sent.
+ addTestFile('class A {}');
+ addFile('/foo.dart', 'library foo');
+ await prepareAnalyzedFiles();
+ await waitForTasksFinished();
+ expect(analyzedFilesReceived, isTrue);
+ analyzedFilesReceived = false;
+ modifyTestFile('import "/foo.dart";');
+ await pumpEventQueue();
+ await waitForTasksFinished();
+ expect(analyzedFilesReceived, isTrue);
+ assertHasFile('/foo.dart');
+ }
+
+ void unsubscribeAnalyzedFiles() {
+ removeGeneralAnalysisSubscription(GeneralAnalysisService.ANALYZED_FILES);
+ }
}
« no previous file with comments | « pkg/analysis_server/lib/src/operation/operation_analysis.dart ('k') | pkg/analysis_server/test/analysis_abstract.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698