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

Side by Side Diff: pkg/analysis_server/test/context_manager_test.dart

Issue 2382053002: Remove unused option in server API (Closed)
Patch Set: Created 4 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.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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 437
438 void test_setRoots_addFolderWithNestedPackageSpec() { 438 void test_setRoots_addFolderWithNestedPackageSpec() {
439 String examplePath = newFolder([projPath, ContextManagerTest.EXAMPLE_NAME]); 439 String examplePath = newFolder([projPath, ContextManagerTest.EXAMPLE_NAME]);
440 String libPath = newFolder([projPath, ContextManagerTest.LIB_NAME]); 440 String libPath = newFolder([projPath, ContextManagerTest.LIB_NAME]);
441 441
442 newFile([projPath, ContextManagerImpl.PACKAGE_SPEC_NAME]); 442 newFile([projPath, ContextManagerImpl.PACKAGE_SPEC_NAME]);
443 newFile([libPath, 'main.dart']); 443 newFile([libPath, 'main.dart']);
444 newFile([examplePath, ContextManagerImpl.PACKAGE_SPEC_NAME]); 444 newFile([examplePath, ContextManagerImpl.PACKAGE_SPEC_NAME]);
445 newFile([examplePath, 'example.dart']); 445 newFile([examplePath, 'example.dart']);
446 446
447 packageMapProvider.packageMap['proj'] = <Folder>[
448 resourceProvider.getResource(libPath)
449 ];
450
451 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 447 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
452 448
453 expect(callbacks.currentContextPaths, hasLength(2)); 449 expect(callbacks.currentContextPaths, hasLength(2));
454 450
455 expect(callbacks.currentContextPaths, contains(projPath)); 451 expect(callbacks.currentContextPaths, contains(projPath));
456 Set<Source> projSources = callbacks.currentContextSources[projPath]; 452 Set<Source> projSources = callbacks.currentContextSources[projPath];
457 expect(projSources, hasLength(1)); 453 expect(projSources, hasLength(1));
458 expect(projSources.first.uri.toString(), 'file:///my/proj/lib/main.dart'); 454 expect(projSources.first.uri.toString(), 'file:///my/proj/lib/main.dart');
459 455
460 expect(callbacks.currentContextPaths, contains(examplePath)); 456 expect(callbacks.currentContextPaths, contains(examplePath));
(...skipping 23 matching lines...) Expand all
484 expect(projSources.first.uri.toString(), 'package:proj/main.dart'); 480 expect(projSources.first.uri.toString(), 'package:proj/main.dart');
485 481
486 expect(callbacks.currentContextPaths, contains(examplePath)); 482 expect(callbacks.currentContextPaths, contains(examplePath));
487 Set<Source> exampleSources = callbacks.currentContextSources[examplePath]; 483 Set<Source> exampleSources = callbacks.currentContextSources[examplePath];
488 expect(exampleSources, hasLength(1)); 484 expect(exampleSources, hasLength(1));
489 expect(exampleSources.first.uri.toString(), 485 expect(exampleSources.first.uri.toString(),
490 'file:///my/proj/example/example.dart'); 486 'file:///my/proj/example/example.dart');
491 } 487 }
492 488
493 void test_setRoots_addFolderWithoutPubspec() { 489 void test_setRoots_addFolderWithoutPubspec() {
494 packageMapProvider.packageMap = null;
495 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 490 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
496 // verify 491 // verify
497 expect(callbacks.currentContextPaths, hasLength(1)); 492 expect(callbacks.currentContextPaths, hasLength(1));
498 expect(callbacks.currentContextPaths, contains(projPath)); 493 expect(callbacks.currentContextPaths, contains(projPath));
499 expect(callbacks.currentContextFilePaths[projPath], hasLength(0)); 494 expect(callbacks.currentContextFilePaths[projPath], hasLength(0));
500 } 495 }
501 496
502 void test_setRoots_addFolderWithPackagespec() { 497 void test_setRoots_addFolderWithPackagespec() {
503 String packagespecPath = posix.join(projPath, '.packages'); 498 String packagespecPath = posix.join(projPath, '.packages');
504 resourceProvider.newFile(packagespecPath, 499 resourceProvider.newFile(packagespecPath,
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 String fileA = '$project/foo.dart'; 970 String fileA = '$project/foo.dart';
976 String fileB = '$project/.pub/bar.dart'; 971 String fileB = '$project/.pub/bar.dart';
977 resourceProvider.newFile(fileA, ''); 972 resourceProvider.newFile(fileA, '');
978 resourceProvider.newFile(fileB, ''); 973 resourceProvider.newFile(fileB, '');
979 manager.setRoots(<String>[project], <String>[], <String, String>{}); 974 manager.setRoots(<String>[project], <String>[], <String, String>{});
980 callbacks.assertContextPaths([project]); 975 callbacks.assertContextPaths([project]);
981 callbacks.assertContextFiles(project, [fileA]); 976 callbacks.assertContextFiles(project, [fileA]);
982 } 977 }
983 978
984 void test_setRoots_removeFolderWithoutPubspec() { 979 void test_setRoots_removeFolderWithoutPubspec() {
985 packageMapProvider.packageMap = null;
986 // add one root - there is a context 980 // add one root - there is a context
987 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 981 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
988 expect(callbacks.currentContextPaths, hasLength(1)); 982 expect(callbacks.currentContextPaths, hasLength(1));
989 // set empty roots - no contexts 983 // set empty roots - no contexts
990 manager.setRoots(<String>[], <String>[], <String, String>{}); 984 manager.setRoots(<String>[], <String>[], <String, String>{});
991 expect(callbacks.currentContextPaths, hasLength(0)); 985 expect(callbacks.currentContextPaths, hasLength(0));
992 expect(callbacks.currentContextFilePaths, hasLength(0)); 986 expect(callbacks.currentContextFilePaths, hasLength(0));
993 } 987 }
994 988
995 void test_setRoots_removeFolderWithPackagespec() { 989 void test_setRoots_removeFolderWithPackagespec() {
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 resourceProvider.modifyFile(filePath, 'new contents'); 1606 resourceProvider.modifyFile(filePath, 'new contents');
1613 return pumpEventQueue().then((_) { 1607 return pumpEventQueue().then((_) {
1614 return expect(filePaths[filePath], equals(callbacks.now)); 1608 return expect(filePaths[filePath], equals(callbacks.now));
1615 }); 1609 });
1616 } 1610 }
1617 1611
1618 test_watch_modifyPackageMapDependency_fail() async { 1612 test_watch_modifyPackageMapDependency_fail() async {
1619 // create a dependency file 1613 // create a dependency file
1620 String dependencyPath = posix.join(projPath, 'dep'); 1614 String dependencyPath = posix.join(projPath, 'dep');
1621 resourceProvider.newFile(dependencyPath, 'contents'); 1615 resourceProvider.newFile(dependencyPath, 'contents');
1622 packageMapProvider.dependencies.add(dependencyPath);
1623 // create a Dart file 1616 // create a Dart file
1624 String dartFilePath = posix.join(projPath, 'main.dart'); 1617 String dartFilePath = posix.join(projPath, 'main.dart');
1625 resourceProvider.newFile(dartFilePath, 'contents'); 1618 resourceProvider.newFile(dartFilePath, 'contents');
1626 // the created context has the expected empty package map 1619 // the created context has the expected empty package map
1627 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 1620 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
1628 expect(_currentPackageMap, isEmpty); 1621 expect(_currentPackageMap, isEmpty);
1629 // Change the package map dependency so that the packageMapProvider is 1622 // Change the package map dependency so that the packageMapProvider is
1630 // re-run, and arrange for it to return null from computePackageMap(). 1623 // re-run, and arrange for it to return null from computePackageMap().
1631 packageMapProvider.packageMap = null;
1632 resourceProvider.modifyFile(dependencyPath, 'new contents'); 1624 resourceProvider.modifyFile(dependencyPath, 'new contents');
1633 await pumpEventQueue(); 1625 await pumpEventQueue();
1634 // The package map should have been changed to null. 1626 // The package map should have been changed to null.
1635 expect(_currentPackageMap, isEmpty); 1627 expect(_currentPackageMap, isEmpty);
1636 } 1628 }
1637 1629
1638 test_watch_modifyPackagespec() { 1630 test_watch_modifyPackagespec() {
1639 String packagesPath = '$projPath/.packages'; 1631 String packagesPath = '$projPath/.packages';
1640 String filePath = '$projPath/bin/main.dart'; 1632 String filePath = '$projPath/bin/main.dart';
1641 1633
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 * The name of the 'test' directory. 1695 * The name of the 'test' directory.
1704 */ 1696 */
1705 static const String TEST_NAME = 'test'; 1697 static const String TEST_NAME = 'test';
1706 1698
1707 ContextManagerImpl manager; 1699 ContextManagerImpl manager;
1708 1700
1709 TestContextManagerCallbacks callbacks; 1701 TestContextManagerCallbacks callbacks;
1710 1702
1711 MemoryResourceProvider resourceProvider; 1703 MemoryResourceProvider resourceProvider;
1712 1704
1713 MockPackageMapProvider packageMapProvider;
1714
1715 UriResolver packageResolver = null; 1705 UriResolver packageResolver = null;
1716 1706
1717 String projPath = '/my/proj'; 1707 String projPath = '/my/proj';
1718 1708
1719 AnalysisError missing_required_param = new AnalysisError( 1709 AnalysisError missing_required_param = new AnalysisError(
1720 new TestSource(), 0, 1, HintCode.MISSING_REQUIRED_PARAM, [ 1710 new TestSource(), 0, 1, HintCode.MISSING_REQUIRED_PARAM, [
1721 ['x'] 1711 ['x']
1722 ]); 1712 ]);
1723 1713
1724 AnalysisError missing_return = 1714 AnalysisError missing_return =
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 plugins.add(linterPlugin); 1777 plugins.add(linterPlugin);
1788 ExtensionManager manager = new ExtensionManager(); 1778 ExtensionManager manager = new ExtensionManager();
1789 manager.processPlugins(plugins); 1779 manager.processPlugins(plugins);
1790 } 1780 }
1791 1781
1792 UriResolver providePackageResolver(Folder folder) => packageResolver; 1782 UriResolver providePackageResolver(Folder folder) => packageResolver;
1793 1783
1794 void setUp() { 1784 void setUp() {
1795 processRequiredPlugins(); 1785 processRequiredPlugins();
1796 resourceProvider = new MemoryResourceProvider(); 1786 resourceProvider = new MemoryResourceProvider();
1797 packageMapProvider = new MockPackageMapProvider();
1798 DartSdk sdk = new MockSdk(resourceProvider: resourceProvider); 1787 DartSdk sdk = new MockSdk(resourceProvider: resourceProvider);
1799 DartSdkManager sdkManager = new DartSdkManager('/', false, (_) => sdk); 1788 DartSdkManager sdkManager = new DartSdkManager('/', false, (_) => sdk);
1800 manager = new ContextManagerImpl( 1789 manager = new ContextManagerImpl(
1801 resourceProvider, 1790 resourceProvider,
1802 sdkManager, 1791 sdkManager,
1803 providePackageResolver, 1792 providePackageResolver,
1804 packageMapProvider,
1805 analysisFilesGlobs, 1793 analysisFilesGlobs,
1806 InstrumentationService.NULL_SERVICE, 1794 InstrumentationService.NULL_SERVICE,
1807 new AnalysisOptionsImpl()); 1795 new AnalysisOptionsImpl());
1808 callbacks = new TestContextManagerCallbacks(resourceProvider); 1796 callbacks = new TestContextManagerCallbacks(resourceProvider);
1809 manager.callbacks = callbacks; 1797 manager.callbacks = callbacks;
1810 resourceProvider.newFolder(projPath); 1798 resourceProvider.newFolder(projPath);
1811 } 1799 }
1812 1800
1813 /** 1801 /**
1814 * Verify that package URI's for source files in [path] will be resolved 1802 * Verify that package URI's for source files in [path] will be resolved
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
2702 void assertContextFiles(String contextPath, List<String> expectedFiles) { 2690 void assertContextFiles(String contextPath, List<String> expectedFiles) {
2703 var actualFiles = currentContextFilePaths[contextPath].keys; 2691 var actualFiles = currentContextFilePaths[contextPath].keys;
2704 expect(actualFiles, unorderedEquals(expectedFiles)); 2692 expect(actualFiles, unorderedEquals(expectedFiles));
2705 } 2693 }
2706 2694
2707 void assertContextPaths(List<String> expected) { 2695 void assertContextPaths(List<String> expected) {
2708 expect(currentContextPaths, unorderedEquals(expected)); 2696 expect(currentContextPaths, unorderedEquals(expected));
2709 } 2697 }
2710 2698
2711 @override 2699 @override
2712 void computingPackageMap(bool computing) {
2713 // Do nothing.
2714 }
2715
2716 @override
2717 ContextBuilder createContextBuilder(Folder folder, AnalysisOptions options) { 2700 ContextBuilder createContextBuilder(Folder folder, AnalysisOptions options) {
2718 DartSdkManager sdkManager = new DartSdkManager('/', false, null); 2701 DartSdkManager sdkManager = new DartSdkManager('/', false, null);
2719 ContextBuilder builder = 2702 ContextBuilder builder =
2720 new ContextBuilder(resourceProvider, sdkManager, new ContentCache()); 2703 new ContextBuilder(resourceProvider, sdkManager, new ContentCache());
2721 builder.defaultOptions = options; 2704 builder.defaultOptions = options;
2722 return builder; 2705 return builder;
2723 } 2706 }
2724 2707
2725 @override 2708 @override
2726 void moveContext(Folder from, Folder to) { 2709 void moveContext(Folder from, Folder to) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2766 class TestUriResolver extends UriResolver { 2749 class TestUriResolver extends UriResolver {
2767 Map<Uri, Source> uriMap; 2750 Map<Uri, Source> uriMap;
2768 2751
2769 TestUriResolver(this.uriMap); 2752 TestUriResolver(this.uriMap);
2770 2753
2771 @override 2754 @override
2772 Source resolveAbsolute(Uri uri, [Uri actualUri]) { 2755 Source resolveAbsolute(Uri uri, [Uri actualUri]) {
2773 return uriMap[uri]; 2756 return uriMap[uri];
2774 } 2757 }
2775 } 2758 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/analysis_server_test.dart ('k') | pkg/analysis_server/test/domain_analysis_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698