| 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 a60bb60264d725633e996ac158da449eee73b6ba..73b260726332e3e074e144339a4186c90f633490 100644
|
| --- a/pkg/analysis_server/test/context_manager_test.dart
|
| +++ b/pkg/analysis_server/test/context_manager_test.dart
|
| @@ -78,6 +78,47 @@ class ContextManagerTest {
|
| expect(manager.isInAnalysisRoot('/test.dart'), isFalse);
|
| }
|
|
|
| + test_refresh_folder_with_pubspec() {
|
| + // create a context with a pubspec.yaml file
|
| + String pubspecPath = posix.join(projPath, 'pubspec.yaml');
|
| + resourceProvider.newFile(pubspecPath, 'pubspec');
|
| + manager.setRoots(<String>[projPath], <String>[]);
|
| + return pumpEventQueue().then((_) {
|
| + expect(manager.currentContextPaths.toList(), [projPath]);
|
| + manager.now++;
|
| + manager.refresh();
|
| + return pumpEventQueue().then((_) {
|
| + expect(manager.currentContextPaths.toList(), [projPath]);
|
| + expect(manager.currentContextTimestamps[projPath], manager.now);
|
| + });
|
| + });
|
| + }
|
| +
|
| + test_refresh_folder_with_pubspec_subfolders() {
|
| + // Create a folder with no pubspec.yaml, containing two subfolders with
|
| + // pubspec.yaml files.
|
| + String subdir1Path = posix.join(projPath, 'subdir1');
|
| + String subdir2Path = posix.join(projPath, 'subdir2');
|
| + String pubspec1Path = posix.join(subdir1Path, 'pubspec.yaml');
|
| + String pubspec2Path = posix.join(subdir2Path, 'pubspec.yaml');
|
| + resourceProvider.newFile(pubspec1Path, 'pubspec');
|
| + resourceProvider.newFile(pubspec2Path, 'pubspec');
|
| + manager.setRoots(<String>[projPath], <String>[]);
|
| + return pumpEventQueue().then((_) {
|
| + expect(manager.currentContextPaths.toSet(),
|
| + [projPath, subdir1Path, subdir2Path].toSet());
|
| + manager.now++;
|
| + manager.refresh();
|
| + return pumpEventQueue().then((_) {
|
| + expect(manager.currentContextPaths.toSet(),
|
| + [projPath, subdir1Path, subdir2Path].toSet());
|
| + expect(manager.currentContextTimestamps[projPath], manager.now);
|
| + expect(manager.currentContextTimestamps[subdir1Path], manager.now);
|
| + expect(manager.currentContextTimestamps[subdir2Path], manager.now);
|
| + });
|
| + });
|
| + }
|
| +
|
| void test_setRoots_addFolderWithDartFile() {
|
| String filePath = posix.join(projPath, 'foo.dart');
|
| resourceProvider.newFile(filePath, 'contents');
|
| @@ -638,7 +679,15 @@ class TestContextManager extends ContextManager {
|
| */
|
| int now = 0;
|
|
|
| - final Set<String> currentContextPaths = new Set<String>();
|
| + /**
|
| + * Map from context to the timestamp when the context was created.
|
| + */
|
| + Map<String, int> currentContextTimestamps = <String, int>{};
|
| +
|
| + /**
|
| + * Iterable of the paths to contexts that currently exist.
|
| + */
|
| + Iterable<String> get currentContextPaths => currentContextTimestamps.keys;
|
|
|
| /**
|
| * Map from context to (map from file path to timestamp of last event).
|
| @@ -659,7 +708,8 @@ class TestContextManager extends ContextManager {
|
| @override
|
| void addContext(Folder folder, Map<String, List<Folder>> packageMap) {
|
| String path = folder.path;
|
| - currentContextPaths.add(path);
|
| + expect(currentContextPaths, isNot(contains(path)));
|
| + currentContextTimestamps[path] = now;
|
| currentContextFilePaths[path] = <String, int>{};
|
| currentContextPackageMaps[path] = packageMap;
|
| }
|
| @@ -693,7 +743,8 @@ class TestContextManager extends ContextManager {
|
| @override
|
| void removeContext(Folder folder) {
|
| String path = folder.path;
|
| - currentContextPaths.remove(path);
|
| + expect(currentContextPaths, contains(path));
|
| + currentContextTimestamps.remove(path);
|
| currentContextFilePaths.remove(path);
|
| currentContextPackageMaps.remove(path);
|
| }
|
|
|