| 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.analysis.abstract; | |
| 6 | |
| 7 import 'dart:async'; | 5 import 'dart:async'; |
| 8 | 6 |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart' | 7 import 'package:analysis_server/plugin/protocol/protocol.dart' |
| 10 hide AnalysisOptions; | 8 hide AnalysisOptions; |
| 11 import 'package:analysis_server/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
| 12 import 'package:analysis_server/src/constants.dart'; | 10 import 'package:analysis_server/src/constants.dart'; |
| 13 import 'package:analysis_server/src/domain_analysis.dart'; | 11 import 'package:analysis_server/src/domain_analysis.dart'; |
| 12 import 'package:analysis_server/src/plugin/notification_manager.dart'; |
| 13 import 'package:analysis_server/src/plugin/plugin_manager.dart'; |
| 14 import 'package:analysis_server/src/plugin/server_plugin.dart'; | 14 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
| 15 import 'package:analysis_server/src/provisional/completion/dart/completion_plugi
n.dart'; | 15 import 'package:analysis_server/src/provisional/completion/dart/completion_plugi
n.dart'; |
| 16 import 'package:analysis_server/src/services/index/index.dart'; | 16 import 'package:analysis_server/src/services/index/index.dart'; |
| 17 import 'package:analyzer/context/context_root.dart' as analyzer; |
| 17 import 'package:analyzer/file_system/file_system.dart'; | 18 import 'package:analyzer/file_system/file_system.dart'; |
| 18 import 'package:analyzer/file_system/memory_file_system.dart'; | 19 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 19 import 'package:analyzer/instrumentation/instrumentation.dart'; | 20 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 20 import 'package:analyzer/src/dart/analysis/driver.dart'; | 21 import 'package:analyzer/src/dart/analysis/driver.dart'; |
| 21 import 'package:analyzer/src/generated/engine.dart'; | 22 import 'package:analyzer/src/generated/engine.dart'; |
| 22 import 'package:analyzer/src/generated/sdk.dart'; | 23 import 'package:analyzer/src/generated/sdk.dart'; |
| 24 import 'package:analyzer_plugin/protocol/protocol.dart' as plugin; |
| 25 import 'package:analyzer_plugin/src/protocol/protocol_internal.dart' as plugin; |
| 23 import 'package:plugin/manager.dart'; | 26 import 'package:plugin/manager.dart'; |
| 24 import 'package:plugin/plugin.dart'; | 27 import 'package:plugin/plugin.dart'; |
| 25 import 'package:test/test.dart'; | 28 import 'package:test/test.dart'; |
| 26 | 29 |
| 27 import 'mock_sdk.dart'; | 30 import 'mock_sdk.dart'; |
| 28 import 'mocks.dart'; | 31 import 'mocks.dart'; |
| 29 | 32 |
| 30 int findIdentifierLength(String search) { | 33 int findIdentifierLength(String search) { |
| 31 int length = 0; | 34 int length = 0; |
| 32 while (length < search.length) { | 35 while (length < search.length) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 44 | 47 |
| 45 /** | 48 /** |
| 46 * An abstract base for all 'analysis' domain tests. | 49 * An abstract base for all 'analysis' domain tests. |
| 47 */ | 50 */ |
| 48 class AbstractAnalysisTest { | 51 class AbstractAnalysisTest { |
| 49 bool enableNewAnalysisDriver = false; | 52 bool enableNewAnalysisDriver = false; |
| 50 bool generateSummaryFiles = false; | 53 bool generateSummaryFiles = false; |
| 51 MockServerChannel serverChannel; | 54 MockServerChannel serverChannel; |
| 52 MemoryResourceProvider resourceProvider; | 55 MemoryResourceProvider resourceProvider; |
| 53 MockPackageMapProvider packageMapProvider; | 56 MockPackageMapProvider packageMapProvider; |
| 57 TestPluginManager pluginManager; |
| 54 AnalysisServer server; | 58 AnalysisServer server; |
| 55 RequestHandler handler; | 59 RequestHandler handler; |
| 56 | 60 |
| 57 final List<ServerErrorParams> serverErrors = <ServerErrorParams>[]; | 61 final List<ServerErrorParams> serverErrors = <ServerErrorParams>[]; |
| 58 final List<GeneralAnalysisService> generalServices = | 62 final List<GeneralAnalysisService> generalServices = |
| 59 <GeneralAnalysisService>[]; | 63 <GeneralAnalysisService>[]; |
| 60 final Map<AnalysisService, List<String>> analysisSubscriptions = {}; | 64 final Map<AnalysisService, List<String>> analysisSubscriptions = {}; |
| 61 | 65 |
| 62 String projectPath; | 66 String projectPath; |
| 63 String testFolder; | 67 String testFolder; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 handleSuccessfulRequest(request); | 221 handleSuccessfulRequest(request); |
| 218 } | 222 } |
| 219 | 223 |
| 220 void setUp() { | 224 void setUp() { |
| 221 serverChannel = new MockServerChannel(); | 225 serverChannel = new MockServerChannel(); |
| 222 resourceProvider = new MemoryResourceProvider(); | 226 resourceProvider = new MemoryResourceProvider(); |
| 223 projectPath = resourceProvider.convertPath('/project'); | 227 projectPath = resourceProvider.convertPath('/project'); |
| 224 testFolder = resourceProvider.convertPath('/project/bin'); | 228 testFolder = resourceProvider.convertPath('/project/bin'); |
| 225 testFile = resourceProvider.convertPath('/project/bin/test.dart'); | 229 testFile = resourceProvider.convertPath('/project/bin/test.dart'); |
| 226 packageMapProvider = new MockPackageMapProvider(); | 230 packageMapProvider = new MockPackageMapProvider(); |
| 231 pluginManager = new TestPluginManager(); |
| 227 Index index = createIndex(); | 232 Index index = createIndex(); |
| 228 server = createAnalysisServer(index); | 233 server = createAnalysisServer(index); |
| 234 server.pluginManager = pluginManager; |
| 229 handler = analysisHandler; | 235 handler = analysisHandler; |
| 230 // listen for notifications | 236 // listen for notifications |
| 231 Stream<Notification> notificationStream = | 237 Stream<Notification> notificationStream = |
| 232 serverChannel.notificationController.stream; | 238 serverChannel.notificationController.stream; |
| 233 notificationStream.listen((Notification notification) { | 239 notificationStream.listen((Notification notification) { |
| 234 processNotification(notification); | 240 processNotification(notification); |
| 235 }); | 241 }); |
| 236 } | 242 } |
| 237 | 243 |
| 238 void tearDown() { | 244 void tearDown() { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 251 } | 257 } |
| 252 | 258 |
| 253 /** | 259 /** |
| 254 * Completes with a successful [Response] for the given [request]. | 260 * Completes with a successful [Response] for the given [request]. |
| 255 * Otherwise fails. | 261 * Otherwise fails. |
| 256 */ | 262 */ |
| 257 Future<Response> waitResponse(Request request) async { | 263 Future<Response> waitResponse(Request request) async { |
| 258 return serverChannel.sendRequest(request); | 264 return serverChannel.sendRequest(request); |
| 259 } | 265 } |
| 260 } | 266 } |
| 267 |
| 268 /** |
| 269 * A plugin manager that simulates broadcasting requests to plugins by |
| 270 * hard-coding the responses. |
| 271 */ |
| 272 class TestPluginManager implements PluginManager { |
| 273 Map<PluginInfo, Future<plugin.Response>> broadcastResults; |
| 274 |
| 275 @override |
| 276 String get byteStorePath { |
| 277 fail('Unexpected invocation of byteStorePath'); |
| 278 return null; |
| 279 } |
| 280 |
| 281 @override |
| 282 InstrumentationService get instrumentationService { |
| 283 fail('Unexpected invocation of instrumentationService'); |
| 284 return null; |
| 285 } |
| 286 |
| 287 @override |
| 288 NotificationManager get notificationManager { |
| 289 fail('Unexpected invocation of notificationManager'); |
| 290 return null; |
| 291 } |
| 292 |
| 293 @override |
| 294 ResourceProvider get resourceProvider { |
| 295 fail('Unexpected invocation of resourceProvider'); |
| 296 return null; |
| 297 } |
| 298 |
| 299 @override |
| 300 Future<Null> addPluginToContextRoot( |
| 301 analyzer.ContextRoot contextRoot, String path) async { |
| 302 fail('Unexpected invocation of addPluginToContextRoot'); |
| 303 return null; |
| 304 } |
| 305 |
| 306 @override |
| 307 Map<PluginInfo, Future<plugin.Response>> broadcast( |
| 308 analyzer.ContextRoot contextRoot, plugin.RequestParams params) { |
| 309 return broadcastResults ?? <PluginInfo, Future<plugin.Response>>{}; |
| 310 } |
| 311 |
| 312 @override |
| 313 List<PluginInfo> pluginsForContextRoot(analyzer.ContextRoot contextRoot) { |
| 314 fail('Unexpected invocation of pluginsForContextRoot'); |
| 315 return null; |
| 316 } |
| 317 |
| 318 @override |
| 319 void removedContextRoot(analyzer.ContextRoot contextRoot) { |
| 320 fail('Unexpected invocation of removedContextRoot'); |
| 321 } |
| 322 |
| 323 @override |
| 324 Future<List<Null>> stopAll() async { |
| 325 fail('Unexpected invocation of stopAll'); |
| 326 return null; |
| 327 } |
| 328 } |
| OLD | NEW |