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

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

Issue 246603005: Use AnalysisServer.running only to track whether server has been shut down. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/test/analysis_server_test.dart ('k') | 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 mocks; 5 library mocks;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:analyzer/src/generated/ast.dart';
11 import 'package:analyzer/src/generated/element.dart';
10 import 'package:analyzer/src/generated/engine.dart'; 12 import 'package:analyzer/src/generated/engine.dart';
13 import 'package:analyzer/src/generated/error.dart';
14 import 'package:analyzer/src/generated/html.dart';
11 import 'package:analyzer/src/generated/source.dart'; 15 import 'package:analyzer/src/generated/source.dart';
16 import 'package:analysis_server/src/analysis_logger.dart';
12 import 'package:analysis_server/src/analysis_server.dart'; 17 import 'package:analysis_server/src/analysis_server.dart';
13 import 'package:analysis_server/src/channel.dart'; 18 import 'package:analysis_server/src/channel.dart';
14 import 'package:analysis_server/src/protocol.dart'; 19 import 'package:analysis_server/src/protocol.dart';
15 import 'package:matcher/matcher.dart'; 20 import 'package:matcher/matcher.dart';
21 import 'package:unittest/unittest.dart';
16 22
17 /** 23 /**
18 * Answer the absolute path the the SDK relative to the currently running 24 * Answer the absolute path the the SDK relative to the currently running
19 * script or throw an exception if it cannot be found. 25 * script or throw an exception if it cannot be found.
20 */ 26 */
21 String get sdkPath { 27 String get sdkPath {
22 Uri sdkUri = Platform.script.resolve('../../../sdk/'); 28 Uri sdkUri = Platform.script.resolve('../../../sdk/');
23 29
24 // Verify the directory exists 30 // Verify the directory exists
25 Directory sdkDir = new Directory.fromUri(sdkUri); 31 Directory sdkDir = new Directory.fromUri(sdkUri);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 responsesReceived.add(response); 142 responsesReceived.add(response);
137 // Wrap send response in future to simulate websocket 143 // Wrap send response in future to simulate websocket
138 new Future(() => responseController.add(response)); 144 new Future(() => responseController.add(response));
139 } 145 }
140 146
141 void expectMsgCount({responseCount: 0, notificationCount: 0}) { 147 void expectMsgCount({responseCount: 0, notificationCount: 0}) {
142 expect(responsesReceived, hasLength(responseCount)); 148 expect(responsesReceived, hasLength(responseCount));
143 expect(notificationsReceived, hasLength(notificationCount)); 149 expect(notificationsReceived, hasLength(notificationCount));
144 } 150 }
145 } 151 }
152
153 /**
154 * Exception thrown when an unexpected function call is made on a mock.
155 */
156 class UnexpectedMockCall extends Error {
157 String toString() => "Unexpected call to mocked function";
158 }
159
160 /**
161 * Shorthand function for throwing an UnexpectedMockCall exception.
162 */
163 _unexpected() {
164 throw new UnexpectedMockCall();
165 }
166
167 /**
168 * A mock [AnalysisLogger] that treats all errors and warnings as unexpected.
169 */
170 class MockAnalysisLogger extends Logger {
Brian Wilkerson 2014/04/22 22:46:03 Try the following @proxy class MockAnalysisLogger
Paul Berry 2014/04/23 18:36:26 Done, thanks.
171
172 void logError(String message) {
173 print(message);
174 _unexpected();
175 }
176
177 @override
178 void logError2(String message, Exception exception) => _unexpected();
179
180 @override
181 void logInformation(String message) => _unexpected();
182
183 @override
184 void logInformation2(String message, Exception exception) => _unexpected();
185 }
186
187 /**
188 * A mock [AnalysisContext] for testing [AnalysisServer]. This class raises an
189 * exception for every abstract method in [AnalysisContext]. Tests should
190 * derive from this and re-implement the methods they need.
191 */
192 class MockAnalysisContext extends AnalysisContext {
Brian Wilkerson 2014/04/22 22:46:03 Likewise: @proxy class MockAnalysisContext implem
193
194 @override
195 AnalysisOptions get analysisOptions => _unexpected();
196
197 @override
198 void set analysisOptions(AnalysisOptions options) => _unexpected();
199
200 @override
201 void set analysisPriorityOrder(List<Source> sources) => _unexpected();
202
203 @override
204 void applyChanges(ChangeSet changeSet) => _unexpected();
205
206 @override
207 String computeDocumentationComment(Element element) => _unexpected();
208
209 @override
210 List<AnalysisError> computeErrors(Source source) => _unexpected();
211
212 @override
213 HtmlElement computeHtmlElement(Source source) => _unexpected();
214
215 @override
216 SourceKind computeKindOf(Source source) => _unexpected();
217
218 @override
219 LibraryElement computeLibraryElement(Source source) => _unexpected();
220
221 @override
222 LineInfo computeLineInfo(Source source) => _unexpected();
223
224 @override
225 void dispose() => _unexpected();
226
227 @override
228 bool exists(Source source) => _unexpected();
229
230 @override
231 AnalysisContext extractContext(SourceContainer container) => _unexpected();
232
233 @override
234 AngularApplication getAngularApplicationWithHtml(Source htmlSource) =>
235 _unexpected();
236
237 @override
238 CompilationUnitElement getCompilationUnitElement(Source unitSource, Source
239 librarySource) => _unexpected();
240
241 @override
242 TimestampedData<String> getContents(Source source) => _unexpected();
243
244 @override
245 Element getElement(ElementLocation location) => _unexpected();
246
247 @override
248 AnalysisErrorInfo getErrors(Source source) => _unexpected();
249
250 @override
251 HtmlElement getHtmlElement(Source source) => _unexpected();
252
253 @override
254 List<Source> getHtmlFilesReferencing(Source source) => _unexpected();
255
256 @override
257 SourceKind getKindOf(Source source) => _unexpected();
258
259 @override
260 List<Source> getLibrariesContaining(Source source) => _unexpected();
261
262 @override
263 List<Source> getLibrariesDependingOn(Source librarySource) => _unexpected();
264
265 @override
266 List<Source> getLibrariesReferencedFromHtml(Source htmlSource) => _unexpected( );
267
268 @override
269 LibraryElement getLibraryElement(Source source) => _unexpected();
270
271 @override
272 LineInfo getLineInfo(Source source) => _unexpected();
273
274 @override
275 int getModificationStamp(Source source) => _unexpected();
276
277 @override
278 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement
279 library) => _unexpected();
280
281 @override
282 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source
283 librarySource) => _unexpected();
284
285 @override
286 HtmlUnit getResolvedHtmlUnit(Source htmlSource) => _unexpected();
287
288 @override
289 List<Source> get htmlSources => _unexpected();
290
291 @override
292 bool isClientLibrary(Source librarySource) => _unexpected();
293
294 @override
295 bool get isDisposed => _unexpected();
296
297 @override
298 bool isServerLibrary(Source librarySource) => _unexpected();
299
300 @override
301 List<Source> get launchableClientLibrarySources => _unexpected();
302
303 @override
304 List<Source> get launchableServerLibrarySources => _unexpected();
305
306 @override
307 List<Source> get librarySources => _unexpected();
308
309 @override
310 void mergeContext(AnalysisContext context) => _unexpected();
311
312 @override
313 CompilationUnit parseCompilationUnit(Source source) => _unexpected();
314
315 @override
316 HtmlUnit parseHtmlUnit(Source source) => _unexpected();
317
318 @override
319 AnalysisResult performAnalysisTask() => _unexpected();
320
321 @override
322 List<Source> get refactoringUnsafeSources => _unexpected();
323
324 @override
325 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement
326 library) => _unexpected();
327
328 @override
329 CompilationUnit resolveCompilationUnit2(Source unitSource, Source
330 librarySource) => _unexpected();
331
332 @override
333 HtmlUnit resolveHtmlUnit(Source htmlSource) => _unexpected();
334
335 @override
336 void setChangedContents(Source source, String contents, int offset, int
337 oldLength, int newLength) => _unexpected();
338
339 @override
340 void setContents(Source source, String contents) => _unexpected();
341
342 @override
343 SourceFactory get sourceFactory => _unexpected();
344
345 @override
346 void set sourceFactory(SourceFactory factory) => _unexpected();
347 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/analysis_server_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698