| 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 @MirrorsUsed(targets: 'mocks', override: '*') | 10 @MirrorsUsed(targets: 'mocks', override: '*') |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 54 * Returns a [Future] that completes when the given [AnalysisServer] finished |
| 55 * all its scheduled tasks. | 55 * all its scheduled tasks. |
| 56 */ | 56 */ |
| 57 Future waitForServerTasksFinished(AnalysisServer server) { | 57 Future waitForServerOperationsPerformed(AnalysisServer server) { |
| 58 if (server.test_areTasksFinished()) { | 58 if (server.test_areOperationsFinished()) { |
| 59 return new Future.value(); | 59 return new Future.value(); |
| 60 } | 60 } |
| 61 // We use a delayed future to allow microtask events to finish. The | 61 // We use a delayed future to allow microtask events to finish. The |
| 62 // Future.value or Future() constructors use scheduleMicrotask themselves and | 62 // Future.value or Future() constructors use scheduleMicrotask themselves and |
| 63 // would therefore not wait for microtask callbacks that are scheduled after | 63 // would therefore not wait for microtask callbacks that are scheduled after |
| 64 // invoking this method. | 64 // invoking this method. |
| 65 return new Future.delayed(Duration.ZERO, | 65 return new Future.delayed(Duration.ZERO, |
| 66 () => waitForServerTasksFinished(server)); | 66 () => waitForServerOperationsPerformed(server)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * A mock [WebSocket] for testing. | 70 * A mock [WebSocket] for testing. |
| 71 */ | 71 */ |
| 72 class MockSocket<T> implements WebSocket { | 72 class MockSocket<T> implements WebSocket { |
| 73 StreamController controller = new StreamController(); | 73 StreamController controller = new StreamController(); |
| 74 MockSocket twin; | 74 MockSocket twin; |
| 75 Stream stream; | 75 Stream stream; |
| 76 | 76 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 Response response = item; | 296 Response response = item; |
| 297 var id = response.id; | 297 var id = response.id; |
| 298 RequestError error = response.error; | 298 RequestError error = response.error; |
| 299 mismatchDescription.add('has identifier "$id"'); | 299 mismatchDescription.add('has identifier "$id"'); |
| 300 if (error == null) { | 300 if (error == null) { |
| 301 mismatchDescription.add(' and has no error'); | 301 mismatchDescription.add(' and has no error'); |
| 302 } | 302 } |
| 303 return mismatchDescription; | 303 return mismatchDescription; |
| 304 } | 304 } |
| 305 } | 305 } |
| OLD | NEW |