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

Side by Side Diff: test/utils.dart

Issue 2515303002: Add expectAsyncX and expectAsyncUntilX methods, and deprecate the old methods. (Closed)
Patch Set: Mark parameter types as Object. Created 4 years 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
« no previous file with comments | « test/util/stream_queue_test.dart ('k') | no next file » | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:collection'; 6 import 'dart:collection';
7 7
8 import 'package:test/src/backend/declarer.dart'; 8 import 'package:test/src/backend/declarer.dart';
9 import 'package:test/src/backend/group.dart'; 9 import 'package:test/src/backend/group.dart';
10 import 'package:test/src/backend/group_entry.dart'; 10 import 'package:test/src/backend/group_entry.dart';
(...skipping 17 matching lines...) Expand all
28 final String closureString = (() {}).toString(); 28 final String closureString = (() {}).toString();
29 29
30 // The last state change detected via [expectStates]. 30 // The last state change detected via [expectStates].
31 State lastState; 31 State lastState;
32 32
33 /// Asserts that exactly [states] will be emitted via [liveTest.onStateChange]. 33 /// Asserts that exactly [states] will be emitted via [liveTest.onStateChange].
34 /// 34 ///
35 /// The most recent emitted state is stored in [_lastState]. 35 /// The most recent emitted state is stored in [_lastState].
36 void expectStates(LiveTest liveTest, Iterable<State> statesIter) { 36 void expectStates(LiveTest liveTest, Iterable<State> statesIter) {
37 var states = new Queue.from(statesIter); 37 var states = new Queue.from(statesIter);
38 liveTest.onStateChange.listen(expectAsync((state) { 38 liveTest.onStateChange.listen(expectAsync1((state) {
39 lastState = state; 39 lastState = state;
40 expect(state, equals(states.removeFirst())); 40 expect(state, equals(states.removeFirst()));
41 }, count: states.length, max: states.length)); 41 }, count: states.length, max: states.length));
42 } 42 }
43 43
44 /// Asserts that errors will be emitted via [liveTest.onError] that match 44 /// Asserts that errors will be emitted via [liveTest.onError] that match
45 /// [validators], in order. 45 /// [validators], in order.
46 void expectErrors(LiveTest liveTest, Iterable<Function> validatorsIter) { 46 void expectErrors(LiveTest liveTest, Iterable<Function> validatorsIter) {
47 var validators = new Queue.from(validatorsIter); 47 var validators = new Queue.from(validatorsIter);
48 liveTest.onError.listen(expectAsync((error) { 48 liveTest.onError.listen(expectAsync1((error) {
49 validators.removeFirst()(error.error); 49 validators.removeFirst()(error.error);
50 }, count: validators.length, max: validators.length)); 50 }, count: validators.length, max: validators.length));
51 } 51 }
52 52
53 /// Asserts that [liveTest] will have a single failure with message `"oh no"`. 53 /// Asserts that [liveTest] will have a single failure with message `"oh no"`.
54 void expectSingleFailure(LiveTest liveTest) { 54 void expectSingleFailure(LiveTest liveTest) {
55 expectStates(liveTest, [ 55 expectStates(liveTest, [
56 const State(Status.running, Result.success), 56 const State(Status.running, Result.success),
57 const State(Status.complete, Result.failure) 57 const State(Status.complete, Result.failure)
58 ]); 58 ]);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 new RunnerSuite( 312 new RunnerSuite(
313 const PluginEnvironment(), 313 const PluginEnvironment(),
314 new SuiteConfiguration(runSkipped: runSkipped), 314 new SuiteConfiguration(runSkipped: runSkipped),
315 declarer.build()) 315 declarer.build())
316 ]); 316 ]);
317 } 317 }
318 318
319 /// Returns a [RunnerSuite] with a default environment and configuration. 319 /// Returns a [RunnerSuite] with a default environment and configuration.
320 RunnerSuite runnerSuite(Group root) => 320 RunnerSuite runnerSuite(Group root) =>
321 new RunnerSuite(const PluginEnvironment(), SuiteConfiguration.empty, root); 321 new RunnerSuite(const PluginEnvironment(), SuiteConfiguration.empty, root);
OLDNEW
« no previous file with comments | « test/util/stream_queue_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698