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/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
10 import 'package:analysis_server/src/constants.dart'; | 10 import 'package:analysis_server/src/constants.dart'; |
11 import 'package:analysis_server/src/domain_execution.dart'; | 11 import 'package:analysis_server/src/domain_execution.dart'; |
| 12 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
12 import 'package:analysis_server/src/protocol.dart'; | 13 import 'package:analysis_server/src/protocol.dart'; |
13 import 'package:analyzer/file_system/file_system.dart'; | 14 import 'package:analyzer/file_system/file_system.dart'; |
14 import 'package:analyzer/file_system/memory_file_system.dart'; | 15 import 'package:analyzer/file_system/memory_file_system.dart'; |
15 import 'package:analyzer/instrumentation/instrumentation.dart'; | 16 import 'package:analyzer/instrumentation/instrumentation.dart'; |
16 import 'package:analyzer/src/generated/engine.dart'; | 17 import 'package:analyzer/src/generated/engine.dart'; |
17 import 'package:analyzer/src/generated/source.dart'; | 18 import 'package:analyzer/src/generated/source.dart'; |
18 import 'package:analyzer/src/generated/source_io.dart'; | 19 import 'package:analyzer/src/generated/source_io.dart'; |
| 20 import 'package:plugin/manager.dart'; |
19 import 'package:typed_mock/typed_mock.dart'; | 21 import 'package:typed_mock/typed_mock.dart'; |
20 import 'package:unittest/unittest.dart'; | 22 import 'package:unittest/unittest.dart'; |
21 | 23 |
22 import 'mock_sdk.dart'; | 24 import 'mock_sdk.dart'; |
23 import 'mocks.dart'; | 25 import 'mocks.dart'; |
24 import 'operation/operation_queue_test.dart'; | 26 import 'operation/operation_queue_test.dart'; |
25 | 27 |
26 /** | |
27 * Return a matcher that will match an [ExecutableFile] if it has the given | |
28 * [source] and [kind]. | |
29 */ | |
30 Matcher isExecutableFile(Source source, ExecutableKind kind) { | |
31 return new IsExecutableFile(source.fullName, kind); | |
32 } | |
33 | |
34 main() { | 28 main() { |
35 group('ExecutionDomainHandler', () { | 29 group('ExecutionDomainHandler', () { |
36 MemoryResourceProvider provider = new MemoryResourceProvider(); | 30 MemoryResourceProvider provider = new MemoryResourceProvider(); |
37 AnalysisServer server; | 31 AnalysisServer server; |
38 ExecutionDomainHandler handler; | 32 ExecutionDomainHandler handler; |
39 | 33 |
40 setUp(() { | 34 setUp(() { |
| 35 ExtensionManager manager = new ExtensionManager(); |
| 36 ServerPlugin serverPlugin = new ServerPlugin(); |
| 37 manager.processPlugins([serverPlugin]); |
41 server = new AnalysisServer(new MockServerChannel(), provider, | 38 server = new AnalysisServer(new MockServerChannel(), provider, |
42 new MockPackageMapProvider(), null, new AnalysisServerOptions(), | 39 new MockPackageMapProvider(), null, serverPlugin, |
43 new MockSdk(), InstrumentationService.NULL_SERVICE); | 40 new AnalysisServerOptions(), new MockSdk(), |
| 41 InstrumentationService.NULL_SERVICE); |
44 handler = new ExecutionDomainHandler(server); | 42 handler = new ExecutionDomainHandler(server); |
45 }); | 43 }); |
46 | 44 |
47 group('createContext/deleteContext', () { | 45 group('createContext/deleteContext', () { |
48 test('create/delete multiple contexts', () { | 46 test('create/delete multiple contexts', () { |
49 Request request = | 47 Request request = |
50 new ExecutionCreateContextParams('/a/b.dart').toRequest('0'); | 48 new ExecutionCreateContextParams('/a/b.dart').toRequest('0'); |
51 Response response = handler.handleRequest(request); | 49 Response response = handler.handleRequest(request); |
52 expect(response, isResponseSuccess('0')); | 50 expect(response, isResponseSuccess('0')); |
53 ExecutionCreateContextResult result = | 51 ExecutionCreateContextResult result = |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 StreamController controller = new StreamController.broadcast(sync: true); | 235 StreamController controller = new StreamController.broadcast(sync: true); |
238 when(server.onFileAnalyzed).thenReturn(controller.stream); | 236 when(server.onFileAnalyzed).thenReturn(controller.stream); |
239 | 237 |
240 List<String> unsentNotifications = <String>[ | 238 List<String> unsentNotifications = <String>[ |
241 source1.fullName, | 239 source1.fullName, |
242 source2.fullName, | 240 source2.fullName, |
243 source3.fullName, | 241 source3.fullName, |
244 source4.fullName, | 242 source4.fullName, |
245 source5.fullName | 243 source5.fullName |
246 ]; | 244 ]; |
247 when(server.sendNotification(anyObject)).thenInvoke( | 245 when(server.sendNotification(anyObject)) |
248 (Notification notification) { | 246 .thenInvoke((Notification notification) { |
249 ExecutionLaunchDataParams params = | 247 ExecutionLaunchDataParams params = |
250 new ExecutionLaunchDataParams.fromNotification(notification); | 248 new ExecutionLaunchDataParams.fromNotification(notification); |
251 | 249 |
252 String fileName = params.file; | 250 String fileName = params.file; |
253 expect(unsentNotifications.remove(fileName), isTrue); | 251 expect(unsentNotifications.remove(fileName), isTrue); |
254 | 252 |
255 if (fileName == source1.fullName) { | 253 if (fileName == source1.fullName) { |
256 expect(params.kind, ExecutableKind.CLIENT); | 254 expect(params.kind, ExecutableKind.CLIENT); |
257 } else if (fileName == source2.fullName) { | 255 } else if (fileName == source2.fullName) { |
258 expect(params.kind, ExecutableKind.EITHER); | 256 expect(params.kind, ExecutableKind.EITHER); |
(...skipping 16 matching lines...) Expand all Loading... |
275 .toRequest('0'); | 273 .toRequest('0'); |
276 handler.handleRequest(request); | 274 handler.handleRequest(request); |
277 | 275 |
278 // controller.add(null); | 276 // controller.add(null); |
279 expect(unsentNotifications, isEmpty); | 277 expect(unsentNotifications, isEmpty); |
280 }); | 278 }); |
281 }); | 279 }); |
282 } | 280 } |
283 | 281 |
284 /** | 282 /** |
| 283 * Return a matcher that will match an [ExecutableFile] if it has the given |
| 284 * [source] and [kind]. |
| 285 */ |
| 286 Matcher isExecutableFile(Source source, ExecutableKind kind) { |
| 287 return new IsExecutableFile(source.fullName, kind); |
| 288 } |
| 289 |
| 290 /** |
285 * A matcher that will match an [ExecutableFile] if it has a specified [source] | 291 * A matcher that will match an [ExecutableFile] if it has a specified [source] |
286 * and [kind]. | 292 * and [kind]. |
287 */ | 293 */ |
288 class IsExecutableFile extends Matcher { | 294 class IsExecutableFile extends Matcher { |
289 String expectedFile; | 295 String expectedFile; |
290 ExecutableKind expectedKind; | 296 ExecutableKind expectedKind; |
291 | 297 |
292 IsExecutableFile(this.expectedFile, this.expectedKind); | 298 IsExecutableFile(this.expectedFile, this.expectedKind); |
293 | 299 |
294 @override | 300 @override |
(...skipping 14 matching lines...) Expand all Loading... |
309 * A [Source] that knows it's [fullName]. | 315 * A [Source] that knows it's [fullName]. |
310 */ | 316 */ |
311 class TestSource implements Source { | 317 class TestSource implements Source { |
312 String fullName; | 318 String fullName; |
313 | 319 |
314 TestSource(this.fullName); | 320 TestSource(this.fullName); |
315 | 321 |
316 @override | 322 @override |
317 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 323 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
318 } | 324 } |
OLD | NEW |