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 a77ccf8a6899c5ea1a5f63cd8d88ba60b93423f0..1662b9fde677c6b8b491b7c064066511c616108e 100644 |
--- a/pkg/analysis_server/test/domain_execution_test.dart |
+++ b/pkg/analysis_server/test/domain_execution_test.dart |
@@ -20,6 +20,8 @@ import 'package:unittest/unittest.dart'; |
import 'mock_sdk.dart'; |
import 'mocks.dart'; |
import 'operation/operation_queue_test.dart'; |
+import 'package:analyzer/file_system/file_system.dart'; |
+import 'package:analyzer/src/generated/source_io.dart'; |
/** |
* Return a matcher that will match an [ExecutableFile] if it has the given |
@@ -84,64 +86,95 @@ main() { |
}); |
}); |
-// group('mapUri', () { |
-// String contextId; |
-// |
-// setUp(() { |
-// 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; |
-// }); |
-// |
-// tearDown(() { |
-// Request request = |
-// new ExecutionDeleteContextParams(contextId).toRequest('1'); |
-// Response response = handler.handleRequest(request); |
-// expect(response, isResponseSuccess('1')); |
-// }); |
-// |
-// test('file to URI', () { |
-// Request request = |
-// new ExecutionMapUriParams(contextId, file: '/a/b.dart').toRequest('2'); |
-// Response response = handler.handleRequest(request); |
-// expect(response, isResponseSuccess('2')); |
-// ExecutionMapUriResult result = |
-// new ExecutionMapUriResult.fromResponse(response); |
-// expect(result.file, isNull); |
-// expect(result.uri, isNotNull); |
-// // TODO(brianwilkerson) Test for the correct result. |
-// }); |
-// |
-// test('URI to file', () { |
-// Request request = |
-// new ExecutionMapUriParams(contextId, uri: '/a/b.dart').toRequest('3'); |
-// Response response = handler.handleRequest(request); |
-// expect(response, isResponseSuccess('3')); |
-// ExecutionMapUriResult result = |
-// new ExecutionMapUriResult.fromResponse(response); |
-// expect(result.file, isNotNull); |
-// expect(result.uri, isNull); |
-// // TODO(brianwilkerson) Test for the correct result. |
-// }); |
-// |
-// test('invalid context id', () { |
-// Request request = |
-// new ExecutionMapUriParams('xxx', uri: '').toRequest('4'); |
-// Response response = handler.handleRequest(request); |
-// expect(response, isResponseFailure('4')); |
-// }); |
-// |
-// test('both file and uri', () { |
-// Request request = |
-// new ExecutionMapUriParams('xxx', file: '', uri: '').toRequest('5'); |
-// Response response = handler.handleRequest(request); |
-// expect(response, isResponseFailure('5')); |
-// }); |
-// }); |
+ group('mapUri', () { |
+ String contextId; |
+ |
+ setUp(() { |
+ Folder folder = provider.newFile('/a/b.dart', '').parent; |
+ server.folderMap.putIfAbsent(folder, () { |
+ SourceFactory factory = new SourceFactory([new ResourceUriResolver(provider)]); |
+ AnalysisContext context = AnalysisEngine.instance.createAnalysisContext(); |
+ 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; |
+ }); |
+ |
+ tearDown(() { |
+ Request request = |
+ new ExecutionDeleteContextParams(contextId).toRequest('1'); |
+ Response response = handler.handleRequest(request); |
+ expect(response, isResponseSuccess('1')); |
+ }); |
+ |
+ group('file to URI', () { |
+ test('does not exist', () { |
+ Request request = |
+ new ExecutionMapUriParams(contextId, file: '/a/c.dart').toRequest('2'); |
+ Response response = handler.handleRequest(request); |
+ expect(response, isResponseFailure('2')); |
+ }); |
+ |
+ test('does not exist', () { |
Paul Berry
2015/02/06 03:55:33
Did you copy/paste the test name from the previous
Brian Wilkerson
2015/02/06 15:49:01
Done
|
+ provider.newFolder('/a/d'); |
+ Request request = |
+ new ExecutionMapUriParams(contextId, file: '/a/d').toRequest('2'); |
+ Response response = handler.handleRequest(request); |
+ expect(response, isResponseFailure('2')); |
+ }); |
+ |
+ test('valid', () { |
+ Request request = |
+ new ExecutionMapUriParams(contextId, file: '/a/b.dart').toRequest('2'); |
+ Response response = handler.handleRequest(request); |
+ expect(response, isResponseSuccess('2')); |
+ ExecutionMapUriResult result = |
+ new ExecutionMapUriResult.fromResponse(response); |
+ expect(result.file, isNull); |
+ expect(result.uri, 'file:///a/b.dart'); |
+ }); |
+ }); |
+ |
+ group('URI to file', () { |
+ test('invalid', () { |
+ Request request = |
+ new ExecutionMapUriParams(contextId, uri: 'foo:///a/b.dart').toRequest('2'); |
+ Response response = handler.handleRequest(request); |
+ expect(response, isResponseFailure('2')); |
+ }); |
+ |
+ test('valid', () { |
+ Request request = |
+ new ExecutionMapUriParams(contextId, uri: 'file:///a/b.dart').toRequest('2'); |
+ Response response = handler.handleRequest(request); |
+ expect(response, isResponseSuccess('2')); |
+ ExecutionMapUriResult result = |
+ new ExecutionMapUriResult.fromResponse(response); |
+ expect(result.file, '/a/b.dart'); |
+ expect(result.uri, isNull); |
+ }); |
+ }); |
+ |
+ test('invalid context id', () { |
+ Request request = |
+ new ExecutionMapUriParams('xxx', uri: '').toRequest('4'); |
+ Response response = handler.handleRequest(request); |
+ expect(response, isResponseFailure('4')); |
+ }); |
+ |
+ test('both file and uri', () { |
Paul Berry
2015/02/06 03:55:33
Should we also have a test for the case where neit
Brian Wilkerson
2015/02/06 15:49:01
Done
|
+ Request request = |
+ new ExecutionMapUriParams('xxx', file: '', uri: '').toRequest('5'); |
+ Response response = handler.handleRequest(request); |
+ expect(response, isResponseFailure('5')); |
+ }); |
+ }); |
group('setSubscriptions', () { |
test('failure - invalid service name', () { |