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

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

Issue 187603010: gracefully degrade with response to client if fail to access client specified dart sdk (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: take 2 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/lib/src/protocol.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 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert';
9 import 'dart:io'; 8 import 'dart:io';
10 9
11 /** 10 /**
12 * A mock [WebSocket] for testing. 11 * A mock [WebSocket] for testing.
13 */ 12 */
14 class MockSocket<T> implements WebSocket { 13 class MockSocket<T> implements WebSocket {
15 14
16 final JsonEncoder jsonEncoder = const JsonEncoder(null);
17
18 final JsonDecoder jsonDecoder = const JsonDecoder(null);
19
20 StreamController controller = new StreamController(); 15 StreamController controller = new StreamController();
21 MockSocket twin; 16 MockSocket twin;
22 Stream stream; 17 Stream stream;
23 18
24 factory MockSocket.pair() { 19 factory MockSocket.pair() {
25 MockSocket socket1 = new MockSocket(); 20 MockSocket socket1 = new MockSocket();
26 MockSocket socket2 = new MockSocket(); 21 MockSocket socket2 = new MockSocket();
27 socket1.twin = socket2; 22 socket1.twin = socket2;
28 socket2.twin = socket1; 23 socket2.twin = socket1;
29 socket1.stream = socket2.controller.stream; 24 socket1.stream = socket2.controller.stream;
(...skipping 13 matching lines...) Expand all
43 .then((_) => twin.controller.close()); 38 .then((_) => twin.controller.close());
44 39
45 StreamSubscription<T> listen(void onData(T event), 40 StreamSubscription<T> listen(void onData(T event),
46 { Function onError, void onDone(), bool cancelOnError}) => 41 { Function onError, void onDone(), bool cancelOnError}) =>
47 stream.listen(onData, onError: onError, onDone: onDone, 42 stream.listen(onData, onError: onError, onDone: onDone,
48 cancelOnError: cancelOnError); 43 cancelOnError: cancelOnError);
49 44
50 Stream<T> where(bool test(T)) => stream.where(test); 45 Stream<T> where(bool test(T)) => stream.where(test);
51 46
52 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 47 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
53 } 48 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/protocol.dart ('k') | pkg/analysis_server/test/protocol_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698