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

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

Issue 2989633002: Issue 30238. Fix for subscribing for a notifications with already cached analysis result. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analyzer/lib/src/dart/analysis/driver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/analysis/notification_outline_test.dart
diff --git a/pkg/analysis_server/test/analysis/notification_outline_test.dart b/pkg/analysis_server/test/analysis/notification_outline_test.dart
index 69a440776f8d9fd55cc8a273bc21a74cceea90ce..e406df1c58bdf07dcfde651304dde245ace51e7a 100644
--- a/pkg/analysis_server/test/analysis/notification_outline_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_outline_test.dart
@@ -25,11 +25,12 @@ class _AnalysisNotificationOutlineTest extends AbstractAnalysisTest {
String libraryName;
Outline outline;
- Completer _resultsAvailable = new Completer();
+ Completer _outlineReceived = new Completer();
+ Completer _highlightsReceived = new Completer();
Future prepareOutline() {
addAnalysisSubscription(AnalysisService.OUTLINE, testFile);
- return _resultsAvailable.future;
+ return _outlineReceived.future;
}
void processNotification(Notification notification) {
@@ -39,7 +40,14 @@ class _AnalysisNotificationOutlineTest extends AbstractAnalysisTest {
fileKind = params.kind;
libraryName = params.libraryName;
outline = params.outline;
- _resultsAvailable.complete(null);
+ _outlineReceived.complete(null);
+ }
+ }
+ if (notification.event == ANALYSIS_NOTIFICATION_HIGHLIGHTS) {
+ var params = new AnalysisHighlightsParams.fromNotification(notification);
+ if (params.file == testFile) {
+ _highlightsReceived?.complete(null);
+ _highlightsReceived = null;
}
}
}
@@ -717,6 +725,27 @@ int fieldD; // marker2
}
}
+ test_subscribeWhenCachedResultIsAvailable() async {
+ // https://github.com/dart-lang/sdk/issues/30238
+ // We need to get notifications for new subscriptions even when the
+ // file is a priority file, and there is a cached result available.
+ addTestFile('''
+class A {}
+class B {}
+''');
+
+ // Make the file a priority one and subscribe for other notification.
+ // This will pre-cache the analysis result for the file.
+ setPriorityFiles([testFile]);
+ addAnalysisSubscription(AnalysisService.HIGHLIGHTS, testFile);
+ await _highlightsReceived.future;
+
+ // Now subscribe for outline notification, we must get it even though
+ // the result which is used is pre-cached, and not a newly computed.
+ await prepareOutline();
+ expect(outline.children, hasLength(2));
+ }
+
test_topLevel() async {
addTestFile('''
typedef String FTA<K, V>(int i, String s);
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analyzer/lib/src/dart/analysis/driver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698