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

Unified Diff: pkg/analyzer/test/src/context/context_test.dart

Issue 1776023002: Add AnalysisContext.onResultInvalidated(descriptor). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fixes for review comments. Created 4 years, 9 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/analyzer/test/src/context/context_test.dart
diff --git a/pkg/analyzer/test/src/context/context_test.dart b/pkg/analyzer/test/src/context/context_test.dart
index d7e0a589a8332abb27ec4495d480e703e2f97f9f..c45b6a9c2ef97afbfebfd981ebaa22e95a7a9047 100644
--- a/pkg/analyzer/test/src/context/context_test.dart
+++ b/pkg/analyzer/test/src/context/context_test.dart
@@ -1463,6 +1463,44 @@ main() {}''');
expect(context.isServerLibrary(source), isFalse);
}
+ void test_onResultInvalidated_removeSource() {
+ Source source = addSource('/test.dart', 'main() {}');
+ bool listenerInvoked = false;
+ context
+ .onResultInvalidated(RESOLVED_UNIT)
+ .listen((InvalidatedResultEvent event) {
+ Source eventSource = event.target.source;
+ expect(event.descriptor, RESOLVED_UNIT);
+ expect(eventSource, source);
+ listenerInvoked = true;
+ });
+ _analyzeAll_assertFinished();
+ // apply changes
+ expect(listenerInvoked, false);
+ context.applyChanges(new ChangeSet()..removedSource(source));
+ // verify
+ expect(listenerInvoked, isTrue);
+ }
+
+ void test_onResultInvalidated_setContents() {
+ Source source = addSource('/test.dart', 'main() {}');
+ bool listenerInvoked = false;
+ context
+ .onResultInvalidated(RESOLVED_UNIT)
+ .listen((InvalidatedResultEvent event) {
+ Source eventSource = event.target.source;
+ expect(event.descriptor, RESOLVED_UNIT);
+ expect(eventSource, source);
+ listenerInvoked = true;
+ });
+ _analyzeAll_assertFinished();
+ // apply changes
+ expect(listenerInvoked, false);
+ context.setContents(source, 'class B {}');
+ // verify
+ expect(listenerInvoked, isTrue);
+ }
+
void test_parseCompilationUnit_errors() {
Source source = addSource("/lib.dart", "library {");
CompilationUnit compilationUnit = context.parseCompilationUnit(source);
« pkg/analyzer/lib/src/generated/engine.dart ('K') | « pkg/analyzer/test/generated/engine_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698