| 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.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/src/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/import_uri_contributor.d
art'; | 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(ImportUriContributorTest); | 20 defineReflectiveTests(UriContributorTest); |
| 21 defineReflectiveTests(ImportUriContributorWindowsTest); | 21 defineReflectiveTests(UriContributorWindowsTest); |
| 22 } | 22 } |
| 23 | 23 |
| 24 @reflectiveTest | 24 @reflectiveTest |
| 25 class ImportUriContributorTest extends AbstractCompletionTest { | 25 class UriContributorTest extends AbstractCompletionTest { |
| 26 @override | 26 @override |
| 27 void setUpContributor() { | 27 void setUpContributor() { |
| 28 contributor = new ImportUriContributor(); | 28 contributor = new UriContributor(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 test_import() { | 31 test_import() { |
| 32 addTestSource('import "^"'); | 32 addTestSource('import "^"'); |
| 33 computeFast(); | 33 computeFast(); |
| 34 expect(request.replacementOffset, completionOffset); | 34 expect(request.replacementOffset, completionOffset); |
| 35 expect(request.replacementLength, 0); | 35 expect(request.replacementLength, 0); |
| 36 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT); | 36 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT); |
| 37 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); | 37 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); |
| 38 } | 38 } |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 assertNotSuggested('completion.dart'); | 277 assertNotSuggested('completion.dart'); |
| 278 assertNotSuggested('other.dart'); | 278 assertNotSuggested('other.dart'); |
| 279 assertNotSuggested('foo'); | 279 assertNotSuggested('foo'); |
| 280 assertNotSuggested('foo/'); | 280 assertNotSuggested('foo/'); |
| 281 assertNotSuggested('foo/bar.dart'); | 281 assertNotSuggested('foo/bar.dart'); |
| 282 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); | 282 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); |
| 283 } | 283 } |
| 284 } | 284 } |
| 285 | 285 |
| 286 @reflectiveTest | 286 @reflectiveTest |
| 287 class ImportUriContributorWindowsTest extends AbstractCompletionTest { | 287 class UriContributorWindowsTest extends AbstractCompletionTest { |
| 288 @override | 288 @override |
| 289 void setUpContributor() { | 289 void setUpContributor() { |
| 290 contributor = new ImportUriContributor(); | 290 contributor = new UriContributor(); |
| 291 } | 291 } |
| 292 | 292 |
| 293 @override | 293 @override |
| 294 void setupResourceProvider() { | 294 void setupResourceProvider() { |
| 295 provider = new _TestWinResourceProvider(); | 295 provider = new _TestWinResourceProvider(); |
| 296 } | 296 } |
| 297 | 297 |
| 298 test_import_file() { | 298 test_import_file() { |
| 299 testFile = '\\proj\\completion.dart'; | 299 testFile = '\\proj\\completion.dart'; |
| 300 addSource('\\proj\\other.dart', 'library other;'); | 300 addSource('\\proj\\other.dart', 'library other;'); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 assertNotSuggested('foo/'); | 446 assertNotSuggested('foo/'); |
| 447 assertNotSuggested('foo/bar.dart'); | 447 assertNotSuggested('foo/bar.dart'); |
| 448 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); | 448 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); |
| 449 } | 449 } |
| 450 } | 450 } |
| 451 | 451 |
| 452 class _TestWinResourceProvider extends MemoryResourceProvider { | 452 class _TestWinResourceProvider extends MemoryResourceProvider { |
| 453 @override | 453 @override |
| 454 Context get pathContext => windows; | 454 Context get pathContext => windows; |
| 455 } | 455 } |
| OLD | NEW |