| 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 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:analysis_server/src/channel.dart'; |
| 11 import 'package:analysis_server/src/protocol.dart'; |
| 12 |
| 10 /** | 13 /** |
| 11 * A mock [WebSocket] for testing. | 14 * A mock [WebSocket] for testing. |
| 12 */ | 15 */ |
| 13 class MockSocket<T> implements WebSocket { | 16 class MockSocket<T> implements WebSocket { |
| 14 | 17 |
| 15 StreamController controller = new StreamController(); | 18 StreamController controller = new StreamController(); |
| 16 MockSocket twin; | 19 MockSocket twin; |
| 17 Stream stream; | 20 Stream stream; |
| 18 | 21 |
| 19 factory MockSocket.pair() { | 22 factory MockSocket.pair() { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 39 | 42 |
| 40 StreamSubscription<T> listen(void onData(T event), | 43 StreamSubscription<T> listen(void onData(T event), |
| 41 { Function onError, void onDone(), bool cancelOnError}) => | 44 { Function onError, void onDone(), bool cancelOnError}) => |
| 42 stream.listen(onData, onError: onError, onDone: onDone, | 45 stream.listen(onData, onError: onError, onDone: onDone, |
| 43 cancelOnError: cancelOnError); | 46 cancelOnError: cancelOnError); |
| 44 | 47 |
| 45 Stream<T> where(bool test(T)) => stream.where(test); | 48 Stream<T> where(bool test(T)) => stream.where(test); |
| 46 | 49 |
| 47 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 50 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 48 } | 51 } |
| 52 |
| 53 /** |
| 54 * A mock [ServerCommunicationChannel] channel that does nothing. |
| 55 */ |
| 56 class MockServerChannel implements ServerCommunicationChannel { |
| 57 @override |
| 58 void listen(void onRequest(Request request), {void onError(), void onDone()})
{ |
| 59 } |
| 60 |
| 61 @override |
| 62 void sendNotification(Notification notification) { |
| 63 } |
| 64 |
| 65 @override |
| 66 void sendResponse(Response response) { |
| 67 } |
| 68 } |
| OLD | NEW |