| 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 @MirrorsUsed(targets: 'mocks', override: '*') | 7 @MirrorsUsed(targets: 'mocks', override: '*') |
| 8 import 'dart:mirrors'; | 8 import 'dart:mirrors'; |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 * A [Matcher] that check that the given [Response] has an expected identifier | 51 * A [Matcher] that check that the given [Response] has an expected identifier |
| 52 * and no error. | 52 * and no error. |
| 53 */ | 53 */ |
| 54 Matcher isResponseSuccess(String id) => new _IsResponseSuccess(id); | 54 Matcher isResponseSuccess(String id) => new _IsResponseSuccess(id); |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * Returns a [Future] that completes after pumping the event queue [times] | 57 * Returns a [Future] that completes after pumping the event queue [times] |
| 58 * times. By default, this should pump the event queue enough times to allow | 58 * times. By default, this should pump the event queue enough times to allow |
| 59 * any code to run, as long as it's not waiting on some external event. | 59 * any code to run, as long as it's not waiting on some external event. |
| 60 */ | 60 */ |
| 61 Future pumpEventQueue([int times = 20]) { | 61 Future pumpEventQueue([int times = 50]) { |
| 62 if (times == 0) return new Future.value(); | 62 if (times == 0) return new Future.value(); |
| 63 // We use a delayed future to allow microtask events to finish. The | 63 // We use a delayed future to allow microtask events to finish. The |
| 64 // Future.value or Future() constructors use scheduleMicrotask themselves and | 64 // Future.value or Future() constructors use scheduleMicrotask themselves and |
| 65 // would therefore not wait for microtask callbacks that are scheduled after | 65 // would therefore not wait for microtask callbacks that are scheduled after |
| 66 // invoking this method. | 66 // invoking this method. |
| 67 return new Future.delayed(Duration.ZERO, () => pumpEventQueue(times - 1)); | 67 return new Future.delayed(Duration.ZERO, () => pumpEventQueue(times - 1)); |
| 68 } | 68 } |
| 69 | 69 |
| 70 /** | 70 /** |
| 71 * Returns a [Future] that completes when the given [AnalysisServer] finished | 71 * Returns a [Future] that completes when the given [AnalysisServer] finished |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 | 316 |
| 317 MockServerOperation(this.priority, this._perform); | 317 MockServerOperation(this.priority, this._perform); |
| 318 | 318 |
| 319 @override | 319 @override |
| 320 AnalysisContext get context => null; | 320 AnalysisContext get context => null; |
| 321 | 321 |
| 322 @override | 322 @override |
| 323 bool get isContinue => false; | 323 bool get isContinue => false; |
| 324 | 324 |
| 325 @override | 325 @override |
| 326 void perform(AnalysisServer server) => this._perform(server); | 326 bool get isPriority => null; |
| 327 | 327 |
| 328 @override | 328 @override |
| 329 void sendNotices(AnalysisServer server, List<ChangeNotice> notices) { | 329 void perform(AnalysisServer server) => this._perform(server); |
| 330 } | |
| 331 | |
| 332 @override | |
| 333 void updateIndex(AnalysisServer server, List<ChangeNotice> notices) { | |
| 334 } | |
| 335 } | 330 } |
| 336 | 331 |
| 337 | 332 |
| 338 /** | 333 /** |
| 339 * A mock [WebSocket] for testing. | 334 * A mock [WebSocket] for testing. |
| 340 */ | 335 */ |
| 341 class MockSocket<T> implements WebSocket { | 336 class MockSocket<T> implements WebSocket { |
| 342 StreamController controller = new StreamController(); | 337 StreamController controller = new StreamController(); |
| 343 MockSocket twin; | 338 MockSocket twin; |
| 344 Stream stream; | 339 Stream stream; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 } | 501 } |
| 507 return mismatchDescription; | 502 return mismatchDescription; |
| 508 } | 503 } |
| 509 | 504 |
| 510 @override | 505 @override |
| 511 bool matches(item, Map matchState) { | 506 bool matches(item, Map matchState) { |
| 512 Response response = item; | 507 Response response = item; |
| 513 return response != null && response.id == _id && response.error == null; | 508 return response != null && response.id == _id && response.error == null; |
| 514 } | 509 } |
| 515 } | 510 } |
| OLD | NEW |