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 import 'package:analysis_server/protocol/protocol.dart'; | 5 import 'package:analysis_server/protocol/protocol.dart'; |
6 import 'package:analysis_server/protocol/protocol_constants.dart'; | 6 import 'package:analysis_server/protocol/protocol_constants.dart'; |
7 import 'package:analysis_server/protocol/protocol_generated.dart'; | 7 import 'package:analysis_server/protocol/protocol_generated.dart'; |
8 import 'package:analysis_server/src/analysis_server.dart'; | 8 import 'package:analysis_server/src/analysis_server.dart'; |
9 import 'package:analysis_server/src/constants.dart'; | 9 import 'package:analysis_server/src/constants.dart'; |
10 import 'package:analysis_server/src/domain_server.dart'; | 10 import 'package:analysis_server/src/domain_server.dart'; |
11 import 'package:analysis_server/src/plugin/server_plugin.dart'; | 11 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
12 import 'package:analyzer/file_system/memory_file_system.dart'; | 12 import 'package:analyzer/file_system/memory_file_system.dart'; |
13 import 'package:analyzer/instrumentation/instrumentation.dart'; | 13 import 'package:analyzer/instrumentation/instrumentation.dart'; |
14 import 'package:analyzer/src/generated/sdk.dart'; | 14 import 'package:analyzer/src/generated/sdk.dart'; |
15 import 'package:plugin/manager.dart'; | 15 import 'package:plugin/manager.dart'; |
16 import 'package:test/test.dart'; | 16 import 'package:test/test.dart'; |
17 | 17 |
18 import 'mocks.dart'; | 18 import 'mocks.dart'; |
19 | 19 |
20 main() { | 20 main() { |
21 AnalysisServer server; | 21 AnalysisServer server; |
22 ServerDomainHandler handler; | 22 ServerDomainHandler handler; |
| 23 MockServerChannel serverChannel; |
23 | 24 |
24 setUp(() { | 25 setUp(() { |
25 var serverChannel = new MockServerChannel(); | 26 serverChannel = new MockServerChannel(); |
26 var resourceProvider = new MemoryResourceProvider(); | 27 var resourceProvider = new MemoryResourceProvider(); |
27 ExtensionManager manager = new ExtensionManager(); | 28 ExtensionManager manager = new ExtensionManager(); |
28 ServerPlugin serverPlugin = new ServerPlugin(); | 29 ServerPlugin serverPlugin = new ServerPlugin(); |
29 manager.processPlugins([serverPlugin]); | 30 manager.processPlugins([serverPlugin]); |
30 server = new AnalysisServer( | 31 server = new AnalysisServer( |
31 serverChannel, | 32 serverChannel, |
32 resourceProvider, | 33 resourceProvider, |
33 new MockPackageMapProvider(), | 34 new MockPackageMapProvider(), |
34 serverPlugin, | 35 serverPlugin, |
35 new AnalysisServerOptions(), | 36 new AnalysisServerOptions(), |
(...skipping 29 matching lines...) Expand all Loading... |
65 Request request = | 66 Request request = |
66 new ServerSetSubscriptionsParams([ServerService.STATUS]) | 67 new ServerSetSubscriptionsParams([ServerService.STATUS]) |
67 .toRequest('0'); | 68 .toRequest('0'); |
68 var response = handler.handleRequest(request); | 69 var response = handler.handleRequest(request); |
69 expect(response, isResponseSuccess('0')); | 70 expect(response, isResponseSuccess('0')); |
70 // set of services has been changed | 71 // set of services has been changed |
71 expect(server.serverServices, contains(ServerService.STATUS)); | 72 expect(server.serverServices, contains(ServerService.STATUS)); |
72 }); | 73 }); |
73 }); | 74 }); |
74 | 75 |
75 test('shutdown', () { | 76 test('shutdown', () async { |
76 expect(server.running, isTrue); | 77 expect(server.running, isTrue); |
77 // send request | 78 // send request |
78 var request = new ServerShutdownParams().toRequest('0'); | 79 var request = new ServerShutdownParams().toRequest('0'); |
79 var response = handler.handleRequest(request); | 80 var response = await serverChannel.sendRequest(request); |
80 expect(response, isResponseSuccess('0')); | 81 expect(response, isResponseSuccess('0')); |
| 82 |
81 // server is down | 83 // server is down |
82 expect(server.running, isFalse); | 84 expect(server.running, isFalse); |
83 }); | 85 }); |
84 }); | 86 }); |
85 } | 87 } |
OLD | NEW |