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

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

Issue 182903005: split client and server channels (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address comments Created 6 years, 9 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/channel_test.dart ('k') | pkg/analysis_server/test/protocol_test.dart » ('j') | 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 'package:analysis_server/src/channel.dart'; 7 import 'dart:io';
8 import 'dart:async';
8 9
9 /** 10 /**
10 * Instances of the class [MockChannel] implement a [CommunicationChannel] that 11 * A mock [WebSocket] that immediately passes data to the listener.
11 * does nothing in response to every method invoked on it.
12 */ 12 */
13 class MockChannel implements CommunicationChannel { 13 class MockSocket<T> implements WebSocket {
14 dynamic noSuchMethod(Invocation invocation) { 14 var onData;
15 // Do nothing 15 StreamSubscription<T> listen(void onData(T event),
16 {Function onError, void onDone(), bool cancelOnError}) {
17 this.onData = onData;
16 return null; 18 return null;
17 } 19 }
20 void add(T event) => onData(event);
21 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
18 } 22 }
23
24 /**
25 * A mock [WebSocket] for sending invalid JSON data and counting responses.
26 */
27 class InvalidJsonMockSocket<T> implements WebSocket {
28 int responseCount = 0;
29 var onData;
30 StreamSubscription<T> listen(void onData(T event),
31 {Function onError, void onDone(), bool cancelOnError}) {
32 this.onData = onData;
33 return null;
34 }
35 void addInvalid(T event) => onData(event);
36 void add(T event) { responseCount++; }
37 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
38 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/channel_test.dart ('k') | pkg/analysis_server/test/protocol_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698