OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:io' as io; | 6 import 'dart:io' as io; |
7 | 7 |
8 import 'package:analysis_server/src/plugin/notification_manager.dart'; | 8 import 'package:analysis_server/src/plugin/notification_manager.dart'; |
9 import 'package:analysis_server/src/plugin/plugin_manager.dart'; | 9 import 'package:analysis_server/src/plugin/plugin_manager.dart'; |
10 import 'package:analyzer/context/context_root.dart'; | 10 import 'package:analyzer/context/context_root.dart'; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 io.Directory pkg1Dir = io.Directory.systemTemp.createTempSync('pkg1'); | 121 io.Directory pkg1Dir = io.Directory.systemTemp.createTempSync('pkg1'); |
122 String pkgPath = pkg1Dir.resolveSymbolicLinksSync(); | 122 String pkgPath = pkg1Dir.resolveSymbolicLinksSync(); |
123 await withPlugin(test: (String pluginPath) async { | 123 await withPlugin(test: (String pluginPath) async { |
124 ContextRoot contextRoot = new ContextRoot(pkgPath, []); | 124 ContextRoot contextRoot = new ContextRoot(pkgPath, []); |
125 await manager.addPluginToContextRoot(contextRoot, pluginPath); | 125 await manager.addPluginToContextRoot(contextRoot, pluginPath); |
126 await manager.stopAll(); | 126 await manager.stopAll(); |
127 }); | 127 }); |
128 pkg1Dir.deleteSync(recursive: true); | 128 pkg1Dir.deleteSync(recursive: true); |
129 } | 129 } |
130 | 130 |
131 test_broadcast_many() async { | 131 test_broadcastRequest_many() async { |
132 io.Directory pkg1Dir = io.Directory.systemTemp.createTempSync('pkg1'); | 132 io.Directory pkg1Dir = io.Directory.systemTemp.createTempSync('pkg1'); |
133 String pkgPath = pkg1Dir.resolveSymbolicLinksSync(); | 133 String pkgPath = pkg1Dir.resolveSymbolicLinksSync(); |
134 await withPlugin( | 134 await withPlugin( |
135 pluginName: 'plugin1', | 135 pluginName: 'plugin1', |
136 test: (String plugin1Path) async { | 136 test: (String plugin1Path) async { |
137 await withPlugin( | 137 await withPlugin( |
138 pluginName: 'plugin2', | 138 pluginName: 'plugin2', |
139 test: (String plugin2Path) async { | 139 test: (String plugin2Path) async { |
140 ContextRoot contextRoot = new ContextRoot(pkgPath, []); | 140 ContextRoot contextRoot = new ContextRoot(pkgPath, []); |
141 await manager.addPluginToContextRoot(contextRoot, plugin1Path); | 141 await manager.addPluginToContextRoot(contextRoot, plugin1Path); |
142 await manager.addPluginToContextRoot(contextRoot, plugin2Path); | 142 await manager.addPluginToContextRoot(contextRoot, plugin2Path); |
143 | 143 |
144 Map<PluginInfo, Future<Response>> responses = | 144 Map<PluginInfo, Future<Response>> responses = |
145 manager.broadcastRequest( | 145 manager.broadcastRequest( |
146 contextRoot, | |
147 new CompletionGetSuggestionsParams( | 146 new CompletionGetSuggestionsParams( |
148 '/pkg1/lib/pkg1.dart', 100)); | 147 '/pkg1/lib/pkg1.dart', 100), |
| 148 contextRoot: contextRoot); |
149 expect(responses, hasLength(2)); | 149 expect(responses, hasLength(2)); |
150 | 150 |
151 await manager.stopAll(); | 151 await manager.stopAll(); |
| 152 }); |
| 153 }); |
| 154 pkg1Dir.deleteSync(recursive: true); |
| 155 } |
| 156 |
| 157 test_broadcastRequest_many_noContextRoot() async { |
| 158 io.Directory pkg1Dir = io.Directory.systemTemp.createTempSync('pkg1'); |
| 159 String pkgPath = pkg1Dir.resolveSymbolicLinksSync(); |
| 160 await withPlugin( |
| 161 pluginName: 'plugin1', |
| 162 test: (String plugin1Path) async { |
| 163 await withPlugin( |
| 164 pluginName: 'plugin2', |
| 165 test: (String plugin2Path) async { |
| 166 ContextRoot contextRoot = new ContextRoot(pkgPath, []); |
| 167 await manager.addPluginToContextRoot(contextRoot, plugin1Path); |
| 168 await manager.addPluginToContextRoot(contextRoot, plugin2Path); |
| 169 |
| 170 Map<PluginInfo, Future<Response>> responses = |
| 171 manager.broadcastRequest(new CompletionGetSuggestionsParams( |
| 172 '/pkg1/lib/pkg1.dart', 100)); |
| 173 expect(responses, hasLength(2)); |
| 174 |
| 175 await manager.stopAll(); |
152 }); | 176 }); |
153 }); | 177 }); |
154 pkg1Dir.deleteSync(recursive: true); | 178 pkg1Dir.deleteSync(recursive: true); |
155 } | 179 } |
156 | 180 |
157 test_broadcastWatchEvent() async { | 181 test_broadcastWatchEvent() async { |
158 io.Directory pkg1Dir = io.Directory.systemTemp.createTempSync('pkg1'); | 182 io.Directory pkg1Dir = io.Directory.systemTemp.createTempSync('pkg1'); |
159 String pkgPath = pkg1Dir.resolveSymbolicLinksSync(); | 183 String pkgPath = pkg1Dir.resolveSymbolicLinksSync(); |
160 await withPlugin( | 184 await withPlugin( |
161 pluginName: 'plugin1', | 185 pluginName: 'plugin1', |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 resourceProvider = new MemoryResourceProvider(); | 270 resourceProvider = new MemoryResourceProvider(); |
247 byteStorePath = '/byteStore'; | 271 byteStorePath = '/byteStore'; |
248 notificationManager = new TestNotificationManager(); | 272 notificationManager = new TestNotificationManager(); |
249 manager = new PluginManager(resourceProvider, byteStorePath, | 273 manager = new PluginManager(resourceProvider, byteStorePath, |
250 notificationManager, InstrumentationService.NULL_SERVICE); | 274 notificationManager, InstrumentationService.NULL_SERVICE); |
251 } | 275 } |
252 | 276 |
253 void test_broadcastRequest_none() { | 277 void test_broadcastRequest_none() { |
254 ContextRoot contextRoot = new ContextRoot('/pkg1', []); | 278 ContextRoot contextRoot = new ContextRoot('/pkg1', []); |
255 Map<PluginInfo, Future<Response>> responses = manager.broadcastRequest( | 279 Map<PluginInfo, Future<Response>> responses = manager.broadcastRequest( |
256 contextRoot, | 280 new CompletionGetSuggestionsParams('/pkg1/lib/pkg1.dart', 100), |
257 new CompletionGetSuggestionsParams('/pkg1/lib/pkg1.dart', 100)); | 281 contextRoot: contextRoot); |
258 expect(responses, hasLength(0)); | 282 expect(responses, hasLength(0)); |
259 } | 283 } |
260 | 284 |
261 void test_creation() { | 285 void test_creation() { |
262 expect(manager.resourceProvider, resourceProvider); | 286 expect(manager.resourceProvider, resourceProvider); |
263 expect(manager.byteStorePath, byteStorePath); | 287 expect(manager.byteStorePath, byteStorePath); |
264 expect(manager.notificationManager, notificationManager); | 288 expect(manager.notificationManager, notificationManager); |
265 } | 289 } |
266 | 290 |
267 void test_pluginsForContextRoot_none() { | 291 void test_pluginsForContextRoot_none() { |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 void onNotification(Notification notification), | 603 void onNotification(Notification notification), |
580 {Function onError, void onDone()}) { | 604 {Function onError, void onDone()}) { |
581 fail('Unexpected invocation of listen'); | 605 fail('Unexpected invocation of listen'); |
582 } | 606 } |
583 | 607 |
584 @override | 608 @override |
585 void sendRequest(Request request) { | 609 void sendRequest(Request request) { |
586 sentRequests.add(request); | 610 sentRequests.add(request); |
587 } | 611 } |
588 } | 612 } |
OLD | NEW |