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.context.directory.manager; | 5 library test.context.directory.manager; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
9 | 9 |
10 import 'package:analysis_server/src/context_manager.dart'; | 10 import 'package:analysis_server/src/context_manager.dart'; |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 438 |
439 void test_setRoots_addFolderWithNestedPackageSpec() { | 439 void test_setRoots_addFolderWithNestedPackageSpec() { |
440 String examplePath = newFolder([projPath, ContextManagerTest.EXAMPLE_NAME]); | 440 String examplePath = newFolder([projPath, ContextManagerTest.EXAMPLE_NAME]); |
441 String libPath = newFolder([projPath, ContextManagerTest.LIB_NAME]); | 441 String libPath = newFolder([projPath, ContextManagerTest.LIB_NAME]); |
442 | 442 |
443 newFile([projPath, ContextManagerImpl.PACKAGE_SPEC_NAME]); | 443 newFile([projPath, ContextManagerImpl.PACKAGE_SPEC_NAME]); |
444 newFile([libPath, 'main.dart']); | 444 newFile([libPath, 'main.dart']); |
445 newFile([examplePath, ContextManagerImpl.PACKAGE_SPEC_NAME]); | 445 newFile([examplePath, ContextManagerImpl.PACKAGE_SPEC_NAME]); |
446 newFile([examplePath, 'example.dart']); | 446 newFile([examplePath, 'example.dart']); |
447 | 447 |
448 packageMapProvider.packageMap['proj'] = [ | 448 packageMapProvider.packageMap['proj'] = <Folder>[ |
449 resourceProvider.getResource(libPath) | 449 resourceProvider.getResource(libPath) |
450 ]; | 450 ]; |
451 | 451 |
452 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 452 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
453 | 453 |
454 expect(callbacks.currentContextPaths, hasLength(2)); | 454 expect(callbacks.currentContextPaths, hasLength(2)); |
455 | 455 |
456 expect(callbacks.currentContextPaths, contains(projPath)); | 456 expect(callbacks.currentContextPaths, contains(projPath)); |
457 Set<Source> projSources = callbacks.currentContextSources[projPath]; | 457 Set<Source> projSources = callbacks.currentContextSources[projPath]; |
458 expect(projSources, hasLength(1)); | 458 expect(projSources, hasLength(1)); |
459 expect(projSources.first.uri.toString(), 'file:///my/proj/lib/main.dart'); | 459 expect(projSources.first.uri.toString(), 'file:///my/proj/lib/main.dart'); |
460 | 460 |
461 expect(callbacks.currentContextPaths, contains(examplePath)); | 461 expect(callbacks.currentContextPaths, contains(examplePath)); |
462 Set<Source> exampleSources = callbacks.currentContextSources[examplePath]; | 462 Set<Source> exampleSources = callbacks.currentContextSources[examplePath]; |
463 expect(exampleSources, hasLength(1)); | 463 expect(exampleSources, hasLength(1)); |
464 expect(exampleSources.first.uri.toString(), | 464 expect(exampleSources.first.uri.toString(), |
465 'file:///my/proj/example/example.dart'); | 465 'file:///my/proj/example/example.dart'); |
466 } | 466 } |
467 | 467 |
468 void test_setRoots_addFolderWithNestedPubspec() { | 468 void test_setRoots_addFolderWithNestedPubspec() { |
469 String examplePath = newFolder([projPath, ContextManagerTest.EXAMPLE_NAME]); | 469 String examplePath = newFolder([projPath, ContextManagerTest.EXAMPLE_NAME]); |
470 String libPath = newFolder([projPath, ContextManagerTest.LIB_NAME]); | 470 String libPath = newFolder([projPath, ContextManagerTest.LIB_NAME]); |
471 | 471 |
472 newFile([projPath, ContextManagerImpl.PUBSPEC_NAME]); | 472 newFile([projPath, ContextManagerImpl.PUBSPEC_NAME]); |
473 newFile([libPath, 'main.dart']); | 473 newFile([libPath, 'main.dart']); |
474 newFile([examplePath, ContextManagerImpl.PUBSPEC_NAME]); | 474 newFile([examplePath, ContextManagerImpl.PUBSPEC_NAME]); |
475 newFile([examplePath, 'example.dart']); | 475 newFile([examplePath, 'example.dart']); |
476 | 476 |
477 packageMapProvider.packageMap['proj'] = [ | 477 packageMapProvider.packageMap['proj'] = <Folder>[ |
478 resourceProvider.getResource(libPath) | 478 resourceProvider.getResource(libPath) |
479 ]; | 479 ]; |
480 | 480 |
481 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 481 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
482 | 482 |
483 expect(callbacks.currentContextPaths, hasLength(2)); | 483 expect(callbacks.currentContextPaths, hasLength(2)); |
484 | 484 |
485 expect(callbacks.currentContextPaths, contains(projPath)); | 485 expect(callbacks.currentContextPaths, contains(projPath)); |
486 Set<Source> projSources = callbacks.currentContextSources[projPath]; | 486 Set<Source> projSources = callbacks.currentContextSources[projPath]; |
487 expect(projSources, hasLength(1)); | 487 expect(projSources, hasLength(1)); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 String libPath = newFolder([projPath, ContextManagerTest.LIB_NAME]); | 566 String libPath = newFolder([projPath, ContextManagerTest.LIB_NAME]); |
567 String srcPath = newFolder([libPath, ContextManagerTest.SRC_NAME]); | 567 String srcPath = newFolder([libPath, ContextManagerTest.SRC_NAME]); |
568 String testPath = newFolder([projPath, ContextManagerTest.TEST_NAME]); | 568 String testPath = newFolder([projPath, ContextManagerTest.TEST_NAME]); |
569 | 569 |
570 newFile([projPath, ContextManagerImpl.PUBSPEC_NAME]); | 570 newFile([projPath, ContextManagerImpl.PUBSPEC_NAME]); |
571 String appPath = newFile([binPath, 'app.dart']); | 571 String appPath = newFile([binPath, 'app.dart']); |
572 newFile([libPath, 'main.dart']); | 572 newFile([libPath, 'main.dart']); |
573 newFile([srcPath, 'internal.dart']); | 573 newFile([srcPath, 'internal.dart']); |
574 String testFilePath = newFile([testPath, 'main_test.dart']); | 574 String testFilePath = newFile([testPath, 'main_test.dart']); |
575 | 575 |
576 packageMapProvider.packageMap['proj'] = [ | 576 packageMapProvider.packageMap['proj'] = <Folder>[ |
577 resourceProvider.getResource(libPath) | 577 resourceProvider.getResource(libPath) |
578 ]; | 578 ]; |
579 | 579 |
580 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 580 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
581 Set<Source> sources = callbacks.currentContextSources[projPath]; | 581 Set<Source> sources = callbacks.currentContextSources[projPath]; |
582 | 582 |
583 expect(callbacks.currentContextPaths, hasLength(1)); | 583 expect(callbacks.currentContextPaths, hasLength(1)); |
584 expect(callbacks.currentContextPaths, contains(projPath)); | 584 expect(callbacks.currentContextPaths, contains(projPath)); |
585 expect(sources, hasLength(4)); | 585 expect(sources, hasLength(4)); |
586 List<String> uris = | 586 List<String> uris = |
(...skipping 2179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2766 class TestUriResolver extends UriResolver { | 2766 class TestUriResolver extends UriResolver { |
2767 Map<Uri, Source> uriMap; | 2767 Map<Uri, Source> uriMap; |
2768 | 2768 |
2769 TestUriResolver(this.uriMap); | 2769 TestUriResolver(this.uriMap); |
2770 | 2770 |
2771 @override | 2771 @override |
2772 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 2772 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
2773 return uriMap[uri]; | 2773 return uriMap[uri]; |
2774 } | 2774 } |
2775 } | 2775 } |
OLD | NEW |