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