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

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

Issue 307533004: Send 'notification.errors' for all non-SDK files. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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
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 @MirrorsUsed(targets: 'mocks', override: '*') 10 @MirrorsUsed(targets: 'mocks', override: '*')
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 Future pumpEventQueue([int times = 20]) { 44 Future pumpEventQueue([int times = 20]) {
45 if (times == 0) return new Future.value(); 45 if (times == 0) return new Future.value();
46 // We use a delayed future to allow microtask events to finish. The 46 // We use a delayed future to allow microtask events to finish. The
47 // Future.value or Future() constructors use scheduleMicrotask themselves and 47 // Future.value or Future() constructors use scheduleMicrotask themselves and
48 // would therefore not wait for microtask callbacks that are scheduled after 48 // would therefore not wait for microtask callbacks that are scheduled after
49 // invoking this method. 49 // invoking this method.
50 return new Future.delayed(Duration.ZERO, () => pumpEventQueue(times - 1)); 50 return new Future.delayed(Duration.ZERO, () => pumpEventQueue(times - 1));
51 } 51 }
52 52
53 /** 53 /**
54 * Returns a [Future] that completes when the given [AnalysisServer] finished
55 * all its scheduled tasks.
56 */
57 Future waitForServerTasksFinished(AnalysisServer server) {
58 if (server.test_areTasksFinished()) {
59 return new Future.value();
60 }
61 // We use a delayed future to allow microtask events to finish. The
62 // Future.value or Future() constructors use scheduleMicrotask themselves and
63 // would therefore not wait for microtask callbacks that are scheduled after
64 // invoking this method.
65 return new Future.delayed(Duration.ZERO,
66 () => waitForServerTasksFinished(server));
67 }
68
69 /**
54 * A mock [WebSocket] for testing. 70 * A mock [WebSocket] for testing.
55 */ 71 */
56 class MockSocket<T> implements WebSocket { 72 class MockSocket<T> implements WebSocket {
57 StreamController controller = new StreamController(); 73 StreamController controller = new StreamController();
58 MockSocket twin; 74 MockSocket twin;
59 Stream stream; 75 Stream stream;
60 76
61 factory MockSocket.pair() { 77 factory MockSocket.pair() {
62 MockSocket socket1 = new MockSocket(); 78 MockSocket socket1 = new MockSocket();
63 MockSocket socket2 = new MockSocket(); 79 MockSocket socket2 = new MockSocket();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 Response response = item; 294 Response response = item;
279 var id = response.id; 295 var id = response.id;
280 RequestError error = response.error; 296 RequestError error = response.error;
281 mismatchDescription.add('has identifier "$id"'); 297 mismatchDescription.add('has identifier "$id"');
282 if (error == null) { 298 if (error == null) {
283 mismatchDescription.add(' and has no error'); 299 mismatchDescription.add(' and has no error');
284 } 300 }
285 return mismatchDescription; 301 return mismatchDescription;
286 } 302 }
287 } 303 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698