Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Side by Side Diff: pkg/analysis_server/test/analysis_abstract.dart

Issue 2404733002: Fix more tests on windows bots (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/plugin/protocol/protocol.dart'; 9 import 'package:analysis_server/plugin/protocol/protocol.dart';
10 import 'package:analysis_server/src/analysis_server.dart'; 10 import 'package:analysis_server/src/analysis_server.dart';
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 MemoryResourceProvider resourceProvider; 50 MemoryResourceProvider resourceProvider;
51 MockPackageMapProvider packageMapProvider; 51 MockPackageMapProvider packageMapProvider;
52 AnalysisServer server; 52 AnalysisServer server;
53 RequestHandler handler; 53 RequestHandler handler;
54 54
55 final List<ServerErrorParams> serverErrors = <ServerErrorParams>[]; 55 final List<ServerErrorParams> serverErrors = <ServerErrorParams>[];
56 final List<GeneralAnalysisService> generalServices = 56 final List<GeneralAnalysisService> generalServices =
57 <GeneralAnalysisService>[]; 57 <GeneralAnalysisService>[];
58 final Map<AnalysisService, List<String>> analysisSubscriptions = {}; 58 final Map<AnalysisService, List<String>> analysisSubscriptions = {};
59 59
60 String projectPath = '/project'; 60 String projectPath;
61 String testFolder = '/project/bin'; 61 String testFolder;
62 String testFile = '/project/bin/test.dart'; 62 String testFile;
63 String testCode; 63 String testCode;
64 64
65 AbstractAnalysisTest(); 65 AbstractAnalysisTest();
66 66
67 AnalysisDomainHandler get analysisHandler => server.handlers 67 AnalysisDomainHandler get analysisHandler => server.handlers
68 .singleWhere((handler) => handler is AnalysisDomainHandler); 68 .singleWhere((handler) => handler is AnalysisDomainHandler);
69 69
70 AnalysisContext get testContext => server.getAnalysisContext(testFile); 70 AnalysisContext get testContext => server.getAnalysisContext(testFile);
71 71
72 void addAnalysisSubscription(AnalysisService service, String file) { 72 void addAnalysisSubscription(AnalysisService service, String file) {
73 // add file to subscription 73 // add file to subscription
74 var files = analysisSubscriptions[service]; 74 var files = analysisSubscriptions[service];
75 if (files == null) { 75 if (files == null) {
76 files = <String>[]; 76 files = <String>[];
77 analysisSubscriptions[service] = files; 77 analysisSubscriptions[service] = files;
78 } 78 }
79 files.add(file); 79 files.add(file);
80 // set subscriptions 80 // set subscriptions
81 Request request = new AnalysisSetSubscriptionsParams(analysisSubscriptions) 81 Request request = new AnalysisSetSubscriptionsParams(analysisSubscriptions)
82 .toRequest('0'); 82 .toRequest('0');
83 handleSuccessfulRequest(request); 83 handleSuccessfulRequest(request);
84 } 84 }
85 85
86 String addFile(String path, String content) { 86 String addFile(String path, String content) {
87 path = resourceProvider.convertPath(path);
87 resourceProvider.newFile(path, content); 88 resourceProvider.newFile(path, content);
88 return path; 89 return path;
89 } 90 }
90 91
91 void addGeneralAnalysisSubscription(GeneralAnalysisService service) { 92 void addGeneralAnalysisSubscription(GeneralAnalysisService service) {
92 generalServices.add(service); 93 generalServices.add(service);
93 Request request = new AnalysisSetGeneralSubscriptionsParams(generalServices) 94 Request request = new AnalysisSetGeneralSubscriptionsParams(generalServices)
94 .toRequest('0'); 95 .toRequest('0');
95 handleSuccessfulRequest(request); 96 handleSuccessfulRequest(request);
96 } 97 }
(...skipping 29 matching lines...) Expand all
126 // Create server 127 // Create server
127 // 128 //
128 MockSdk sdk = new MockSdk(resourceProvider: resourceProvider); 129 MockSdk sdk = new MockSdk(resourceProvider: resourceProvider);
129 return new AnalysisServer( 130 return new AnalysisServer(
130 serverChannel, 131 serverChannel,
131 resourceProvider, 132 resourceProvider,
132 packageMapProvider, 133 packageMapProvider,
133 index, 134 index,
134 serverPlugin, 135 serverPlugin,
135 new AnalysisServerOptions(), 136 new AnalysisServerOptions(),
136 new DartSdkManager('/', false, (_) => sdk), 137 new DartSdkManager(
138 resourceProvider.convertPath('/'), false, (_) => sdk),
137 InstrumentationService.NULL_SERVICE); 139 InstrumentationService.NULL_SERVICE);
138 } 140 }
139 141
140 Index createIndex() { 142 Index createIndex() {
141 return null; 143 return null;
142 } 144 }
143 145
144 /** 146 /**
145 * Creates a project `/project`. 147 * Creates a project `/project`.
146 */ 148 */
147 void createProject({Map<String, String> packageRoots}) { 149 void createProject({Map<String, String> packageRoots}) {
148 resourceProvider.newFolder(projectPath); 150 resourceProvider.newFolder(projectPath);
149 Request request = 151 Request request = new AnalysisSetAnalysisRootsParams([projectPath], [],
150 new AnalysisSetAnalysisRootsParams([projectPath], [], packageRoots: pack ageRoots).toRequest('0'); 152 packageRoots: packageRoots)
153 .toRequest('0');
151 handleSuccessfulRequest(request, handler: analysisHandler); 154 handleSuccessfulRequest(request, handler: analysisHandler);
152 } 155 }
153 156
154 /** 157 /**
155 * Returns the offset of [search] in [testCode]. 158 * Returns the offset of [search] in [testCode].
156 * Fails if not found. 159 * Fails if not found.
157 */ 160 */
158 int findFileOffset(String path, String search) { 161 int findFileOffset(String path, String search) {
159 File file = resourceProvider.getResource(path) as File; 162 File file = resourceProvider.getResource(path) as File;
160 String code = file.createSource().contents.data; 163 String code = file.createSource().contents.data;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 void removeGeneralAnalysisSubscription(GeneralAnalysisService service) { 202 void removeGeneralAnalysisSubscription(GeneralAnalysisService service) {
200 generalServices.remove(service); 203 generalServices.remove(service);
201 Request request = new AnalysisSetGeneralSubscriptionsParams(generalServices) 204 Request request = new AnalysisSetGeneralSubscriptionsParams(generalServices)
202 .toRequest('0'); 205 .toRequest('0');
203 handleSuccessfulRequest(request); 206 handleSuccessfulRequest(request);
204 } 207 }
205 208
206 void setUp() { 209 void setUp() {
207 serverChannel = new MockServerChannel(); 210 serverChannel = new MockServerChannel();
208 resourceProvider = new MemoryResourceProvider(); 211 resourceProvider = new MemoryResourceProvider();
212 projectPath = resourceProvider.convertPath('/project');
213 testFolder = resourceProvider.convertPath('/project/bin');
214 testFile = resourceProvider.convertPath('/project/bin/test.dart');
209 packageMapProvider = new MockPackageMapProvider(); 215 packageMapProvider = new MockPackageMapProvider();
210 Index index = createIndex(); 216 Index index = createIndex();
211 server = createAnalysisServer(index); 217 server = createAnalysisServer(index);
212 handler = analysisHandler; 218 handler = analysisHandler;
213 // listen for notifications 219 // listen for notifications
214 Stream<Notification> notificationStream = 220 Stream<Notification> notificationStream =
215 serverChannel.notificationController.stream; 221 serverChannel.notificationController.stream;
216 notificationStream.listen((Notification notification) { 222 notificationStream.listen((Notification notification) {
217 processNotification(notification); 223 processNotification(notification);
218 }); 224 });
(...skipping 15 matching lines...) Expand all
234 } 240 }
235 241
236 /** 242 /**
237 * Completes with a successful [Response] for the given [request]. 243 * Completes with a successful [Response] for the given [request].
238 * Otherwise fails. 244 * Otherwise fails.
239 */ 245 */
240 Future<Response> waitResponse(Request request) async { 246 Future<Response> waitResponse(Request request) async {
241 return serverChannel.sendRequest(request); 247 return serverChannel.sendRequest(request);
242 } 248 }
243 } 249 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698