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

Unified Diff: pkg/analysis_server/test/context_directory_manager_test.dart

Issue 306733002: Make ContextDirectoryManager responsible for scanning directory contents. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
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 4a3c0c2b5d197ed6f010705742cd530d3edaaeef..08a3c94d0b2423d9598dc35c50dbd074cf0fdef6 100644
--- a/pkg/analysis_server/test/context_directory_manager_test.dart
+++ b/pkg/analysis_server/test/context_directory_manager_test.dart
@@ -6,16 +6,32 @@ library test.context.directory.manager;
import 'package:analysis_server/src/context_directory_manager.dart';
import 'package:analysis_server/src/resource.dart';
+import 'package:path/path.dart';
import 'package:unittest/unittest.dart';
+import 'package:analyzer/src/generated/engine.dart';
+import 'package:analyzer/src/generated/source.dart';
class TestContextDirectoryManager extends ContextDirectoryManager {
TestContextDirectoryManager(MemoryResourceProvider provider) : super(provider);
final Set<String> currentContextPaths = new Set<String>();
+ final Map<String, String> currentContextPubspecPaths = <String, String>{};
+ final Map<String, Set<String>> currentContextFilePaths = <String, Set<String>>{};
@override
- void addContext(Folder folder) {
+ void addContext(Folder folder, File pubspecFile) {
currentContextPaths.add(folder.fullName);
+ currentContextPubspecPaths[folder.fullName] = pubspecFile != null ? pubspecFile.fullName : null;
+ currentContextFilePaths[folder.fullName] = new Set<String>();
+ }
+
+ @override
+ void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) {
+ Set<String> filePaths = currentContextFilePaths[contextFolder.fullName];
+ for (Source source in changeSet.addedSources) {
+ filePaths.add(source.fullName);
+ }
+ // TODO(paulberry): handle source.changedSources and source.removedSources.
}
}
@@ -32,10 +48,47 @@ main() {
});
test('add folder with pubspec', () {
- provider.newFile('/my/proj/pubspec.yaml', 'pubspec');
- manager.setRoots(<String>['/my/proj'], <String>[]);
+ String projPath = '/my/proj';
+ String pubspecPath = posix.join(projPath, 'pubspec.yaml');
+ provider.newFolder(projPath);
+ provider.newFile(pubspecPath, 'pubspec');
+ manager.setRoots(<String>[projPath], <String>[]);
+ expect(manager.currentContextPaths, hasLength(1));
+ expect(manager.currentContextPaths, contains(projPath));
+ expect(manager.currentContextPubspecPaths[projPath], equals(pubspecPath));
+ expect(manager.currentContextFilePaths[projPath], hasLength(0));
+ });
+
+ test('add folder without pubspec', () {
+ String projPath = '/my/proj';
+ provider.newFolder(projPath);
+ manager.setRoots(<String>[projPath], <String>[]);
expect(manager.currentContextPaths, hasLength(1));
- expect(manager.currentContextPaths, contains('/my/proj'));
+ expect(manager.currentContextPaths, contains(projPath));
+ expect(manager.currentContextPubspecPaths[projPath], isNull);
+ expect(manager.currentContextFilePaths[projPath], hasLength(0));
+ });
+
+ test('add folder with dart file', () {
+ String projPath = '/my/proj';
+ provider.newFolder(projPath);
+ String filePath = posix.join(projPath, 'foo.dart');
+ provider.newFile(filePath, 'contents');
+ manager.setRoots(<String>[projPath], <String>[]);
+ var filePaths = manager.currentContextFilePaths[projPath];
+ expect(filePaths, hasLength(1));
+ expect(filePaths, contains(filePath));
+ });
+
+ test('add folder with dart file in subdir', () {
+ String projPath = '/my/proj';
+ provider.newFolder(projPath);
+ String filePath = posix.join(projPath, 'foo', 'bar.dart');
+ provider.newFile(filePath, 'contents');
+ manager.setRoots(<String>[projPath], <String>[]);
+ var filePaths = manager.currentContextFilePaths[projPath];
+ expect(filePaths, hasLength(1));
+ expect(filePaths, contains(filePath));
});
});
}

Powered by Google App Engine
This is Rietveld 408576698