| 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; | 5 library test.domain.analysis.abstract; |
| 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'; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 * An abstract base for all 'analysis' domain tests. | 39 * An abstract base for all 'analysis' domain tests. |
| 40 */ | 40 */ |
| 41 class AbstractAnalysisTest { | 41 class AbstractAnalysisTest { |
| 42 MockServerChannel serverChannel; | 42 MockServerChannel serverChannel; |
| 43 MemoryResourceProvider resourceProvider; | 43 MemoryResourceProvider resourceProvider; |
| 44 MockPackageMapProvider packageMapProvider; | 44 MockPackageMapProvider packageMapProvider; |
| 45 AnalysisServer server; | 45 AnalysisServer server; |
| 46 RequestHandler handler; | 46 RequestHandler handler; |
| 47 | 47 |
| 48 final List<ServerErrorParams> serverErrors = <ServerErrorParams>[]; | 48 final List<ServerErrorParams> serverErrors = <ServerErrorParams>[]; |
| 49 final List<GeneralAnalysisService> generalServices = |
| 50 <GeneralAnalysisService>[]; |
| 49 final Map<AnalysisService, List<String>> analysisSubscriptions = {}; | 51 final Map<AnalysisService, List<String>> analysisSubscriptions = {}; |
| 50 | 52 |
| 51 String projectPath = '/project'; | 53 String projectPath = '/project'; |
| 52 String testFolder = '/project/bin/'; | 54 String testFolder = '/project/bin/'; |
| 53 String testFile = '/project/bin/test.dart'; | 55 String testFile = '/project/bin/test.dart'; |
| 54 String testCode; | 56 String testCode; |
| 55 | 57 |
| 56 AbstractAnalysisTest(); | 58 AbstractAnalysisTest(); |
| 57 | 59 |
| 58 void addAnalysisSubscription(AnalysisService service, String file) { | 60 void addAnalysisSubscription(AnalysisService service, String file) { |
| 59 // add file to subscription | 61 // add file to subscription |
| 60 var files = analysisSubscriptions[service]; | 62 var files = analysisSubscriptions[service]; |
| 61 if (files == null) { | 63 if (files == null) { |
| 62 files = <String>[]; | 64 files = <String>[]; |
| 63 analysisSubscriptions[service] = files; | 65 analysisSubscriptions[service] = files; |
| 64 } | 66 } |
| 65 files.add(file); | 67 files.add(file); |
| 66 // set subscriptions | 68 // set subscriptions |
| 67 Request request = new AnalysisSetSubscriptionsParams(analysisSubscriptions) | 69 Request request = new AnalysisSetSubscriptionsParams(analysisSubscriptions) |
| 68 .toRequest('0'); | 70 .toRequest('0'); |
| 69 handleSuccessfulRequest(request); | 71 handleSuccessfulRequest(request); |
| 70 } | 72 } |
| 71 | 73 |
| 72 String addFile(String path, String content) { | 74 String addFile(String path, String content) { |
| 73 resourceProvider.newFile(path, content); | 75 resourceProvider.newFile(path, content); |
| 74 return path; | 76 return path; |
| 75 } | 77 } |
| 76 | 78 |
| 79 void addGeneralAnalysisSubscription(GeneralAnalysisService service) { |
| 80 generalServices.add(service); |
| 81 Request request = new AnalysisSetGeneralSubscriptionsParams(generalServices) |
| 82 .toRequest('0'); |
| 83 handleSuccessfulRequest(request); |
| 84 } |
| 85 |
| 77 String addTestFile(String content) { | 86 String addTestFile(String content) { |
| 78 addFile(testFile, content); | 87 addFile(testFile, content); |
| 79 this.testCode = content; | 88 this.testCode = content; |
| 80 return testFile; | 89 return testFile; |
| 81 } | 90 } |
| 82 | 91 |
| 83 AnalysisServer createAnalysisServer(Index index) { | 92 AnalysisServer createAnalysisServer(Index index) { |
| 84 ExtensionManager manager = new ExtensionManager(); | 93 ExtensionManager manager = new ExtensionManager(); |
| 85 ServerPlugin serverPlugin = new ServerPlugin(); | 94 ServerPlugin serverPlugin = new ServerPlugin(); |
| 86 manager.processPlugins([serverPlugin]); | 95 manager.processPlugins([serverPlugin]); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 } | 187 } |
| 179 | 188 |
| 180 /** | 189 /** |
| 181 * Completes with a successful [Response] for the given [request]. | 190 * Completes with a successful [Response] for the given [request]. |
| 182 * Otherwise fails. | 191 * Otherwise fails. |
| 183 */ | 192 */ |
| 184 Future<Response> waitResponse(Request request) async { | 193 Future<Response> waitResponse(Request request) async { |
| 185 return serverChannel.sendRequest(request); | 194 return serverChannel.sendRequest(request); |
| 186 } | 195 } |
| 187 } | 196 } |
| OLD | NEW |