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

Unified Diff: pkg/analysis_server/test/services/completion/import_uri_contributor_test.dart

Issue 1325583002: improve import uri completions - fixes #24000 (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge and fix test source path Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/test/abstract_context.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/services/completion/import_uri_contributor_test.dart
diff --git a/pkg/analysis_server/test/services/completion/import_uri_contributor_test.dart b/pkg/analysis_server/test/services/completion/import_uri_contributor_test.dart
index 176428f2cd4b072b38883ad83bd90bbb306d3bd7..527410e84b92cc44eab9b864e355f6cb3f98e4c0 100644
--- a/pkg/analysis_server/test/services/completion/import_uri_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/import_uri_contributor_test.dart
@@ -4,21 +4,21 @@
library test.services.completion.contributor.dart.importuri;
-import 'dart:io';
-
import 'package:analysis_server/src/protocol.dart';
+import 'package:analysis_server/src/services/completion/dart_completion_manager.dart';
import 'package:analysis_server/src/services/completion/import_uri_contributor.dart';
+import 'package:analyzer/file_system/memory_file_system.dart';
import 'package:path/path.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'package:unittest/unittest.dart';
import '../../utils.dart';
import 'completion_test_util.dart';
-import 'package:analysis_server/src/services/completion/dart_completion_manager.dart';
main() {
initializeTestEnvironment();
defineReflectiveTests(ImportUriContributorTest);
+ defineReflectiveTests(ImportUriContributorWindowsTest);
}
@reflectiveTest
@@ -73,8 +73,6 @@ class ImportUriContributorTest extends AbstractCompletionTest {
}
test_import_file() {
- // TODO(danrubel) fix file uri suggestions on Windows
- if (Platform.isWindows) return;
testFile = '/proj/completion.dart';
addSource('/proj/other.dart', 'library other;');
addSource('/proj/foo/bar.dart', 'library bar;');
@@ -92,8 +90,6 @@ class ImportUriContributorTest extends AbstractCompletionTest {
}
test_import_file2() {
- // TODO(danrubel) fix file uri suggestions on Windows
- if (Platform.isWindows) return;
testFile = '/proj/completion.dart';
addSource('/proj/other.dart', 'library other;');
addSource('/proj/foo/bar.dart', 'library bar;');
@@ -111,8 +107,6 @@ class ImportUriContributorTest extends AbstractCompletionTest {
}
test_import_file_child() {
- // TODO(danrubel) fix file uri suggestions on Windows
- if (Platform.isWindows) return;
testFile = '/proj/completion.dart';
addSource('/proj/other.dart', 'library other;');
addSource('/proj/foo/bar.dart', 'library bar;');
@@ -130,8 +124,6 @@ class ImportUriContributorTest extends AbstractCompletionTest {
}
test_import_file_parent() {
- // TODO(danrubel) fix file uri suggestions on Windows
- if (Platform.isWindows) return;
testFile = '/proj/completion.dart';
addSource('/proj/other.dart', 'library other;');
addSource('/proj/foo/bar.dart', 'library bar;');
@@ -148,6 +140,23 @@ class ImportUriContributorTest extends AbstractCompletionTest {
assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT);
}
+ test_import_file_parent2() {
+ testFile = '/proj/completion.dart';
+ addSource('/proj/other.dart', 'library other;');
+ addSource('/proj/foo/bar.dart', 'library bar;');
+ addSource('/blat.dart', 'library blat;');
+ addTestSource('import "../b^" import');
+ computeFast();
+ expect(request.replacementOffset, completionOffset - 4);
+ expect(request.replacementLength, 4);
+ assertNotSuggested('completion.dart');
+ assertNotSuggested('other.dart');
+ assertNotSuggested('foo');
+ assertNotSuggested('foo/');
+ assertNotSuggested('foo/bar.dart');
+ assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT);
+ }
+
test_import_package() {
addPackageSource('foo', 'foo.dart', 'library foo;');
addPackageSource('foo', 'baz/too.dart', 'library too;');
@@ -206,8 +215,6 @@ class ImportUriContributorTest extends AbstractCompletionTest {
}
test_part_file() {
- // TODO(danrubel) fix file uri suggestions on Windows
- if (Platform.isWindows) return;
testFile = '/proj/completion.dart';
addSource('/proj/other.dart', 'library other;');
addSource('/proj/foo/bar.dart', 'library bar;');
@@ -225,8 +232,6 @@ class ImportUriContributorTest extends AbstractCompletionTest {
}
test_part_file2() {
- // TODO(danrubel) fix file uri suggestions on Windows
- if (Platform.isWindows) return;
testFile = '/proj/completion.dart';
addSource('/proj/other.dart', 'library other;');
addSource('/proj/foo/bar.dart', 'library bar;');
@@ -244,8 +249,6 @@ class ImportUriContributorTest extends AbstractCompletionTest {
}
test_part_file_child() {
- // TODO(danrubel) fix file uri suggestions on Windows
- if (Platform.isWindows) return;
testFile = '/proj/completion.dart';
addSource('/proj/other.dart', 'library other;');
addSource('/proj/foo/bar.dart', 'library bar;');
@@ -263,8 +266,6 @@ class ImportUriContributorTest extends AbstractCompletionTest {
}
test_part_file_parent() {
- // TODO(danrubel) fix file uri suggestions on Windows
- if (Platform.isWindows) return;
testFile = '/proj/completion.dart';
addSource('/proj/other.dart', 'library other;');
addSource('/proj/foo/bar.dart', 'library bar;');
@@ -281,3 +282,174 @@ class ImportUriContributorTest extends AbstractCompletionTest {
assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT);
}
}
+
+@reflectiveTest
+class ImportUriContributorWindowsTest extends AbstractCompletionTest {
+ @override
+ void setUpContributor() {
+ contributor = new ImportUriContributor();
+ }
+
+ @override
+ void setupResourceProvider() {
+ provider = new _TestWinResourceProvider();
+ }
+
+ test_import_file() {
+ testFile = '\\proj\\completion.dart';
+ addSource('\\proj\\other.dart', 'library other;');
+ addSource('\\proj\\foo\\bar.dart', 'library bar;');
+ addSource('\\blat.dart', 'library blat;');
+ addTestSource('import "^" import');
+ computeFast();
+ expect(request.replacementOffset, completionOffset);
+ expect(request.replacementLength, 0);
+ assertNotSuggested('completion.dart');
+ assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT);
+ assertNotSuggested('foo');
+ assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT);
+ assertNotSuggested('foo/bar.dart');
+ assertNotSuggested('../blat.dart');
+ }
+
+ test_import_file2() {
+ testFile = '\\proj\\completion.dart';
+ addSource('\\proj\\other.dart', 'library other;');
+ addSource('\\proj\\foo\\bar.dart', 'library bar;');
+ addSource('\\blat.dart', 'library blat;');
+ addTestSource('import "..^" import');
+ computeFast();
+ expect(request.replacementOffset, completionOffset - 2);
+ expect(request.replacementLength, 2);
+ assertNotSuggested('completion.dart');
+ assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT);
+ assertNotSuggested('foo');
+ assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT);
+ assertNotSuggested('foo/bar.dart');
+ assertNotSuggested('../blat.dart');
+ }
+
+ test_import_file_child() {
+ testFile = '\\proj\\completion.dart';
+ addSource('\\proj\\other.dart', 'library other;');
+ addSource('\\proj\\foo\\bar.dart', 'library bar;');
+ addSource('\\blat.dart', 'library blat;');
+ addTestSource('import "foo/^" import');
+ computeFast();
+ expect(request.replacementOffset, completionOffset - 4);
+ expect(request.replacementLength, 4);
+ assertNotSuggested('completion.dart');
+ assertNotSuggested('other.dart');
+ assertNotSuggested('foo');
+ assertNotSuggested('foo/');
+ assertSuggest('foo/bar.dart', csKind: CompletionSuggestionKind.IMPORT);
+ assertNotSuggested('../blat.dart');
+ }
+
+ test_import_file_parent() {
+ testFile = '\\proj\\completion.dart';
+ addSource('\\proj\\other.dart', 'library other;');
+ addSource('\\proj\\foo\\bar.dart', 'library bar;');
+ addSource('\\blat.dart', 'library blat;');
+ addTestSource('import "../^" import');
+ computeFast();
+ expect(request.replacementOffset, completionOffset - 3);
+ expect(request.replacementLength, 3);
+ assertNotSuggested('completion.dart');
+ assertNotSuggested('other.dart');
+ assertNotSuggested('foo');
+ assertNotSuggested('foo/');
+ assertNotSuggested('foo/bar.dart');
+ assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT);
+ }
+
+ test_import_file_parent2() {
+ testFile = '\\proj\\completion.dart';
+ addSource('\\proj\\other.dart', 'library other;');
+ addSource('\\proj\\foo\\bar.dart', 'library bar;');
+ addSource('\\blat.dart', 'library blat;');
+ addTestSource('import "../b^" import');
+ computeFast();
+ expect(request.replacementOffset, completionOffset - 4);
+ expect(request.replacementLength, 4);
+ assertNotSuggested('completion.dart');
+ assertNotSuggested('other.dart');
+ assertNotSuggested('foo');
+ assertNotSuggested('foo/');
+ assertNotSuggested('foo/bar.dart');
+ assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT);
+ }
+
+ test_part_file() {
+ testFile = '\\proj\\completion.dart';
+ addSource('\\proj\\other.dart', 'library other;');
+ addSource('\\proj\\foo\\bar.dart', 'library bar;');
+ addSource('\\blat.dart', 'library blat;');
+ addTestSource('library x; part "^" import');
+ computeFast();
+ expect(request.replacementOffset, completionOffset);
+ expect(request.replacementLength, 0);
+ assertNotSuggested('completion.dart');
+ assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT);
+ assertNotSuggested('foo');
+ assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT);
+ assertNotSuggested('foo/bar.dart');
+ assertNotSuggested('../blat.dart');
+ }
+
+ test_part_file2() {
+ testFile = '\\proj\\completion.dart';
+ addSource('\\proj\\other.dart', 'library other;');
+ addSource('\\proj\\foo\\bar.dart', 'library bar;');
+ addSource('\\blat.dart', 'library blat;');
+ addTestSource('library x; part "..^" import');
+ computeFast();
+ expect(request.replacementOffset, completionOffset - 2);
+ expect(request.replacementLength, 2);
+ assertNotSuggested('completion.dart');
+ assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT);
+ assertNotSuggested('foo');
+ assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT);
+ assertNotSuggested('foo/bar.dart');
+ assertNotSuggested('../blat.dart');
+ }
+
+ test_part_file_child() {
+ testFile = '\\proj\\completion.dart';
+ addSource('\\proj\\other.dart', 'library other;');
+ addSource('\\proj\\foo\\bar.dart', 'library bar;');
+ addSource('\\blat.dart', 'library blat;');
+ addTestSource('library x; part "foo/^" import');
+ computeFast();
+ expect(request.replacementOffset, completionOffset - 4);
+ expect(request.replacementLength, 4);
+ assertNotSuggested('completion.dart');
+ assertNotSuggested('other.dart');
+ assertNotSuggested('foo');
+ assertNotSuggested('foo/');
+ assertSuggest('foo/bar.dart', csKind: CompletionSuggestionKind.IMPORT);
+ assertNotSuggested('../blat.dart');
+ }
+
+ test_part_file_parent() {
+ testFile = '\\proj\\completion.dart';
+ addSource('\\proj\\other.dart', 'library other;');
+ addSource('\\proj\\foo\\bar.dart', 'library bar;');
+ addSource('\\blat.dart', 'library blat;');
+ addTestSource('library x; part "../^" import');
+ computeFast();
+ expect(request.replacementOffset, completionOffset - 3);
+ expect(request.replacementLength, 3);
+ assertNotSuggested('completion.dart');
+ assertNotSuggested('other.dart');
+ assertNotSuggested('foo');
+ assertNotSuggested('foo/');
+ assertNotSuggested('foo/bar.dart');
+ assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT);
+ }
+}
+
+class _TestWinResourceProvider extends MemoryResourceProvider {
+ @override
+ Context get pathContext => windows;
+}
« no previous file with comments | « pkg/analysis_server/test/abstract_context.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698