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

Side by Side Diff: pkg/analysis_server/test/services/completion/dart/uri_contributor_test.dart

Issue 1498733005: convert uri contributor to use new task model (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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
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.services.completion.contributor.dart.importuri; 5 library test.services.completion.contributor.dart.importuri;
6 6
7 import 'package:analysis_server/plugin/protocol/protocol.dart'; 7 import 'package:analysis_server/plugin/protocol/protocol.dart';
8 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; 8 import 'package:analysis_server/src/provisional/completion/dart/completion_dart. dart';
9 import 'package:analysis_server/src/services/completion/uri_contributor.dart'; 9 import 'package:analysis_server/src/services/completion/dart/uri_contributor.dar t';
10 import 'package:analyzer/file_system/memory_file_system.dart'; 10 import 'package:analyzer/file_system/memory_file_system.dart';
11 import 'package:path/path.dart'; 11 import 'package:path/path.dart';
12 import 'package:test_reflective_loader/test_reflective_loader.dart'; 12 import 'package:test_reflective_loader/test_reflective_loader.dart';
13 import 'package:unittest/unittest.dart'; 13 import 'package:unittest/unittest.dart';
14 14
15 import '../../utils.dart'; 15 import '../../../utils.dart';
16 import 'completion_test_util.dart'; 16 import 'completion_contributor_util.dart';
17 17
18 main() { 18 main() {
19 initializeTestEnvironment(); 19 initializeTestEnvironment();
20 defineReflectiveTests(UriContributorTest); 20 defineReflectiveTests(UriContributorTest);
21 defineReflectiveTests(UriContributorWindowsTest); 21 defineReflectiveTests(UriContributorWindowsTest);
22 } 22 }
23 23
24 @reflectiveTest 24 @reflectiveTest
25 class UriContributorTest extends AbstractCompletionTest { 25 class UriContributorTest extends DartCompletionContributorTest {
26 @override 26 @override
27 void setUpContributor() { 27 DartCompletionContributor createContributor() {
28 contributor = new UriContributor(); 28 return new UriContributor();
29 } 29 }
30 30
31 test_after_import() { 31 test_after_import() async {
32 addTestSource('import "p"^'); 32 addTestSource('import "p"^');
33 computeFast(); 33 await computeSuggestions();
34 expect(request.replacementOffset, completionOffset); 34 expect(replacementOffset, completionOffset);
35 expect(request.replacementLength, 0); 35 expect(replacementLength, 0);
36 assertNoSuggestions(); 36 assertNoSuggestions();
37 } 37 }
38 38
39 test_after_import_raw() { 39 test_after_import_raw() async {
40 addTestSource('import r"p"^'); 40 addTestSource('import r"p"^');
41 computeFast(); 41 await computeSuggestions();
42 expect(request.replacementOffset, completionOffset); 42 expect(replacementOffset, completionOffset);
43 expect(request.replacementLength, 0); 43 expect(replacementLength, 0);
44 assertNoSuggestions(); 44 assertNoSuggestions();
45 } 45 }
46 46
47 test_before_import() { 47 test_before_import() async {
48 addTestSource('import ^"p"'); 48 addTestSource('import ^"p"');
49 computeFast(); 49 await computeSuggestions();
50 expect(request.replacementOffset, completionOffset); 50 expect(replacementOffset, completionOffset);
51 expect(request.replacementLength, 0); 51 expect(replacementLength, 0);
52 assertNoSuggestions(); 52 assertNoSuggestions();
53 } 53 }
54 54
55 test_before_import_raw() { 55 test_before_import_raw() async {
56 addTestSource('import ^r"p"'); 56 addTestSource('import ^r"p"');
57 computeFast(); 57 await computeSuggestions();
58 expect(request.replacementOffset, completionOffset); 58 expect(replacementOffset, completionOffset);
59 expect(request.replacementLength, 0); 59 expect(replacementLength, 0);
60 assertNoSuggestions(); 60 assertNoSuggestions();
61 } 61 }
62 62
63 test_before_import_raw2() { 63 test_before_import_raw2() async {
64 addTestSource('import r^"p"'); 64 addTestSource('import r^"p"');
65 computeFast(); 65 await computeSuggestions();
66 expect(request.replacementOffset, completionOffset); 66 expect(replacementOffset, completionOffset);
67 expect(request.replacementLength, 0); 67 expect(replacementLength, 0);
68 assertNoSuggestions(); 68 assertNoSuggestions();
69 } 69 }
70 70
71 test_export_package2() { 71 test_export_package2() async {
72 addPackageSource('foo', 'foo.dart', 'library foo;'); 72 addPackageSource('foo', 'foo.dart', 'library foo;');
73 addPackageSource('foo', 'baz/too.dart', 'library too;'); 73 addPackageSource('foo', 'baz/too.dart', 'library too;');
74 addPackageSource('bar', 'bar.dart', 'library bar;'); 74 addPackageSource('bar', 'bar.dart', 'library bar;');
75 addTestSource('export "package:foo/baz/^" import'); 75 addTestSource('export "package:foo/baz/^" import');
76 computeFast(); 76 await computeSuggestions();
77 assertSuggest('package:foo/baz/too.dart', 77 assertSuggest('package:foo/baz/too.dart',
78 csKind: CompletionSuggestionKind.IMPORT); 78 csKind: CompletionSuggestionKind.IMPORT);
79 } 79 }
80 80
81 test_import() { 81 test_import() async {
82 addTestSource('import "^"'); 82 addTestSource('import "^"');
83 computeFast(); 83 await computeSuggestions();
84 expect(request.replacementOffset, completionOffset); 84 expect(replacementOffset, completionOffset);
85 expect(request.replacementLength, 0); 85 expect(replacementLength, 0);
86 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT); 86 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT);
87 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); 87 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT);
88 } 88 }
89 89
90 test_import2() { 90 test_import2() async {
91 addTestSource('import "^" import'); 91 addTestSource('import "^" import');
92 computeFast(); 92 await computeSuggestions();
93 expect(request.replacementOffset, completionOffset); 93 expect(replacementOffset, completionOffset);
94 expect(request.replacementLength, 0); 94 expect(replacementLength, 0);
95 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT); 95 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT);
96 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); 96 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT);
97 } 97 }
98 98
99 test_import_dart() { 99 test_import_dart() async {
100 addTestSource('import "d^" import'); 100 addTestSource('import "d^" import');
101 computeFast(); 101 await computeSuggestions();
102 expect(request.replacementOffset, completionOffset - 1); 102 expect(replacementOffset, completionOffset - 1);
103 expect(request.replacementLength, 1); 103 expect(replacementLength, 1);
104 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT); 104 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT);
105 assertSuggest('dart:core', 105 assertSuggest('dart:core',
106 csKind: CompletionSuggestionKind.IMPORT, relevance: DART_RELEVANCE_LOW); 106 csKind: CompletionSuggestionKind.IMPORT, relevance: DART_RELEVANCE_LOW);
107 assertNotSuggested('dart:_internal'); 107 assertNotSuggested('dart:_internal');
108 assertSuggest('dart:async', csKind: CompletionSuggestionKind.IMPORT); 108 assertSuggest('dart:async', csKind: CompletionSuggestionKind.IMPORT);
109 assertSuggest('dart:math', csKind: CompletionSuggestionKind.IMPORT); 109 assertSuggest('dart:math', csKind: CompletionSuggestionKind.IMPORT);
110 } 110 }
111 111
112 test_import_dart2() { 112 test_import_dart2() async {
113 addTestSource('import "dart:async"; import "d^"'); 113 addTestSource('import "dart:async"; import "d^"');
114 computeFast(); 114 await computeSuggestions();
115 expect(request.replacementOffset, completionOffset - 1); 115 expect(replacementOffset, completionOffset - 1);
116 expect(request.replacementLength, 1); 116 expect(replacementLength, 1);
117 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT); 117 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT);
118 assertSuggest('dart:core', 118 assertSuggest('dart:core',
119 csKind: CompletionSuggestionKind.IMPORT, relevance: DART_RELEVANCE_LOW); 119 csKind: CompletionSuggestionKind.IMPORT, relevance: DART_RELEVANCE_LOW);
120 assertNotSuggested('dart:_internal'); 120 assertNotSuggested('dart:_internal');
121 assertSuggest('dart:async', csKind: CompletionSuggestionKind.IMPORT); 121 assertSuggest('dart:async', csKind: CompletionSuggestionKind.IMPORT);
122 assertSuggest('dart:math', csKind: CompletionSuggestionKind.IMPORT); 122 assertSuggest('dart:math', csKind: CompletionSuggestionKind.IMPORT);
123 } 123 }
124 124
125 test_import_file() { 125 test_import_file() async {
126 testFile = '/proj/completion.dart'; 126 testFile = '/proj/completion.dart';
127 addSource('/proj/other.dart', 'library other;'); 127 addSource('/proj/other.dart', 'library other;');
128 addSource('/proj/foo/bar.dart', 'library bar;'); 128 addSource('/proj/foo/bar.dart', 'library bar;');
129 addSource('/blat.dart', 'library blat;'); 129 addSource('/blat.dart', 'library blat;');
130 addTestSource('import "^" import'); 130 addTestSource('import "^" import');
131 computeFast(); 131 await computeSuggestions();
132 expect(request.replacementOffset, completionOffset); 132 expect(replacementOffset, completionOffset);
133 expect(request.replacementLength, 0); 133 expect(replacementLength, 0);
134 assertNotSuggested('completion.dart'); 134 assertNotSuggested('completion.dart');
135 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT); 135 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT);
136 assertNotSuggested('foo'); 136 assertNotSuggested('foo');
137 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT); 137 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT);
138 assertNotSuggested('foo/bar.dart'); 138 assertNotSuggested('foo/bar.dart');
139 assertNotSuggested('../blat.dart'); 139 assertNotSuggested('../blat.dart');
140 } 140 }
141 141
142 test_import_file2() { 142 test_import_file2() async {
143 testFile = '/proj/completion.dart'; 143 testFile = '/proj/completion.dart';
144 addSource('/proj/other.dart', 'library other;'); 144 addSource('/proj/other.dart', 'library other;');
145 addSource('/proj/foo/bar.dart', 'library bar;'); 145 addSource('/proj/foo/bar.dart', 'library bar;');
146 addSource('/blat.dart', 'library blat;'); 146 addSource('/blat.dart', 'library blat;');
147 addTestSource('import "..^" import'); 147 addTestSource('import "..^" import');
148 computeFast(); 148 await computeSuggestions();
149 expect(request.replacementOffset, completionOffset - 2); 149 expect(replacementOffset, completionOffset - 2);
150 expect(request.replacementLength, 2); 150 expect(replacementLength, 2);
151 assertNotSuggested('completion.dart'); 151 assertNotSuggested('completion.dart');
152 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT); 152 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT);
153 assertNotSuggested('foo'); 153 assertNotSuggested('foo');
154 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT); 154 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT);
155 assertNotSuggested('foo/bar.dart'); 155 assertNotSuggested('foo/bar.dart');
156 assertNotSuggested('../blat.dart'); 156 assertNotSuggested('../blat.dart');
157 } 157 }
158 158
159 test_import_file_child() { 159 test_import_file_child() async {
160 testFile = '/proj/completion.dart'; 160 testFile = '/proj/completion.dart';
161 addSource('/proj/other.dart', 'library other;'); 161 addSource('/proj/other.dart', 'library other;');
162 addSource('/proj/foo/bar.dart', 'library bar;'); 162 addSource('/proj/foo/bar.dart', 'library bar;');
163 addSource('/blat.dart', 'library blat;'); 163 addSource('/blat.dart', 'library blat;');
164 addTestSource('import "foo/^" import'); 164 addTestSource('import "foo/^" import');
165 computeFast(); 165 await computeSuggestions();
166 expect(request.replacementOffset, completionOffset - 4); 166 expect(replacementOffset, completionOffset - 4);
167 expect(request.replacementLength, 4); 167 expect(replacementLength, 4);
168 assertNotSuggested('completion.dart'); 168 assertNotSuggested('completion.dart');
169 assertNotSuggested('other.dart'); 169 assertNotSuggested('other.dart');
170 assertNotSuggested('foo'); 170 assertNotSuggested('foo');
171 assertNotSuggested('foo/'); 171 assertNotSuggested('foo/');
172 assertSuggest('foo/bar.dart', csKind: CompletionSuggestionKind.IMPORT); 172 assertSuggest('foo/bar.dart', csKind: CompletionSuggestionKind.IMPORT);
173 assertNotSuggested('../blat.dart'); 173 assertNotSuggested('../blat.dart');
174 } 174 }
175 175
176 test_import_file_parent() { 176 test_import_file_parent() async {
177 testFile = '/proj/completion.dart'; 177 testFile = '/proj/completion.dart';
178 addSource('/proj/other.dart', 'library other;'); 178 addSource('/proj/other.dart', 'library other;');
179 addSource('/proj/foo/bar.dart', 'library bar;'); 179 addSource('/proj/foo/bar.dart', 'library bar;');
180 addSource('/blat.dart', 'library blat;'); 180 addSource('/blat.dart', 'library blat;');
181 addTestSource('import "../^" import'); 181 addTestSource('import "../^" import');
182 computeFast(); 182 await computeSuggestions();
183 expect(request.replacementOffset, completionOffset - 3); 183 expect(replacementOffset, completionOffset - 3);
184 expect(request.replacementLength, 3); 184 expect(replacementLength, 3);
185 assertNotSuggested('completion.dart'); 185 assertNotSuggested('completion.dart');
186 assertNotSuggested('other.dart'); 186 assertNotSuggested('other.dart');
187 assertNotSuggested('foo'); 187 assertNotSuggested('foo');
188 assertNotSuggested('foo/'); 188 assertNotSuggested('foo/');
189 assertNotSuggested('foo/bar.dart'); 189 assertNotSuggested('foo/bar.dart');
190 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); 190 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT);
191 } 191 }
192 192
193 test_import_file_parent2() { 193 test_import_file_parent2() async {
194 testFile = '/proj/completion.dart'; 194 testFile = '/proj/completion.dart';
195 addSource('/proj/other.dart', 'library other;'); 195 addSource('/proj/other.dart', 'library other;');
196 addSource('/proj/foo/bar.dart', 'library bar;'); 196 addSource('/proj/foo/bar.dart', 'library bar;');
197 addSource('/blat.dart', 'library blat;'); 197 addSource('/blat.dart', 'library blat;');
198 addTestSource('import "../b^" import'); 198 addTestSource('import "../b^" import');
199 computeFast(); 199 await computeSuggestions();
200 expect(request.replacementOffset, completionOffset - 4); 200 expect(replacementOffset, completionOffset - 4);
201 expect(request.replacementLength, 4); 201 expect(replacementLength, 4);
202 assertNotSuggested('completion.dart'); 202 assertNotSuggested('completion.dart');
203 assertNotSuggested('other.dart'); 203 assertNotSuggested('other.dart');
204 assertNotSuggested('foo'); 204 assertNotSuggested('foo');
205 assertNotSuggested('foo/'); 205 assertNotSuggested('foo/');
206 assertNotSuggested('foo/bar.dart'); 206 assertNotSuggested('foo/bar.dart');
207 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); 207 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT);
208 } 208 }
209 209
210 test_import_package() { 210 test_import_package() async {
211 addPackageSource('foo', 'foo.dart', 'library foo;'); 211 addPackageSource('foo', 'foo.dart', 'library foo;');
212 addPackageSource('foo', 'baz/too.dart', 'library too;'); 212 addPackageSource('foo', 'baz/too.dart', 'library too;');
213 addPackageSource('bar', 'bar.dart', 'library bar;'); 213 addPackageSource('bar', 'bar.dart', 'library bar;');
214 addTestSource('import "p^" import'); 214 addTestSource('import "p^" import');
215 computeFast(); 215 await computeSuggestions();
216 expect(request.replacementOffset, completionOffset - 1); 216 expect(replacementOffset, completionOffset - 1);
217 expect(request.replacementLength, 1); 217 expect(replacementLength, 1);
218 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); 218 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT);
219 assertSuggest('package:foo/', csKind: CompletionSuggestionKind.IMPORT); 219 assertSuggest('package:foo/', csKind: CompletionSuggestionKind.IMPORT);
220 assertSuggest('package:foo/foo.dart', 220 assertSuggest('package:foo/foo.dart',
221 csKind: CompletionSuggestionKind.IMPORT); 221 csKind: CompletionSuggestionKind.IMPORT);
222 assertSuggest('package:foo/baz/', csKind: CompletionSuggestionKind.IMPORT); 222 assertSuggest('package:foo/baz/', csKind: CompletionSuggestionKind.IMPORT);
223 assertNotSuggested('package:foo/baz/too.dart'); 223 assertNotSuggested('package:foo/baz/too.dart');
224 assertSuggest('package:bar/', csKind: CompletionSuggestionKind.IMPORT); 224 assertSuggest('package:bar/', csKind: CompletionSuggestionKind.IMPORT);
225 assertSuggest('package:bar/bar.dart', 225 assertSuggest('package:bar/bar.dart',
226 csKind: CompletionSuggestionKind.IMPORT); 226 csKind: CompletionSuggestionKind.IMPORT);
227 } 227 }
228 228
229 test_import_package2() { 229 test_import_package2() async {
230 addPackageSource('foo', 'foo.dart', 'library foo;'); 230 addPackageSource('foo', 'foo.dart', 'library foo;');
231 addPackageSource('foo', 'baz/too.dart', 'library too;'); 231 addPackageSource('foo', 'baz/too.dart', 'library too;');
232 addPackageSource('bar', 'bar.dart', 'library bar;'); 232 addPackageSource('bar', 'bar.dart', 'library bar;');
233 addTestSource('import "package:foo/baz/^" import'); 233 addTestSource('import "package:foo/baz/^" import');
234 computeFast(); 234 await computeSuggestions();
235 assertSuggest('package:foo/baz/too.dart', 235 assertSuggest('package:foo/baz/too.dart',
236 csKind: CompletionSuggestionKind.IMPORT); 236 csKind: CompletionSuggestionKind.IMPORT);
237 } 237 }
238 238
239 test_import_package2_raw() { 239 test_import_package2_raw() async {
240 addPackageSource('foo', 'foo.dart', 'library foo;'); 240 addPackageSource('foo', 'foo.dart', 'library foo;');
241 addPackageSource('foo', 'baz/too.dart', 'library too;'); 241 addPackageSource('foo', 'baz/too.dart', 'library too;');
242 addPackageSource('bar', 'bar.dart', 'library bar;'); 242 addPackageSource('bar', 'bar.dart', 'library bar;');
243 addTestSource('import r"package:foo/baz/^" import'); 243 addTestSource('import r"package:foo/baz/^" import');
244 computeFast(); 244 await computeSuggestions();
245 assertSuggest('package:foo/baz/too.dart', 245 assertSuggest('package:foo/baz/too.dart',
246 csKind: CompletionSuggestionKind.IMPORT); 246 csKind: CompletionSuggestionKind.IMPORT);
247 } 247 }
248 248
249 test_import_package_missing_lib() { 249 test_import_package_missing_lib() async {
250 var pkgSrc = addPackageSource('bar', 'bar.dart', 'library bar;'); 250 var pkgSrc = addPackageSource('bar', 'bar.dart', 'library bar;');
251 provider.deleteFolder(dirname(pkgSrc.fullName)); 251 provider.deleteFolder(dirname(pkgSrc.fullName));
252 addTestSource('import "p^" class'); 252 addTestSource('import "p^" class');
253 computeFast(); 253 await computeSuggestions();
254 expect(request.replacementOffset, completionOffset - 1); 254 expect(replacementOffset, completionOffset - 1);
255 expect(request.replacementLength, 1); 255 expect(replacementLength, 1);
256 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); 256 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT);
257 assertSuggest('package:bar/', csKind: CompletionSuggestionKind.IMPORT); 257 assertSuggest('package:bar/', csKind: CompletionSuggestionKind.IMPORT);
258 assertNotSuggested('package:bar/bar.dart'); 258 assertNotSuggested('package:bar/bar.dart');
259 } 259 }
260 260
261 test_import_package_raw() { 261 test_import_package_raw() async {
262 addPackageSource('foo', 'foo.dart', 'library foo;'); 262 addPackageSource('foo', 'foo.dart', 'library foo;');
263 addPackageSource('foo', 'baz/too.dart', 'library too;'); 263 addPackageSource('foo', 'baz/too.dart', 'library too;');
264 addPackageSource('bar', 'bar.dart', 'library bar;'); 264 addPackageSource('bar', 'bar.dart', 'library bar;');
265 addTestSource('import r"p^" import'); 265 addTestSource('import r"p^" import');
266 computeFast(); 266 await computeSuggestions();
267 expect(request.replacementOffset, completionOffset - 1); 267 expect(replacementOffset, completionOffset - 1);
268 expect(request.replacementLength, 1); 268 expect(replacementLength, 1);
269 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); 269 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT);
270 assertSuggest('package:foo/', csKind: CompletionSuggestionKind.IMPORT); 270 assertSuggest('package:foo/', csKind: CompletionSuggestionKind.IMPORT);
271 assertSuggest('package:foo/foo.dart', 271 assertSuggest('package:foo/foo.dart',
272 csKind: CompletionSuggestionKind.IMPORT); 272 csKind: CompletionSuggestionKind.IMPORT);
273 assertSuggest('package:foo/baz/', csKind: CompletionSuggestionKind.IMPORT); 273 assertSuggest('package:foo/baz/', csKind: CompletionSuggestionKind.IMPORT);
274 assertNotSuggested('package:foo/baz/too.dart'); 274 assertNotSuggested('package:foo/baz/too.dart');
275 assertSuggest('package:bar/', csKind: CompletionSuggestionKind.IMPORT); 275 assertSuggest('package:bar/', csKind: CompletionSuggestionKind.IMPORT);
276 assertSuggest('package:bar/bar.dart', 276 assertSuggest('package:bar/bar.dart',
277 csKind: CompletionSuggestionKind.IMPORT); 277 csKind: CompletionSuggestionKind.IMPORT);
278 } 278 }
279 279
280 test_import_raw() { 280 test_import_raw() async {
281 addTestSource('import r"^" import'); 281 addTestSource('import r"^" import');
282 computeFast(); 282 await computeSuggestions();
283 expect(request.replacementOffset, completionOffset); 283 expect(replacementOffset, completionOffset);
284 expect(request.replacementLength, 0); 284 expect(replacementLength, 0);
285 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT); 285 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT);
286 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); 286 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT);
287 } 287 }
288 288
289 test_outside_import() { 289 test_outside_import() async {
290 addTestSource('import ^"d" import'); 290 addTestSource('import ^"d" import');
291 computeFast(); 291 await computeSuggestions();
292 computeFull((_) { 292 assertNoSuggestions();
293 assertNoSuggestions();
294 });
295 } 293 }
296 294
297 test_outside_import2() { 295 test_outside_import2() async {
298 addTestSource('import "d"^ import'); 296 addTestSource('import "d"^ import');
299 computeFast(); 297 await computeSuggestions();
300 computeFull((_) { 298 assertNoSuggestions();
301 assertNoSuggestions();
302 });
303 } 299 }
304 300
305 test_part_file() { 301 test_part_file() async {
306 testFile = '/proj/completion.dart'; 302 testFile = '/proj/completion.dart';
307 addSource('/proj/other.dart', 'library other;'); 303 addSource('/proj/other.dart', 'library other;');
308 addSource('/proj/foo/bar.dart', 'library bar;'); 304 addSource('/proj/foo/bar.dart', 'library bar;');
309 addSource('/blat.dart', 'library blat;'); 305 addSource('/blat.dart', 'library blat;');
310 addTestSource('library x; part "^" import'); 306 addTestSource('library x; part "^" import');
311 computeFast(); 307 await computeSuggestions();
312 expect(request.replacementOffset, completionOffset); 308 expect(replacementOffset, completionOffset);
313 expect(request.replacementLength, 0); 309 expect(replacementLength, 0);
314 assertNotSuggested('completion.dart'); 310 assertNotSuggested('completion.dart');
315 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT); 311 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT);
316 assertNotSuggested('foo'); 312 assertNotSuggested('foo');
317 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT); 313 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT);
318 assertNotSuggested('foo/bar.dart'); 314 assertNotSuggested('foo/bar.dart');
319 assertNotSuggested('../blat.dart'); 315 assertNotSuggested('../blat.dart');
320 } 316 }
321 317
322 test_part_file2() { 318 test_part_file2() async {
323 testFile = '/proj/completion.dart'; 319 testFile = '/proj/completion.dart';
324 addSource('/proj/other.dart', 'library other;'); 320 addSource('/proj/other.dart', 'library other;');
325 addSource('/proj/foo/bar.dart', 'library bar;'); 321 addSource('/proj/foo/bar.dart', 'library bar;');
326 addSource('/blat.dart', 'library blat;'); 322 addSource('/blat.dart', 'library blat;');
327 addTestSource('library x; part "..^" import'); 323 addTestSource('library x; part "..^" import');
328 computeFast(); 324 await computeSuggestions();
329 expect(request.replacementOffset, completionOffset - 2); 325 expect(replacementOffset, completionOffset - 2);
330 expect(request.replacementLength, 2); 326 expect(replacementLength, 2);
331 assertNotSuggested('completion.dart'); 327 assertNotSuggested('completion.dart');
332 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT); 328 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT);
333 assertNotSuggested('foo'); 329 assertNotSuggested('foo');
334 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT); 330 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT);
335 assertNotSuggested('foo/bar.dart'); 331 assertNotSuggested('foo/bar.dart');
336 assertNotSuggested('../blat.dart'); 332 assertNotSuggested('../blat.dart');
337 } 333 }
338 334
339 test_part_file_child() { 335 test_part_file_child() async {
340 testFile = '/proj/completion.dart'; 336 testFile = '/proj/completion.dart';
341 addSource('/proj/other.dart', 'library other;'); 337 addSource('/proj/other.dart', 'library other;');
342 addSource('/proj/foo/bar.dart', 'library bar;'); 338 addSource('/proj/foo/bar.dart', 'library bar;');
343 addSource('/blat.dart', 'library blat;'); 339 addSource('/blat.dart', 'library blat;');
344 addTestSource('library x; part "foo/^" import'); 340 addTestSource('library x; part "foo/^" import');
345 computeFast(); 341 await computeSuggestions();
346 expect(request.replacementOffset, completionOffset - 4); 342 expect(replacementOffset, completionOffset - 4);
347 expect(request.replacementLength, 4); 343 expect(replacementLength, 4);
348 assertNotSuggested('completion.dart'); 344 assertNotSuggested('completion.dart');
349 assertNotSuggested('other.dart'); 345 assertNotSuggested('other.dart');
350 assertNotSuggested('foo'); 346 assertNotSuggested('foo');
351 assertNotSuggested('foo/'); 347 assertNotSuggested('foo/');
352 assertSuggest('foo/bar.dart', csKind: CompletionSuggestionKind.IMPORT); 348 assertSuggest('foo/bar.dart', csKind: CompletionSuggestionKind.IMPORT);
353 assertNotSuggested('../blat.dart'); 349 assertNotSuggested('../blat.dart');
354 } 350 }
355 351
356 test_part_file_parent() { 352 test_part_file_parent() async {
357 testFile = '/proj/completion.dart'; 353 testFile = '/proj/completion.dart';
358 addSource('/proj/other.dart', 'library other;'); 354 addSource('/proj/other.dart', 'library other;');
359 addSource('/proj/foo/bar.dart', 'library bar;'); 355 addSource('/proj/foo/bar.dart', 'library bar;');
360 addSource('/blat.dart', 'library blat;'); 356 addSource('/blat.dart', 'library blat;');
361 addTestSource('library x; part "../^" import'); 357 addTestSource('library x; part "../^" import');
362 computeFast(); 358 await computeSuggestions();
363 expect(request.replacementOffset, completionOffset - 3); 359 expect(replacementOffset, completionOffset - 3);
364 expect(request.replacementLength, 3); 360 expect(replacementLength, 3);
365 assertNotSuggested('completion.dart'); 361 assertNotSuggested('completion.dart');
366 assertNotSuggested('other.dart'); 362 assertNotSuggested('other.dart');
367 assertNotSuggested('foo'); 363 assertNotSuggested('foo');
368 assertNotSuggested('foo/'); 364 assertNotSuggested('foo/');
369 assertNotSuggested('foo/bar.dart'); 365 assertNotSuggested('foo/bar.dart');
370 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); 366 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT);
371 } 367 }
372 } 368 }
373 369
374 @reflectiveTest 370 @reflectiveTest
375 class UriContributorWindowsTest extends AbstractCompletionTest { 371 class UriContributorWindowsTest extends DartCompletionContributorTest {
376 @override 372 @override
377 void setUpContributor() { 373 DartCompletionContributor createContributor() {
378 contributor = new UriContributor(); 374 return new UriContributor();
379 } 375 }
380 376
381 @override 377 @override
382 void setupResourceProvider() { 378 void setupResourceProvider() {
383 provider = new _TestWinResourceProvider(); 379 provider = new _TestWinResourceProvider();
384 } 380 }
385 381
386 test_import_file() { 382 test_import_file() async {
387 testFile = '\\proj\\completion.dart'; 383 testFile = '\\proj\\completion.dart';
388 addSource('\\proj\\other.dart', 'library other;'); 384 addSource('\\proj\\other.dart', 'library other;');
389 addSource('\\proj\\foo\\bar.dart', 'library bar;'); 385 addSource('\\proj\\foo\\bar.dart', 'library bar;');
390 addSource('\\blat.dart', 'library blat;'); 386 addSource('\\blat.dart', 'library blat;');
391 addTestSource('import "^" import'); 387 addTestSource('import "^" import');
392 computeFast(); 388 await computeSuggestions();
393 expect(request.replacementOffset, completionOffset); 389 expect(replacementOffset, completionOffset);
394 expect(request.replacementLength, 0); 390 expect(replacementLength, 0);
395 assertNotSuggested('completion.dart'); 391 assertNotSuggested('completion.dart');
396 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT); 392 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT);
397 assertNotSuggested('foo'); 393 assertNotSuggested('foo');
398 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT); 394 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT);
399 assertNotSuggested('foo/bar.dart'); 395 assertNotSuggested('foo/bar.dart');
400 assertNotSuggested('../blat.dart'); 396 assertNotSuggested('../blat.dart');
401 } 397 }
402 398
403 test_import_file2() { 399 test_import_file2() async {
404 testFile = '\\proj\\completion.dart'; 400 testFile = '\\proj\\completion.dart';
405 addSource('\\proj\\other.dart', 'library other;'); 401 addSource('\\proj\\other.dart', 'library other;');
406 addSource('\\proj\\foo\\bar.dart', 'library bar;'); 402 addSource('\\proj\\foo\\bar.dart', 'library bar;');
407 addSource('\\blat.dart', 'library blat;'); 403 addSource('\\blat.dart', 'library blat;');
408 addTestSource('import "..^" import'); 404 addTestSource('import "..^" import');
409 computeFast(); 405 await computeSuggestions();
410 expect(request.replacementOffset, completionOffset - 2); 406 expect(replacementOffset, completionOffset - 2);
411 expect(request.replacementLength, 2); 407 expect(replacementLength, 2);
412 assertNotSuggested('completion.dart'); 408 assertNotSuggested('completion.dart');
413 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT); 409 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT);
414 assertNotSuggested('foo'); 410 assertNotSuggested('foo');
415 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT); 411 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT);
416 assertNotSuggested('foo/bar.dart'); 412 assertNotSuggested('foo/bar.dart');
417 assertNotSuggested('../blat.dart'); 413 assertNotSuggested('../blat.dart');
418 } 414 }
419 415
420 test_import_file_child() { 416 test_import_file_child() async {
421 testFile = '\\proj\\completion.dart'; 417 testFile = '\\proj\\completion.dart';
422 addSource('\\proj\\other.dart', 'library other;'); 418 addSource('\\proj\\other.dart', 'library other;');
423 addSource('\\proj\\foo\\bar.dart', 'library bar;'); 419 addSource('\\proj\\foo\\bar.dart', 'library bar;');
424 addSource('\\blat.dart', 'library blat;'); 420 addSource('\\blat.dart', 'library blat;');
425 addTestSource('import "foo/^" import'); 421 addTestSource('import "foo/^" import');
426 computeFast(); 422 await computeSuggestions();
427 expect(request.replacementOffset, completionOffset - 4); 423 expect(replacementOffset, completionOffset - 4);
428 expect(request.replacementLength, 4); 424 expect(replacementLength, 4);
429 assertNotSuggested('completion.dart'); 425 assertNotSuggested('completion.dart');
430 assertNotSuggested('other.dart'); 426 assertNotSuggested('other.dart');
431 assertNotSuggested('foo'); 427 assertNotSuggested('foo');
432 assertNotSuggested('foo/'); 428 assertNotSuggested('foo/');
433 assertSuggest('foo/bar.dart', csKind: CompletionSuggestionKind.IMPORT); 429 assertSuggest('foo/bar.dart', csKind: CompletionSuggestionKind.IMPORT);
434 assertNotSuggested('../blat.dart'); 430 assertNotSuggested('../blat.dart');
435 } 431 }
436 432
437 test_import_file_parent() { 433 test_import_file_parent() async {
438 testFile = '\\proj\\completion.dart'; 434 testFile = '\\proj\\completion.dart';
439 addSource('\\proj\\other.dart', 'library other;'); 435 addSource('\\proj\\other.dart', 'library other;');
440 addSource('\\proj\\foo\\bar.dart', 'library bar;'); 436 addSource('\\proj\\foo\\bar.dart', 'library bar;');
441 addSource('\\blat.dart', 'library blat;'); 437 addSource('\\blat.dart', 'library blat;');
442 addTestSource('import "../^" import'); 438 addTestSource('import "../^" import');
443 computeFast(); 439 await computeSuggestions();
444 expect(request.replacementOffset, completionOffset - 3); 440 expect(replacementOffset, completionOffset - 3);
445 expect(request.replacementLength, 3); 441 expect(replacementLength, 3);
446 assertNotSuggested('completion.dart'); 442 assertNotSuggested('completion.dart');
447 assertNotSuggested('other.dart'); 443 assertNotSuggested('other.dart');
448 assertNotSuggested('foo'); 444 assertNotSuggested('foo');
449 assertNotSuggested('foo/'); 445 assertNotSuggested('foo/');
450 assertNotSuggested('foo/bar.dart'); 446 assertNotSuggested('foo/bar.dart');
451 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); 447 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT);
452 } 448 }
453 449
454 test_import_file_parent2() { 450 test_import_file_parent2() async {
455 testFile = '\\proj\\completion.dart'; 451 testFile = '\\proj\\completion.dart';
456 addSource('\\proj\\other.dart', 'library other;'); 452 addSource('\\proj\\other.dart', 'library other;');
457 addSource('\\proj\\foo\\bar.dart', 'library bar;'); 453 addSource('\\proj\\foo\\bar.dart', 'library bar;');
458 addSource('\\blat.dart', 'library blat;'); 454 addSource('\\blat.dart', 'library blat;');
459 addTestSource('import "../b^" import'); 455 addTestSource('import "../b^" import');
460 computeFast(); 456 await computeSuggestions();
461 expect(request.replacementOffset, completionOffset - 4); 457 expect(replacementOffset, completionOffset - 4);
462 expect(request.replacementLength, 4); 458 expect(replacementLength, 4);
463 assertNotSuggested('completion.dart'); 459 assertNotSuggested('completion.dart');
464 assertNotSuggested('other.dart'); 460 assertNotSuggested('other.dart');
465 assertNotSuggested('foo'); 461 assertNotSuggested('foo');
466 assertNotSuggested('foo/'); 462 assertNotSuggested('foo/');
467 assertNotSuggested('foo/bar.dart'); 463 assertNotSuggested('foo/bar.dart');
468 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); 464 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT);
469 } 465 }
470 466
471 test_part_file() { 467 test_part_file() async {
472 testFile = '\\proj\\completion.dart'; 468 testFile = '\\proj\\completion.dart';
473 addSource('\\proj\\other.dart', 'library other;'); 469 addSource('\\proj\\other.dart', 'library other;');
474 addSource('\\proj\\foo\\bar.dart', 'library bar;'); 470 addSource('\\proj\\foo\\bar.dart', 'library bar;');
475 addSource('\\blat.dart', 'library blat;'); 471 addSource('\\blat.dart', 'library blat;');
476 addTestSource('library x; part "^" import'); 472 addTestSource('library x; part "^" import');
477 computeFast(); 473 await computeSuggestions();
478 expect(request.replacementOffset, completionOffset); 474 expect(replacementOffset, completionOffset);
479 expect(request.replacementLength, 0); 475 expect(replacementLength, 0);
480 assertNotSuggested('completion.dart'); 476 assertNotSuggested('completion.dart');
481 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT); 477 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT);
482 assertNotSuggested('foo'); 478 assertNotSuggested('foo');
483 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT); 479 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT);
484 assertNotSuggested('foo/bar.dart'); 480 assertNotSuggested('foo/bar.dart');
485 assertNotSuggested('../blat.dart'); 481 assertNotSuggested('../blat.dart');
486 } 482 }
487 483
488 test_part_file2() { 484 test_part_file2() async {
489 testFile = '\\proj\\completion.dart'; 485 testFile = '\\proj\\completion.dart';
490 addSource('\\proj\\other.dart', 'library other;'); 486 addSource('\\proj\\other.dart', 'library other;');
491 addSource('\\proj\\foo\\bar.dart', 'library bar;'); 487 addSource('\\proj\\foo\\bar.dart', 'library bar;');
492 addSource('\\blat.dart', 'library blat;'); 488 addSource('\\blat.dart', 'library blat;');
493 addTestSource('library x; part "..^" import'); 489 addTestSource('library x; part "..^" import');
494 computeFast(); 490 await computeSuggestions();
495 expect(request.replacementOffset, completionOffset - 2); 491 expect(replacementOffset, completionOffset - 2);
496 expect(request.replacementLength, 2); 492 expect(replacementLength, 2);
497 assertNotSuggested('completion.dart'); 493 assertNotSuggested('completion.dart');
498 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT); 494 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT);
499 assertNotSuggested('foo'); 495 assertNotSuggested('foo');
500 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT); 496 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT);
501 assertNotSuggested('foo/bar.dart'); 497 assertNotSuggested('foo/bar.dart');
502 assertNotSuggested('../blat.dart'); 498 assertNotSuggested('../blat.dart');
503 } 499 }
504 500
505 test_part_file_child() { 501 test_part_file_child() async {
506 testFile = '\\proj\\completion.dart'; 502 testFile = '\\proj\\completion.dart';
507 addSource('\\proj\\other.dart', 'library other;'); 503 addSource('\\proj\\other.dart', 'library other;');
508 addSource('\\proj\\foo\\bar.dart', 'library bar;'); 504 addSource('\\proj\\foo\\bar.dart', 'library bar;');
509 addSource('\\blat.dart', 'library blat;'); 505 addSource('\\blat.dart', 'library blat;');
510 addTestSource('library x; part "foo/^" import'); 506 addTestSource('library x; part "foo/^" import');
511 computeFast(); 507 await computeSuggestions();
512 expect(request.replacementOffset, completionOffset - 4); 508 expect(replacementOffset, completionOffset - 4);
513 expect(request.replacementLength, 4); 509 expect(replacementLength, 4);
514 assertNotSuggested('completion.dart'); 510 assertNotSuggested('completion.dart');
515 assertNotSuggested('other.dart'); 511 assertNotSuggested('other.dart');
516 assertNotSuggested('foo'); 512 assertNotSuggested('foo');
517 assertNotSuggested('foo/'); 513 assertNotSuggested('foo/');
518 assertSuggest('foo/bar.dart', csKind: CompletionSuggestionKind.IMPORT); 514 assertSuggest('foo/bar.dart', csKind: CompletionSuggestionKind.IMPORT);
519 assertNotSuggested('../blat.dart'); 515 assertNotSuggested('../blat.dart');
520 } 516 }
521 517
522 test_part_file_parent() { 518 test_part_file_parent() async {
523 testFile = '\\proj\\completion.dart'; 519 testFile = '\\proj\\completion.dart';
524 addSource('\\proj\\other.dart', 'library other;'); 520 addSource('\\proj\\other.dart', 'library other;');
525 addSource('\\proj\\foo\\bar.dart', 'library bar;'); 521 addSource('\\proj\\foo\\bar.dart', 'library bar;');
526 addSource('\\blat.dart', 'library blat;'); 522 addSource('\\blat.dart', 'library blat;');
527 addTestSource('library x; part "../^" import'); 523 addTestSource('library x; part "../^" import');
528 computeFast(); 524 await computeSuggestions();
529 expect(request.replacementOffset, completionOffset - 3); 525 expect(replacementOffset, completionOffset - 3);
530 expect(request.replacementLength, 3); 526 expect(replacementLength, 3);
531 assertNotSuggested('completion.dart'); 527 assertNotSuggested('completion.dart');
532 assertNotSuggested('other.dart'); 528 assertNotSuggested('other.dart');
533 assertNotSuggested('foo'); 529 assertNotSuggested('foo');
534 assertNotSuggested('foo/'); 530 assertNotSuggested('foo/');
535 assertNotSuggested('foo/bar.dart'); 531 assertNotSuggested('foo/bar.dart');
536 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); 532 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT);
537 } 533 }
538 } 534 }
539 535
540 class _TestWinResourceProvider extends MemoryResourceProvider { 536 class _TestWinResourceProvider extends MemoryResourceProvider {
541 @override 537 @override
542 Context get pathContext => windows; 538 Context get pathContext => windows;
543 } 539 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698