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); |
+ } |
} |