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.services.completion.dart.util; | 5 library test.services.completion.dart.util; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol | 9 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol |
10 show Element, ElementKind; | 10 show Element, ElementKind; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 void assertHasParameterInfo(CompletionSuggestion suggestion) { | 55 void assertHasParameterInfo(CompletionSuggestion suggestion) { |
56 expect(suggestion.parameterNames, isNotNull); | 56 expect(suggestion.parameterNames, isNotNull); |
57 expect(suggestion.parameterTypes, isNotNull); | 57 expect(suggestion.parameterTypes, isNotNull); |
58 expect(suggestion.parameterNames.length, suggestion.parameterTypes.length); | 58 expect(suggestion.parameterNames.length, suggestion.parameterTypes.length); |
59 expect(suggestion.requiredParameterCount, | 59 expect(suggestion.requiredParameterCount, |
60 lessThanOrEqualTo(suggestion.parameterNames.length)); | 60 lessThanOrEqualTo(suggestion.parameterNames.length)); |
61 expect(suggestion.hasNamedParameters, isNotNull); | 61 expect(suggestion.hasNamedParameters, isNotNull); |
62 } | 62 } |
63 | 63 |
| 64 void assertNoSuggestions({CompletionSuggestionKind kind: null}) { |
| 65 if (kind == null) { |
| 66 if (suggestions.length > 0) { |
| 67 failedCompletion('Expected no suggestions', suggestions); |
| 68 } |
| 69 return; |
| 70 } |
| 71 CompletionSuggestion suggestion = suggestions.firstWhere( |
| 72 (CompletionSuggestion cs) => cs.kind == kind, |
| 73 orElse: () => null); |
| 74 if (suggestion != null) { |
| 75 failedCompletion('did not expect completion: $completion\n $suggestion'); |
| 76 } |
| 77 } |
| 78 |
64 void assertNotSuggested(String completion) { | 79 void assertNotSuggested(String completion) { |
65 CompletionSuggestion suggestion = suggestions.firstWhere( | 80 CompletionSuggestion suggestion = suggestions.firstWhere( |
66 (CompletionSuggestion cs) => cs.completion == completion, | 81 (CompletionSuggestion cs) => cs.completion == completion, |
67 orElse: () => null); | 82 orElse: () => null); |
68 if (suggestion != null) { | 83 if (suggestion != null) { |
69 failedCompletion('did not expect completion: $completion\n $suggestion'); | 84 failedCompletion('did not expect completion: $completion\n $suggestion'); |
70 } | 85 } |
71 } | 86 } |
72 | 87 |
73 CompletionSuggestion assertSuggest(String completion, | 88 CompletionSuggestion assertSuggest(String completion, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 } | 224 } |
210 | 225 |
211 @override | 226 @override |
212 void setUp() { | 227 void setUp() { |
213 super.setUp(); | 228 super.setUp(); |
214 index = createLocalMemoryIndex(); | 229 index = createLocalMemoryIndex(); |
215 searchEngine = new SearchEngineImpl(index); | 230 searchEngine = new SearchEngineImpl(index); |
216 contributor = createContributor(); | 231 contributor = createContributor(); |
217 } | 232 } |
218 } | 233 } |
OLD | NEW |