| Index: pkg/analysis_server/test/context_directory_manager_test.dart
|
| diff --git a/pkg/analysis_server/test/context_directory_manager_test.dart b/pkg/analysis_server/test/context_directory_manager_test.dart
|
| index 08a3c94d0b2423d9598dc35c50dbd074cf0fdef6..a42faf81fdfedc7d1a5bbad65150705da159e6db 100644
|
| --- a/pkg/analysis_server/test/context_directory_manager_test.dart
|
| +++ b/pkg/analysis_server/test/context_directory_manager_test.dart
|
| @@ -4,6 +4,7 @@
|
|
|
| library test.context.directory.manager;
|
|
|
| +import 'mocks.dart';
|
| import 'package:analysis_server/src/context_directory_manager.dart';
|
| import 'package:analysis_server/src/resource.dart';
|
| import 'package:path/path.dart';
|
| @@ -29,9 +30,14 @@ class TestContextDirectoryManager extends ContextDirectoryManager {
|
| void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) {
|
| Set<String> filePaths = currentContextFilePaths[contextFolder.fullName];
|
| for (Source source in changeSet.addedSources) {
|
| + expect(filePaths, isNot(contains(source.fullName)));
|
| filePaths.add(source.fullName);
|
| }
|
| - // TODO(paulberry): handle source.changedSources and source.removedSources.
|
| + for (Source source in changeSet.removedSources) {
|
| + expect(filePaths, contains(source.fullName));
|
| + filePaths.remove(source.fullName);
|
| + }
|
| + // TODO(paulberry): handle source.changedSources.
|
| }
|
| }
|
|
|
| @@ -90,5 +96,49 @@ main() {
|
| expect(filePaths, hasLength(1));
|
| expect(filePaths, contains(filePath));
|
| });
|
| +
|
| + group('detect context modifications', () {
|
| + String projPath;
|
| +
|
| + setUp(() {
|
| + projPath = '/my/proj';
|
| + provider.newFolder(projPath);
|
| + });
|
| +
|
| + test('Add file', () {
|
| + manager.setRoots(<String>[projPath], <String>[]);
|
| + Set<String> filePaths = manager.currentContextFilePaths[projPath];
|
| + expect(filePaths, hasLength(0));
|
| + String filePath = posix.join(projPath, 'foo.dart');
|
| + provider.newFile(filePath, 'contents');
|
| + return pumpEventQueue().then((_) {
|
| + expect(filePaths, hasLength(1));
|
| + expect(filePaths, contains(filePath));
|
| + });
|
| + });
|
| +
|
| + test('Add file in subdirectory', () {
|
| + manager.setRoots(<String>[projPath], <String>[]);
|
| + Set<String> filePaths = manager.currentContextFilePaths[projPath];
|
| + expect(filePaths, hasLength(0));
|
| + String filePath = posix.join(projPath, 'foo', 'bar.dart');
|
| + provider.newFile(filePath, 'contents');
|
| + return pumpEventQueue().then((_) {
|
| + expect(filePaths, hasLength(1));
|
| + expect(filePaths, contains(filePath));
|
| + });
|
| + });
|
| +
|
| + test('Delete file', () {
|
| + String filePath = posix.join(projPath, 'foo.dart');
|
| + provider.newFile(filePath, 'contents');
|
| + manager.setRoots(<String>[projPath], <String>[]);
|
| + Set<String> filePaths = manager.currentContextFilePaths[projPath];
|
| + expect(filePaths, hasLength(1));
|
| + expect(filePaths, contains(filePath));
|
| + provider.deleteFile(filePath);
|
| + return pumpEventQueue().then((_) => expect(filePaths, hasLength(0)));
|
| + });
|
| + });
|
| });
|
| }
|
|
|