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

Side by Side Diff: pkg/analysis_server/test/domain_completion_test.dart

Issue 669483002: (TBR) fix failing test (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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';
(...skipping 19 matching lines...) Expand all
30 int replacementLength; 30 int replacementLength;
31 List<CompletionSuggestion> suggestions = []; 31 List<CompletionSuggestion> suggestions = [];
32 bool suggestionsDone = false; 32 bool suggestionsDone = false;
33 33
34 String addTestFile(String content) { 34 String addTestFile(String content) {
35 completionOffset = content.indexOf('^'); 35 completionOffset = content.indexOf('^');
36 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^'); 36 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^');
37 int nextOffset = content.indexOf('^', completionOffset + 1); 37 int nextOffset = content.indexOf('^', completionOffset + 1);
38 expect(nextOffset, equals(-1), reason: 'too many ^'); 38 expect(nextOffset, equals(-1), reason: 'too many ^');
39 return super.addTestFile( 39 return super.addTestFile(
40 content.substring(0, completionOffset) 40 content.substring(0, completionOffset) +
41 + content.substring(completionOffset + 1)); 41 content.substring(completionOffset + 1));
42 } 42 }
43 43
44 void assertHasResult(CompletionSuggestionKind kind, String completion, 44 void assertHasResult(CompletionSuggestionKind kind, String completion,
45 [CompletionRelevance relevance = CompletionRelevance.DEFAULT, 45 [CompletionRelevance relevance = CompletionRelevance.DEFAULT, bool isDepre cated
46 bool isDeprecated = false, bool isPotential = false]) { 46 = false, bool isPotential = false]) {
47 var cs; 47 var cs;
48 suggestions.forEach((s) { 48 suggestions.forEach((s) {
49 if (s.completion == completion) { 49 if (s.completion == completion) {
50 if (cs == null) { 50 if (cs == null) {
51 cs = s; 51 cs = s;
52 } else { 52 } else {
53 fail('expected exactly one $completion but found > 1'); 53 fail('expected exactly one $completion but found > 1');
54 } 54 }
55 } 55 }
56 }); 56 });
(...skipping 20 matching lines...) Expand all
77 expect(id.isNotEmpty, isTrue); 77 expect(id.isNotEmpty, isTrue);
78 } 78 }
79 79
80 @override 80 @override
81 Index createIndex() { 81 Index createIndex() {
82 return createLocalMemoryIndex(); 82 return createLocalMemoryIndex();
83 } 83 }
84 84
85 Future getSuggestions() { 85 Future getSuggestions() {
86 return waitForTasksFinished().then((_) { 86 return waitForTasksFinished().then((_) {
87 Request request = new CompletionGetSuggestionsParams(testFile, 87 Request request =
88 completionOffset).toRequest('0'); 88 new CompletionGetSuggestionsParams(testFile, completionOffset).toReque st('0');
89 Response response = handleSuccessfulRequest(request); 89 Response response = handleSuccessfulRequest(request);
90 var result = new CompletionGetSuggestionsResult.fromResponse(response); 90 var result = new CompletionGetSuggestionsResult.fromResponse(response);
91 completionId = response.id; 91 completionId = response.id;
92 assertValidId(completionId); 92 assertValidId(completionId);
93 return pumpEventQueue().then((_) { 93 return pumpEventQueue().then((_) {
94 expect(suggestionsDone, isTrue); 94 expect(suggestionsDone, isTrue);
95 }); 95 });
96 }); 96 });
97 } 97 }
98 98
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 assertNoResult('HtmlElement'); 158 assertNoResult('HtmlElement');
159 assertNoResult('test'); 159 assertNoResult('test');
160 }); 160 });
161 } 161 }
162 162
163 test_keyword() { 163 test_keyword() {
164 addTestFile('library A; cl^'); 164 addTestFile('library A; cl^');
165 return getSuggestions().then((_) { 165 return getSuggestions().then((_) {
166 expect(replacementOffset, equals(completionOffset - 2)); 166 expect(replacementOffset, equals(completionOffset - 2));
167 expect(replacementLength, equals(2)); 167 expect(replacementLength, equals(2));
168 assertHasResult(CompletionSuggestionKind.KEYWORD, 'import'); 168 assertHasResult(
169 assertHasResult(CompletionSuggestionKind.KEYWORD, 'class'); 169 CompletionSuggestionKind.KEYWORD,
170 'import',
171 CompletionRelevance.HIGH);
172 assertHasResult(
173 CompletionSuggestionKind.KEYWORD,
174 'class',
175 CompletionRelevance.HIGH);
170 }); 176 });
171 } 177 }
172 178
173 test_locals() { 179 test_locals() {
174 addTestFile('class A {var a; x() {var b;^}}'); 180 addTestFile('class A {var a; x() {var b;^}}');
175 return getSuggestions().then((_) { 181 return getSuggestions().then((_) {
176 expect(replacementOffset, equals(completionOffset)); 182 expect(replacementOffset, equals(completionOffset));
177 expect(replacementLength, equals(0)); 183 expect(replacementLength, equals(0));
178 assertHasResult(CompletionSuggestionKind.CLASS, 'A'); 184 assertHasResult(CompletionSuggestionKind.CLASS, 'A');
179 assertHasResult(CompletionSuggestionKind.GETTER, 'a'); 185 assertHasResult(CompletionSuggestionKind.GETTER, 'a');
(...skipping 19 matching lines...) Expand all
199 '''); 205 ''');
200 return getSuggestions().then((_) { 206 return getSuggestions().then((_) {
201 expect(replacementOffset, equals(completionOffset - 3)); 207 expect(replacementOffset, equals(completionOffset - 3));
202 expect(replacementLength, equals(4)); 208 expect(replacementLength, equals(4));
203 assertHasResult(CompletionSuggestionKind.CLASS, 'Object'); 209 assertHasResult(CompletionSuggestionKind.CLASS, 'Object');
204 assertHasResult(CompletionSuggestionKind.TOP_LEVEL_VARIABLE, 'test'); 210 assertHasResult(CompletionSuggestionKind.TOP_LEVEL_VARIABLE, 'test');
205 assertNoResult('HtmlElement'); 211 assertNoResult('HtmlElement');
206 }); 212 });
207 } 213 }
208 } 214 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698