| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.domain.completion; | 5 library test.domain.completion; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/constants.dart'; | 9 import 'package:analysis_server/src/constants.dart'; |
| 10 import 'package:analysis_server/src/domain_completion.dart'; | 10 import 'package:analysis_server/src/domain_completion.dart'; |
| 11 import 'package:analysis_server/src/protocol.dart'; | 11 import 'package:analysis_server/src/protocol.dart'; |
| 12 import 'package:analysis_server/src/protocol2.dart' show | 12 import 'package:analysis_server/src/protocol2.dart' show |
| 13 CompletionGetSuggestionsParams; | 13 CompletionGetSuggestionsParams, CompletionGetSuggestionsResult; |
| 14 import 'package:analysis_server/src/services/completion/completion_suggestion.da
rt'; | 14 import 'package:analysis_server/src/services/completion/completion_suggestion.da
rt'; |
| 15 import 'package:analysis_server/src/services/index/index.dart' show Index; | 15 import 'package:analysis_server/src/services/index/index.dart' show Index; |
| 16 import 'package:analysis_server/src/services/index/local_memory_index.dart'; | 16 import 'package:analysis_server/src/services/index/local_memory_index.dart'; |
| 17 import 'package:analysis_testing/reflective_tests.dart'; | 17 import 'package:analysis_testing/reflective_tests.dart'; |
| 18 import 'package:unittest/unittest.dart'; | 18 import 'package:unittest/unittest.dart'; |
| 19 | 19 |
| 20 import 'analysis_abstract.dart'; | 20 import 'analysis_abstract.dart'; |
| 21 import 'mocks.dart'; | 21 import 'mocks.dart'; |
| 22 | 22 |
| 23 main() { | 23 main() { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 @override | 83 @override |
| 84 Index createIndex() { | 84 Index createIndex() { |
| 85 return createLocalMemoryIndex(); | 85 return createLocalMemoryIndex(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 Future getSuggestions() { | 88 Future getSuggestions() { |
| 89 return waitForTasksFinished().then((_) { | 89 return waitForTasksFinished().then((_) { |
| 90 Request request = new CompletionGetSuggestionsParams(testFile, | 90 Request request = new CompletionGetSuggestionsParams(testFile, |
| 91 completionOffset).toRequest('0'); | 91 completionOffset).toRequest('0'); |
| 92 Response response = handleSuccessfulRequest(request); | 92 Response response = handleSuccessfulRequest(request); |
| 93 completionId = response.getResult(ID); | 93 var result = new CompletionGetSuggestionsResult.fromResponse(response); |
| 94 completionId = response.id; |
| 94 assertValidId(completionId); | 95 assertValidId(completionId); |
| 95 return pumpEventQueue().then((_) { | 96 return pumpEventQueue().then((_) { |
| 96 expect(suggestionsDone, isTrue); | 97 expect(suggestionsDone, isTrue); |
| 97 }); | 98 }); |
| 98 }); | 99 }); |
| 99 } | 100 } |
| 100 | 101 |
| 101 void processNotification(Notification notification) { | 102 void processNotification(Notification notification) { |
| 102 if (notification.event == COMPLETION_RESULTS) { | 103 if (notification.event == COMPLETION_RESULTS) { |
| 103 String id = notification.getParameter(ID); | 104 String id = notification.getParameter(ID); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 '''); | 206 '''); |
| 206 return getSuggestions().then((_) { | 207 return getSuggestions().then((_) { |
| 207 // expect(replacementOffset, equals(completionOffset - 3)); | 208 // expect(replacementOffset, equals(completionOffset - 3)); |
| 208 // expect(replacementLength, equals(4)); | 209 // expect(replacementLength, equals(4)); |
| 209 assertHasResult(CompletionSuggestionKind.CLASS, 'Object'); | 210 assertHasResult(CompletionSuggestionKind.CLASS, 'Object'); |
| 210 assertHasResult(CompletionSuggestionKind.TOP_LEVEL_VARIABLE, 'test'); | 211 assertHasResult(CompletionSuggestionKind.TOP_LEVEL_VARIABLE, 'test'); |
| 211 assertNoResult('HtmlElement'); | 212 assertNoResult('HtmlElement'); |
| 212 }); | 213 }); |
| 213 } | 214 } |
| 214 } | 215 } |
| OLD | NEW |