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

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

Issue 1900503002: More steps toward making server strong mode clean (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « pkg/analysis_server/lib/src/watch_manager.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 @MirrorsUsed(targets: 'mocks', override: '*')
10 import 'dart:mirrors'; 9 import 'dart:mirrors';
11 10
12 import 'package:analysis_server/plugin/protocol/protocol.dart' 11 import 'package:analysis_server/plugin/protocol/protocol.dart'
13 hide Element, ElementKind; 12 hide Element, ElementKind;
14 import 'package:analysis_server/src/analysis_server.dart'; 13 import 'package:analysis_server/src/analysis_server.dart';
15 import 'package:analysis_server/src/channel/channel.dart'; 14 import 'package:analysis_server/src/channel/channel.dart';
16 import 'package:analysis_server/src/operation/operation.dart'; 15 import 'package:analysis_server/src/operation/operation.dart';
17 import 'package:analysis_server/src/operation/operation_analysis.dart'; 16 import 'package:analysis_server/src/operation/operation_analysis.dart';
18 import 'package:analyzer/dart/element/element.dart'; 17 import 'package:analyzer/dart/element/element.dart';
19 import 'package:analyzer/file_system/file_system.dart' as resource; 18 import 'package:analyzer/file_system/file_system.dart' as resource;
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 bool get isContinue => false; 275 bool get isContinue => false;
277 276
278 @override 277 @override
279 void perform(AnalysisServer server) => this._perform(server); 278 void perform(AnalysisServer server) => this._perform(server);
280 } 279 }
281 280
282 /** 281 /**
283 * A mock [WebSocket] for testing. 282 * A mock [WebSocket] for testing.
284 */ 283 */
285 class MockSocket<T> implements WebSocket { 284 class MockSocket<T> implements WebSocket {
286 StreamController controller = new StreamController(); 285 StreamController<T> controller = new StreamController<T>();
287 MockSocket twin; 286 MockSocket<T> twin;
288 Stream stream; 287 Stream<T> stream;
289 288
290 MockSocket(); 289 MockSocket();
291 290
292 factory MockSocket.pair() { 291 factory MockSocket.pair() {
293 MockSocket socket1 = new MockSocket(); 292 MockSocket<T> socket1 = new MockSocket<T>();
294 MockSocket socket2 = new MockSocket(); 293 MockSocket<T> socket2 = new MockSocket<T>();
295 socket1.twin = socket2; 294 socket1.twin = socket2;
296 socket2.twin = socket1; 295 socket2.twin = socket1;
297 socket1.stream = socket2.controller.stream; 296 socket1.stream = socket2.controller.stream;
298 socket2.stream = socket1.controller.stream; 297 socket2.stream = socket1.controller.stream;
299 return socket1; 298 return socket1;
300 } 299 }
301 300
302 void add(T text) => controller.add(text); 301 void add(T text) => controller.add(text);
303 302
304 void allowMultipleListeners() { 303 void allowMultipleListeners() {
305 stream = stream.asBroadcastStream(); 304 stream = stream.asBroadcastStream();
306 } 305 }
307 306
308 Future close([int code, String reason]) => 307 Future close([int code, String reason]) =>
309 controller.close().then((_) => twin.controller.close()); 308 controller.close().then((_) => twin.controller.close());
310 309
311 StreamSubscription<T> listen(void onData(T event), 310 StreamSubscription<T> listen(void onData(T event),
312 {Function onError, void onDone(), bool cancelOnError}) => 311 {Function onError, void onDone(), bool cancelOnError}) =>
313 stream.listen(onData, 312 stream.listen(onData,
314 onError: onError, onDone: onDone, cancelOnError: cancelOnError); 313 onError: onError, onDone: onDone, cancelOnError: cancelOnError);
315 314
316 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 315 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
317 316
318 Stream<T> where(bool test(T)) => stream.where(test); 317 Stream<T> where(bool test(T t)) => stream.where(test);
319 } 318 }
320 319
321 class MockSource extends StringTypedMock implements Source { 320 class MockSource extends StringTypedMock implements Source {
322 MockSource([String name = 'mocked.dart']) : super(name); 321 MockSource([String name = 'mocked.dart']) : super(name);
323 } 322 }
324 323
325 class MockTopLevelVariableElement extends TypedMock 324 class MockTopLevelVariableElement extends TypedMock
326 implements TopLevelVariableElement { 325 implements TopLevelVariableElement {
327 final ElementKind kind = ElementKind.TOP_LEVEL_VARIABLE; 326 final ElementKind kind = ElementKind.TOP_LEVEL_VARIABLE;
328 } 327 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 } 436 }
438 return mismatchDescription; 437 return mismatchDescription;
439 } 438 }
440 439
441 @override 440 @override
442 bool matches(item, Map matchState) { 441 bool matches(item, Map matchState) {
443 Response response = item; 442 Response response = item;
444 return response != null && response.id == _id && response.error == null; 443 return response != null && response.id == _id && response.error == null;
445 } 444 }
446 } 445 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/watch_manager.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698