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 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:analysis_server/protocol/protocol.dart'; | 7 import 'package:analysis_server/protocol/protocol.dart'; |
8 import 'package:analysis_server/protocol/protocol_constants.dart'; | 8 import 'package:analysis_server/protocol/protocol_constants.dart'; |
9 import 'package:analysis_server/protocol/protocol_generated.dart'; | 9 import 'package:analysis_server/protocol/protocol_generated.dart'; |
10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
11 import 'package:analysis_server/src/domain_server.dart'; | 11 import 'package:analysis_server/src/domain_server.dart'; |
12 import 'package:analysis_server/src/plugin/server_plugin.dart'; | |
13 import 'package:analyzer/file_system/file_system.dart'; | 12 import 'package:analyzer/file_system/file_system.dart'; |
14 import 'package:analyzer/file_system/memory_file_system.dart'; | 13 import 'package:analyzer/file_system/memory_file_system.dart'; |
15 import 'package:analyzer/instrumentation/instrumentation.dart'; | 14 import 'package:analyzer/instrumentation/instrumentation.dart'; |
16 import 'package:analyzer/src/generated/engine.dart'; | 15 import 'package:analyzer/src/generated/engine.dart'; |
17 import 'package:analyzer/src/generated/sdk.dart'; | 16 import 'package:analyzer/src/generated/sdk.dart'; |
18 import 'package:analyzer_plugin/protocol/protocol_common.dart'; | 17 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
19 import 'package:plugin/manager.dart'; | 18 import 'package:plugin/manager.dart'; |
20 import 'package:plugin/plugin.dart'; | 19 import 'package:plugin/plugin.dart'; |
21 import 'package:test/test.dart'; | 20 import 'package:test/test.dart'; |
22 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 21 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 break; | 78 break; |
80 default: | 79 default: |
81 if (!notificationTypesReceived.add(notificationType)) { | 80 if (!notificationTypesReceived.add(notificationType)) { |
82 fail('Notification type $notificationType received more than once'); | 81 fail('Notification type $notificationType received more than once'); |
83 } | 82 } |
84 break; | 83 break; |
85 } | 84 } |
86 } | 85 } |
87 } | 86 } |
88 | 87 |
89 void processRequiredPlugins(ServerPlugin serverPlugin) { | 88 void processRequiredPlugins() { |
90 List<Plugin> plugins = <Plugin>[]; | 89 List<Plugin> plugins = <Plugin>[]; |
91 plugins.addAll(AnalysisEngine.instance.requiredPlugins); | 90 plugins.addAll(AnalysisEngine.instance.requiredPlugins); |
92 plugins.add(serverPlugin); | |
93 | 91 |
94 ExtensionManager manager = new ExtensionManager(); | 92 ExtensionManager manager = new ExtensionManager(); |
95 manager.processPlugins(plugins); | 93 manager.processPlugins(plugins); |
96 } | 94 } |
97 | 95 |
98 void setUp() { | 96 void setUp() { |
99 ServerPlugin serverPlugin = new ServerPlugin(); | 97 processRequiredPlugins(); |
100 processRequiredPlugins(serverPlugin); | |
101 channel = new MockServerChannel(); | 98 channel = new MockServerChannel(); |
102 resourceProvider = new MemoryResourceProvider(); | 99 resourceProvider = new MemoryResourceProvider(); |
103 // Create an SDK in the mock file system. | 100 // Create an SDK in the mock file system. |
104 new MockSdk(resourceProvider: resourceProvider); | 101 new MockSdk(resourceProvider: resourceProvider); |
105 packageMapProvider = new MockPackageMapProvider(); | 102 packageMapProvider = new MockPackageMapProvider(); |
106 server = new AnalysisServer( | 103 server = new AnalysisServer( |
107 channel, | 104 channel, |
108 resourceProvider, | 105 resourceProvider, |
109 packageMapProvider, | 106 packageMapProvider, |
110 serverPlugin, | |
111 new AnalysisServerOptions(), | 107 new AnalysisServerOptions(), |
112 new DartSdkManager('/', false), | 108 new DartSdkManager('/', false), |
113 InstrumentationService.NULL_SERVICE); | 109 InstrumentationService.NULL_SERVICE); |
114 } | 110 } |
115 | 111 |
116 Future test_echo() { | 112 Future test_echo() { |
117 server.handlers = [new EchoHandler()]; | 113 server.handlers = [new EchoHandler()]; |
118 var request = new Request('my22', 'echo'); | 114 var request = new Request('my22', 'echo'); |
119 return channel.sendRequest(request).then((Response response) { | 115 return channel.sendRequest(request).then((Response response) { |
120 expect(response.id, equals('my22')); | 116 expect(response.id, equals('my22')); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 205 |
210 class EchoHandler implements RequestHandler { | 206 class EchoHandler implements RequestHandler { |
211 @override | 207 @override |
212 Response handleRequest(Request request) { | 208 Response handleRequest(Request request) { |
213 if (request.method == 'echo') { | 209 if (request.method == 'echo') { |
214 return new Response(request.id, result: {'echo': true}); | 210 return new Response(request.id, result: {'echo': true}); |
215 } | 211 } |
216 return null; | 212 return null; |
217 } | 213 } |
218 } | 214 } |
OLD | NEW |