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

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

Issue 1457643002: Fix for mapping SDK files to 'dart:' URIs. (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
« no previous file with comments | « pkg/analysis_server/lib/src/domain_execution.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/domain_execution_test.dart
diff --git a/pkg/analysis_server/test/domain_execution_test.dart b/pkg/analysis_server/test/domain_execution_test.dart
index 927d46d6047c654e20efa8fb83d78f029b01b885..174e6c2de8d5506211c3d26a059e46f184aa4ae2 100644
--- a/pkg/analysis_server/test/domain_execution_test.dart
+++ b/pkg/analysis_server/test/domain_execution_test.dart
@@ -19,9 +19,11 @@ import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/source_io.dart';
import 'package:plugin/manager.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'package:typed_mock/typed_mock.dart';
import 'package:unittest/unittest.dart';
+import 'analysis_abstract.dart';
import 'mock_sdk.dart';
import 'mocks.dart';
import 'operation/operation_queue_test.dart';
@@ -29,6 +31,7 @@ import 'utils.dart';
main() {
initializeTestEnvironment();
+ defineReflectiveTests(ExecutionDomainTest);
group('ExecutionDomainHandler', () {
MemoryResourceProvider provider = new MemoryResourceProvider();
AnalysisServer server;
@@ -90,6 +93,15 @@ main() {
group('mapUri', () {
String contextId;
+ void createExecutionContextIdForFile(String zzz) {
+ Request request = new ExecutionCreateContextParams(zzz).toRequest('0');
+ Response response = handler.handleRequest(request);
+ expect(response, isResponseSuccess('0'));
+ ExecutionCreateContextResult result =
+ new ExecutionCreateContextResult.fromResponse(response);
+ contextId = result.id;
+ }
+
setUp(() {
Folder folder = provider.newFile('/a/b.dart', '').parent;
server.folderMap.putIfAbsent(folder, () {
@@ -100,13 +112,7 @@ main() {
context.sourceFactory = factory;
return context;
});
- Request request =
- new ExecutionCreateContextParams('/a/b.dart').toRequest('0');
- Response response = handler.handleRequest(request);
- expect(response, isResponseSuccess('0'));
- ExecutionCreateContextResult result =
- new ExecutionCreateContextResult.fromResponse(response);
- contextId = result.id;
+ createExecutionContextIdForFile('/a/b.dart');
});
tearDown(() {
@@ -287,35 +293,56 @@ main() {
});
}
-/**
- * Return a matcher that will match an [ExecutableFile] if it has the given
- * [source] and [kind].
- */
-Matcher isExecutableFile(Source source, ExecutableKind kind) {
- return new IsExecutableFile(source.fullName, kind);
-}
-
-/**
- * A matcher that will match an [ExecutableFile] if it has a specified [source]
- * and [kind].
- */
-class IsExecutableFile extends Matcher {
- String expectedFile;
- ExecutableKind expectedKind;
-
- IsExecutableFile(this.expectedFile, this.expectedKind);
+@reflectiveTest
+class ExecutionDomainTest extends AbstractAnalysisTest {
+ String contextId;
@override
- Description describe(Description description) {
- return description.add('ExecutableFile($expectedFile, $expectedKind)');
+ void setUp() {
+ super.setUp();
+ createProject();
+ handler = new ExecutionDomainHandler(server);
+ _createExecutionContext(testFile);
}
@override
- bool matches(item, Map matchState) {
- if (item is! ExecutableFile) {
- return false;
- }
- return item.file == expectedFile && item.kind == expectedKind;
+ void tearDown() {
+ super.tearDown();
+ _disposeExecutionContext();
+ }
+
+ void test_mapUri_file_dart() {
+ String path = server.defaultSdk.mapDartUri('dart:async').fullName;
+ // hack - pretend that the SDK file exists in the project FS
+ resourceProvider.newFile(path, '// hack');
+ // map file
+ ExecutionMapUriResult result = _mapUri(file: path);
+ expect(result.file, isNull);
+ expect(result.uri, 'dart:async');
+ }
+
+ void _createExecutionContext(String path) {
+ Request request = new ExecutionCreateContextParams(path).toRequest('0');
+ Response response = handler.handleRequest(request);
+ expect(response, isResponseSuccess('0'));
+ ExecutionCreateContextResult result =
+ new ExecutionCreateContextResult.fromResponse(response);
+ contextId = result.id;
+ }
+
+ void _disposeExecutionContext() {
+ Request request =
+ new ExecutionDeleteContextParams(contextId).toRequest('1');
+ Response response = handler.handleRequest(request);
+ expect(response, isResponseSuccess('1'));
+ }
+
+ ExecutionMapUriResult _mapUri({String file, String uri}) {
+ Request request = new ExecutionMapUriParams(contextId, file: file, uri: uri)
+ .toRequest('2');
+ Response response = handler.handleRequest(request);
+ expect(response, isResponseSuccess('2'));
+ return new ExecutionMapUriResult.fromResponse(response);
}
}
« no previous file with comments | « pkg/analysis_server/lib/src/domain_execution.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698