| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.domain.execution; | 5 library test.domain.execution; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 ExtensionManager manager = new ExtensionManager(); | 41 ExtensionManager manager = new ExtensionManager(); |
| 42 ServerPlugin serverPlugin = new ServerPlugin(); | 42 ServerPlugin serverPlugin = new ServerPlugin(); |
| 43 manager.processPlugins([serverPlugin]); | 43 manager.processPlugins([serverPlugin]); |
| 44 server = new AnalysisServer( | 44 server = new AnalysisServer( |
| 45 new MockServerChannel(), | 45 new MockServerChannel(), |
| 46 provider, | 46 provider, |
| 47 new MockPackageMapProvider(), | 47 new MockPackageMapProvider(), |
| 48 null, | 48 null, |
| 49 serverPlugin, | 49 serverPlugin, |
| 50 new AnalysisServerOptions(), | 50 new AnalysisServerOptions(), |
| 51 new MockSdk(), | 51 () => new MockSdk(), |
| 52 InstrumentationService.NULL_SERVICE); | 52 InstrumentationService.NULL_SERVICE); |
| 53 handler = new ExecutionDomainHandler(server); | 53 handler = new ExecutionDomainHandler(server); |
| 54 }); | 54 }); |
| 55 | 55 |
| 56 group('createContext/deleteContext', () { | 56 group('createContext/deleteContext', () { |
| 57 test('create/delete multiple contexts', () { | 57 test('create/delete multiple contexts', () { |
| 58 Request request = | 58 Request request = |
| 59 new ExecutionCreateContextParams('/a/b.dart').toRequest('0'); | 59 new ExecutionCreateContextParams('/a/b.dart').toRequest('0'); |
| 60 Response response = handler.handleRequest(request); | 60 Response response = handler.handleRequest(request); |
| 61 expect(response, isResponseSuccess('0')); | 61 expect(response, isResponseSuccess('0')); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 tearDown(() { | 118 tearDown(() { |
| 119 Request request = | 119 Request request = |
| 120 new ExecutionDeleteContextParams(contextId).toRequest('1'); | 120 new ExecutionDeleteContextParams(contextId).toRequest('1'); |
| 121 Response response = handler.handleRequest(request); | 121 Response response = handler.handleRequest(request); |
| 122 expect(response, isResponseSuccess('1')); | 122 expect(response, isResponseSuccess('1')); |
| 123 }); | 123 }); |
| 124 | 124 |
| 125 group('file to URI', () { | 125 group('file to URI', () { |
| 126 test('does not exist', () { | 126 test('does not exist', () { |
| 127 Request request = new ExecutionMapUriParams(contextId, | 127 Request request = |
| 128 file: '/a/c.dart').toRequest('2'); | 128 new ExecutionMapUriParams(contextId, file: '/a/c.dart') |
| 129 .toRequest('2'); |
| 129 Response response = handler.handleRequest(request); | 130 Response response = handler.handleRequest(request); |
| 130 expect(response, isResponseFailure('2')); | 131 expect(response, isResponseFailure('2')); |
| 131 }); | 132 }); |
| 132 | 133 |
| 133 test('directory', () { | 134 test('directory', () { |
| 134 provider.newFolder('/a/d'); | 135 provider.newFolder('/a/d'); |
| 135 Request request = | 136 Request request = |
| 136 new ExecutionMapUriParams(contextId, file: '/a/d').toRequest('2'); | 137 new ExecutionMapUriParams(contextId, file: '/a/d').toRequest('2'); |
| 137 Response response = handler.handleRequest(request); | 138 Response response = handler.handleRequest(request); |
| 138 expect(response, isResponseFailure('2')); | 139 expect(response, isResponseFailure('2')); |
| 139 }); | 140 }); |
| 140 }); | 141 }); |
| 141 | 142 |
| 142 group('URI to file', () { | 143 group('URI to file', () { |
| 143 test('invalid', () { | 144 test('invalid', () { |
| 144 Request request = new ExecutionMapUriParams(contextId, | 145 Request request = |
| 145 uri: 'foo:///a/b.dart').toRequest('2'); | 146 new ExecutionMapUriParams(contextId, uri: 'foo:///a/b.dart') |
| 147 .toRequest('2'); |
| 146 Response response = handler.handleRequest(request); | 148 Response response = handler.handleRequest(request); |
| 147 expect(response, isResponseFailure('2')); | 149 expect(response, isResponseFailure('2')); |
| 148 }); | 150 }); |
| 149 }); | 151 }); |
| 150 | 152 |
| 151 test('invalid context id', () { | 153 test('invalid context id', () { |
| 152 Request request = | 154 Request request = |
| 153 new ExecutionMapUriParams('xxx', uri: '').toRequest('4'); | 155 new ExecutionMapUriParams('xxx', uri: '').toRequest('4'); |
| 154 Response response = handler.handleRequest(request); | 156 Response response = handler.handleRequest(request); |
| 155 expect(response, isResponseFailure('4')); | 157 expect(response, isResponseFailure('4')); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 void test_mapUri_file() { | 294 void test_mapUri_file() { |
| 293 String path = '/a/b.dart'; | 295 String path = '/a/b.dart'; |
| 294 resourceProvider.newFile(path, ''); | 296 resourceProvider.newFile(path, ''); |
| 295 // map the file | 297 // map the file |
| 296 ExecutionMapUriResult result = _mapUri(file: path); | 298 ExecutionMapUriResult result = _mapUri(file: path); |
| 297 expect(result.file, isNull); | 299 expect(result.file, isNull); |
| 298 expect(result.uri, 'file:///a/b.dart'); | 300 expect(result.uri, 'file:///a/b.dart'); |
| 299 } | 301 } |
| 300 | 302 |
| 301 void test_mapUri_file_dartUriKind() { | 303 void test_mapUri_file_dartUriKind() { |
| 302 String path = server.defaultSdk.mapDartUri('dart:async').fullName; | 304 String path = server.findSdk().mapDartUri('dart:async').fullName; |
| 303 // hack - pretend that the SDK file exists in the project FS | 305 // hack - pretend that the SDK file exists in the project FS |
| 304 resourceProvider.newFile(path, '// hack'); | 306 resourceProvider.newFile(path, '// hack'); |
| 305 // map file | 307 // map file |
| 306 ExecutionMapUriResult result = _mapUri(file: path); | 308 ExecutionMapUriResult result = _mapUri(file: path); |
| 307 expect(result.file, isNull); | 309 expect(result.file, isNull); |
| 308 expect(result.uri, 'dart:async'); | 310 expect(result.uri, 'dart:async'); |
| 309 } | 311 } |
| 310 | 312 |
| 311 void test_mapUri_uri() { | 313 void test_mapUri_uri() { |
| 312 String path = '/a/b.dart'; | 314 String path = '/a/b.dart'; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 * A [Source] that knows it's [fullName]. | 348 * A [Source] that knows it's [fullName]. |
| 347 */ | 349 */ |
| 348 class TestSource implements Source { | 350 class TestSource implements Source { |
| 349 String fullName; | 351 String fullName; |
| 350 | 352 |
| 351 TestSource(this.fullName); | 353 TestSource(this.fullName); |
| 352 | 354 |
| 353 @override | 355 @override |
| 354 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 356 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 355 } | 357 } |
| OLD | NEW |