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

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

Issue 1398293002: Move the wire protocol support into the public API (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add missed files Created 5 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
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/src/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/services/completion/dart_completion_manager. dart';
9 import 'package:analysis_server/src/services/completion/uri_contributor.dart'; 9 import 'package:analysis_server/src/services/completion/uri_contributor.dart';
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_test_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 AbstractCompletionTest {
26 @override 26 @override
27 void setUpContributor() { 27 void setUpContributor() {
28 contributor = new UriContributor(); 28 contributor = new UriContributor();
29 } 29 }
30 30
31 test_export_package2() {
32 addPackageSource('foo', 'foo.dart', 'library foo;');
33 addPackageSource('foo', 'baz/too.dart', 'library too;');
34 addPackageSource('bar', 'bar.dart', 'library bar;');
35 addTestSource('export "package:foo/baz/^" import');
36 computeFast();
37 assertSuggest('package:foo/baz/too.dart',
38 csKind: CompletionSuggestionKind.IMPORT);
39 }
40
31 test_import() { 41 test_import() {
32 addTestSource('import "^"'); 42 addTestSource('import "^"');
33 computeFast(); 43 computeFast();
34 expect(request.replacementOffset, completionOffset); 44 expect(request.replacementOffset, completionOffset);
35 expect(request.replacementLength, 0); 45 expect(request.replacementLength, 0);
36 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT); 46 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT);
37 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); 47 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT);
38 } 48 }
39 49
40 test_import2() { 50 test_import2() {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 test_import_package2() { 189 test_import_package2() {
180 addPackageSource('foo', 'foo.dart', 'library foo;'); 190 addPackageSource('foo', 'foo.dart', 'library foo;');
181 addPackageSource('foo', 'baz/too.dart', 'library too;'); 191 addPackageSource('foo', 'baz/too.dart', 'library too;');
182 addPackageSource('bar', 'bar.dart', 'library bar;'); 192 addPackageSource('bar', 'bar.dart', 'library bar;');
183 addTestSource('import "package:foo/baz/^" import'); 193 addTestSource('import "package:foo/baz/^" import');
184 computeFast(); 194 computeFast();
185 assertSuggest('package:foo/baz/too.dart', 195 assertSuggest('package:foo/baz/too.dart',
186 csKind: CompletionSuggestionKind.IMPORT); 196 csKind: CompletionSuggestionKind.IMPORT);
187 } 197 }
188 198
189 test_export_package2() {
190 addPackageSource('foo', 'foo.dart', 'library foo;');
191 addPackageSource('foo', 'baz/too.dart', 'library too;');
192 addPackageSource('bar', 'bar.dart', 'library bar;');
193 addTestSource('export "package:foo/baz/^" import');
194 computeFast();
195 assertSuggest('package:foo/baz/too.dart',
196 csKind: CompletionSuggestionKind.IMPORT);
197 }
198
199 test_import_package_missing_lib() { 199 test_import_package_missing_lib() {
200 var pkgSrc = addPackageSource('bar', 'bar.dart', 'library bar;'); 200 var pkgSrc = addPackageSource('bar', 'bar.dart', 'library bar;');
201 provider.deleteFolder(dirname(pkgSrc.fullName)); 201 provider.deleteFolder(dirname(pkgSrc.fullName));
202 addTestSource('import "p^" class'); 202 addTestSource('import "p^" class');
203 computeFast(); 203 computeFast();
204 expect(request.replacementOffset, completionOffset - 1); 204 expect(request.replacementOffset, completionOffset - 1);
205 expect(request.replacementLength, 1); 205 expect(request.replacementLength, 1);
206 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); 206 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT);
207 assertSuggest('package:bar/', csKind: CompletionSuggestionKind.IMPORT); 207 assertSuggest('package:bar/', csKind: CompletionSuggestionKind.IMPORT);
208 assertNotSuggested('package:bar/bar.dart'); 208 assertNotSuggested('package:bar/bar.dart');
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 assertNotSuggested('foo/'); 456 assertNotSuggested('foo/');
457 assertNotSuggested('foo/bar.dart'); 457 assertNotSuggested('foo/bar.dart');
458 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); 458 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT);
459 } 459 }
460 } 460 }
461 461
462 class _TestWinResourceProvider extends MemoryResourceProvider { 462 class _TestWinResourceProvider extends MemoryResourceProvider {
463 @override 463 @override
464 Context get pathContext => windows; 464 Context get pathContext => windows;
465 } 465 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698