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

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

Issue 1455163005: Implement AnalysisServer.getContainingContext() using ContextManager. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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/analysis_server_test.dart
diff --git a/pkg/analysis_server/test/analysis_server_test.dart b/pkg/analysis_server/test/analysis_server_test.dart
index 663c1d84d6be06e30a25d8dcea3f6f67680bc6c1..5275d3a43298137625bb20434ea85848fd722920 100644
--- a/pkg/analysis_server/test/analysis_server_test.dart
+++ b/pkg/analysis_server/test/analysis_server_test.dart
@@ -242,20 +242,15 @@ import "../foo/foo.dart";
String dir1Path = '/dir1';
String dir2Path = dir1Path + '/dir2';
String filePath = dir2Path + '/file.dart';
- Folder dir1 = resourceProvider.newFolder(dir1Path);
- Folder dir2 = resourceProvider.newFolder(dir2Path);
+ resourceProvider.newFile('$dir1Path/.packages', '');
+ resourceProvider.newFile('$dir2Path/.packages', '');
resourceProvider.newFile(filePath, 'library lib;');
-
- AnalysisContext context1 = AnalysisEngine.instance.createAnalysisContext();
- AnalysisContext context2 = AnalysisEngine.instance.createAnalysisContext();
- _configureSourceFactory(context1);
- _configureSourceFactory(context2);
- server.folderMap[dir1] = context1;
- server.folderMap[dir2] = context2;
-
+ // create contexts
+ server.setAnalysisRoots('0', [dir1Path], [], {});
+ // get pair
ContextSourcePair pair = server.getContextSourcePair(filePath);
Source source = pair.source;
- expect(pair.context, same(context2));
+ _assertContextOfFolder(pair.context, dir2Path);
expect(source, isNotNull);
expect(source.uri.scheme, 'file');
expect(source.fullName, filePath);
@@ -284,14 +279,12 @@ import "../foo/foo.dart";
packageMapProvider.packageMap = <String, List<Folder>>{
'my_package': <Folder>[rootFolder]
};
-
- AnalysisContext context = AnalysisEngine.instance.createAnalysisContext();
- _configureSourceFactory(context);
- server.folderMap[rootFolder] = context;
-
+ // create contexts
+ server.setAnalysisRoots('0', [rootPath], [], {});
+ // get pair
ContextSourcePair pair = server.getContextSourcePair(filePath);
Source source = pair.source;
- expect(pair.context, same(context));
+ _assertContextOfFolder(pair.context, rootPath);
expect(source, isNotNull);
expect(source.uri.scheme, 'package');
expect(source.fullName, filePath);
@@ -300,16 +293,13 @@ import "../foo/foo.dart";
test_getContextSourcePair_simple() {
String dirPath = '/dir';
String filePath = dirPath + '/file.dart';
- Folder dir = resourceProvider.newFolder(dirPath);
resourceProvider.newFile(filePath, 'library lib;');
-
- AnalysisContext context = AnalysisEngine.instance.createAnalysisContext();
- _configureSourceFactory(context);
- server.folderMap[dir] = context;
-
+ // create contexts
+ server.setAnalysisRoots('0', [dirPath], [], {});
+ // get pair
ContextSourcePair pair = server.getContextSourcePair(filePath);
Source source = pair.source;
- expect(pair.context, same(context));
+ _assertContextOfFolder(pair.context, dirPath);
expect(source, isNotNull);
expect(source.uri.scheme, 'file');
expect(source.fullName, filePath);
@@ -506,6 +496,15 @@ import "../foo/foo.dart";
}), isFalse);
}
+ void _assertContextOfFolder(
+ AnalysisContext context, String expectedFolderPath) {
+ Folder expectedFolder = resourceProvider.newFolder(expectedFolderPath);
+ ContextInfo expectedContextInfo = (server.contextManager
+ as ContextManagerImpl).getContextInfoFor(expectedFolder);
+ expect(expectedContextInfo, isNotNull);
+ expect(context, same(expectedContextInfo.context));
+ }
+
void _configureSourceFactory(AnalysisContext context) {
var resourceUriResolver = new ResourceUriResolver(resourceProvider);
var packageUriResolver = new PackageMapUriResolver(
« no previous file with comments | « pkg/analysis_server/test/analysis/get_errors_test.dart ('k') | pkg/analysis_server/test/domain_execution_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698