| Index: pkg/analysis_server/test/context_manager_test.dart
|
| diff --git a/pkg/analysis_server/test/context_manager_test.dart b/pkg/analysis_server/test/context_manager_test.dart
|
| index 0eecd2875cd2e4a31af15328029fb25f9d159ac1..db83aee5a5f8414f72062de3fa54eb0aa441f267 100644
|
| --- a/pkg/analysis_server/test/context_manager_test.dart
|
| +++ b/pkg/analysis_server/test/context_manager_test.dart
|
| @@ -189,6 +189,15 @@ class ContextManagerTest {
|
| expect(filePaths, isEmpty);
|
| }
|
|
|
| + void test_setRoots_addFolderWithoutPubspec() {
|
| + packageMapProvider.packageMap = null;
|
| + manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| + // verify
|
| + expect(manager.currentContextPaths, hasLength(1));
|
| + expect(manager.currentContextPaths, contains(projPath));
|
| + expect(manager.currentContextFilePaths[projPath], hasLength(0));
|
| + }
|
| +
|
| void test_setRoots_addFolderWithPubspec() {
|
| String pubspecPath = posix.join(projPath, 'pubspec.yaml');
|
| resourceProvider.newFile(pubspecPath, 'pubspec');
|
| @@ -268,15 +277,6 @@ class ContextManagerTest {
|
| equals(packageMapProvider.packageMaps[subProjectB]));
|
| }
|
|
|
| - void test_setRoots_addFolderWithoutPubspec() {
|
| - packageMapProvider.packageMap = null;
|
| - manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| - // verify
|
| - expect(manager.currentContextPaths, hasLength(1));
|
| - expect(manager.currentContextPaths, contains(projPath));
|
| - expect(manager.currentContextFilePaths[projPath], hasLength(0));
|
| - }
|
| -
|
| void test_setRoots_addPackageRoot() {
|
| String packagePathFoo = '/package1/foo';
|
| String packageRootPath = '/package2/foo';
|
| @@ -471,6 +471,17 @@ class ContextManagerTest {
|
| _checkPackageMap(projPath, equals(packageMapProvider.packageMap));
|
| }
|
|
|
| + void test_setRoots_removeFolderWithoutPubspec() {
|
| + packageMapProvider.packageMap = null;
|
| + // add one root - there is a context
|
| + manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| + expect(manager.currentContextPaths, hasLength(1));
|
| + // set empty roots - no contexts
|
| + manager.setRoots(<String>[], <String>[], <String, String>{});
|
| + expect(manager.currentContextPaths, hasLength(0));
|
| + expect(manager.currentContextFilePaths, hasLength(0));
|
| + }
|
| +
|
| void test_setRoots_removeFolderWithPubspec() {
|
| // create a pubspec
|
| String pubspecPath = posix.join(projPath, 'pubspec.yaml');
|
| @@ -520,17 +531,6 @@ class ContextManagerTest {
|
| manager.assertContextFiles(subProjectA, [subProjectA_file]);
|
| }
|
|
|
| - void test_setRoots_removeFolderWithoutPubspec() {
|
| - packageMapProvider.packageMap = null;
|
| - // add one root - there is a context
|
| - manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| - expect(manager.currentContextPaths, hasLength(1));
|
| - // set empty roots - no contexts
|
| - manager.setRoots(<String>[], <String>[], <String, String>{});
|
| - expect(manager.currentContextPaths, hasLength(0));
|
| - expect(manager.currentContextFilePaths, hasLength(0));
|
| - }
|
| -
|
| void test_setRoots_removePackageRoot() {
|
| String packagePathFoo = '/package1/foo';
|
| String packageRootPath = '/package2/foo';
|
| @@ -577,21 +577,6 @@ class ContextManagerTest {
|
| });
|
| }
|
|
|
| - test_watch_addFileInSubfolder() {
|
| - manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| - // empty folder initially
|
| - Map<String, int> filePaths = manager.currentContextFilePaths[projPath];
|
| - expect(filePaths, hasLength(0));
|
| - // add file in subfolder
|
| - String filePath = posix.join(projPath, 'foo', 'bar.dart');
|
| - resourceProvider.newFile(filePath, 'contents');
|
| - // the file was added
|
| - return pumpEventQueue().then((_) {
|
| - expect(filePaths, hasLength(1));
|
| - expect(filePaths, contains(filePath));
|
| - });
|
| - }
|
| -
|
| test_watch_addFile_excluded() {
|
| // prepare paths
|
| String project = '/project';
|
| @@ -613,6 +598,21 @@ class ContextManagerTest {
|
| });
|
| }
|
|
|
| + test_watch_addFileInSubfolder() {
|
| + manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| + // empty folder initially
|
| + Map<String, int> filePaths = manager.currentContextFilePaths[projPath];
|
| + expect(filePaths, hasLength(0));
|
| + // add file in subfolder
|
| + String filePath = posix.join(projPath, 'foo', 'bar.dart');
|
| + resourceProvider.newFile(filePath, 'contents');
|
| + // the file was added
|
| + return pumpEventQueue().then((_) {
|
| + expect(filePaths, hasLength(1));
|
| + expect(filePaths, contains(filePath));
|
| + });
|
| + }
|
| +
|
| test_watch_addPubspec_toRoot() {
|
| // prepare paths
|
| String root = '/root';
|
| @@ -686,15 +686,41 @@ class ContextManagerTest {
|
| test_watch_deleteFile() {
|
| String filePath = posix.join(projPath, 'foo.dart');
|
| // add root with a file
|
| - resourceProvider.newFile(filePath, 'contents');
|
| + File file = resourceProvider.newFile(filePath, 'contents');
|
| + Folder projFolder = file.parent;
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| // the file was added
|
| Map<String, int> filePaths = manager.currentContextFilePaths[projPath];
|
| expect(filePaths, hasLength(1));
|
| expect(filePaths, contains(filePath));
|
| + expect(file.exists, isTrue);
|
| + expect(projFolder.exists, isTrue);
|
| // delete the file
|
| resourceProvider.deleteFile(filePath);
|
| return pumpEventQueue().then((_) {
|
| + expect(file.exists, isFalse);
|
| + expect(projFolder.exists, isTrue);
|
| + return expect(filePaths, hasLength(0));
|
| + });
|
| + }
|
| +
|
| + test_watch_deleteFolder() {
|
| + String filePath = posix.join(projPath, 'foo.dart');
|
| + // add root with a file
|
| + File file = resourceProvider.newFile(filePath, 'contents');
|
| + Folder projFolder = file.parent;
|
| + manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| + // the file was added
|
| + Map<String, int> filePaths = manager.currentContextFilePaths[projPath];
|
| + expect(filePaths, hasLength(1));
|
| + expect(filePaths, contains(filePath));
|
| + expect(file.exists, isTrue);
|
| + expect(projFolder.exists, isTrue);
|
| + // delete the folder
|
| + resourceProvider.deleteFolder(projPath);
|
| + return pumpEventQueue().then((_) {
|
| + expect(file.exists, isFalse);
|
| + expect(projFolder.exists, isFalse);
|
| return expect(filePaths, hasLength(0));
|
| });
|
| }
|
|
|