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

Unified Diff: pkg/analysis_server/test/domain_completion_util.dart

Issue 2478963002: Completion with the new analysis driver. (Closed)
Patch Set: Fixes for review comments. Created 4 years, 1 month 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/domain_completion_util.dart
diff --git a/pkg/analysis_server/test/domain_completion_util.dart b/pkg/analysis_server/test/domain_completion_util.dart
index bd55b7212803090a9ec52bc8632502bdb8c38835..e95b14fcb3a67f0826eaa1a418e11c7e332bfe90 100644
--- a/pkg/analysis_server/test/domain_completion_util.dart
+++ b/pkg/analysis_server/test/domain_completion_util.dart
@@ -14,13 +14,13 @@ import 'package:analysis_server/src/services/index/index.dart';
import 'package:test/test.dart';
import 'analysis_abstract.dart';
-import 'mocks.dart';
class AbstractCompletionDomainTest extends AbstractAnalysisTest {
String completionId;
int completionOffset;
int replacementOffset;
int replacementLength;
+ Map<String, Completer<Null>> receivedSuggestionsCompleters = {};
List<CompletionSuggestion> suggestions = [];
bool suggestionsDone = false;
Map<String, List<CompletionSuggestion>> allSuggestions = {};
@@ -82,34 +82,33 @@ class AbstractCompletionDomainTest extends AbstractAnalysisTest {
return createMemoryIndex();
}
- Future getSuggestions() {
- return waitForTasksFinished().then((_) {
- Request request =
- new CompletionGetSuggestionsParams(testFile, completionOffset)
- .toRequest('0');
- Response response = handleSuccessfulRequest(request);
- completionId = response.id;
- assertValidId(completionId);
- return pumpEventQueue().then((_) {
- expect(suggestionsDone, isTrue);
- });
- });
+ Future getSuggestions() async {
+ await waitForTasksFinished();
+
+ Request request =
+ new CompletionGetSuggestionsParams(testFile, completionOffset)
+ .toRequest('0');
+ Response response = await waitResponse(request);
+ var result = new CompletionGetSuggestionsResult.fromResponse(response);
+ completionId = result.id;
+ assertValidId(completionId);
+ await _getResultsCompleter(completionId).future;
+ expect(suggestionsDone, isTrue);
}
- void processNotification(Notification notification) {
+ processNotification(Notification notification) async {
if (notification.event == COMPLETION_RESULTS) {
var params = new CompletionResultsParams.fromNotification(notification);
String id = params.id;
assertValidId(id);
- if (id == completionId) {
- expect(suggestionsDone, isFalse);
- replacementOffset = params.replacementOffset;
- replacementLength = params.replacementLength;
- suggestionsDone = params.isLast;
- expect(suggestionsDone, isNotNull);
- suggestions = params.results;
- }
+ replacementOffset = params.replacementOffset;
+ replacementLength = params.replacementLength;
+ suggestionsDone = params.isLast;
+ expect(suggestionsDone, isNotNull);
+ suggestions = params.results;
+ expect(allSuggestions.containsKey(id), isFalse);
allSuggestions[id] = params.results;
+ _getResultsCompleter(id).complete(null);
} else if (notification.event == SERVER_ERROR) {
fail('server error: ${notification.toJson()}');
}
@@ -121,4 +120,9 @@ class AbstractCompletionDomainTest extends AbstractAnalysisTest {
createProject();
handler = new CompletionDomainHandler(server);
}
+
+ Completer<Null> _getResultsCompleter(String id) {
+ return receivedSuggestionsCompleters.putIfAbsent(
+ id, () => new Completer<Null>());
+ }
}

Powered by Google App Engine
This is Rietveld 408576698