Line data Source code
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
3 : // BSD-style license that can be found in the LICENSE file.
4 :
5 : import 'package:test_api/hooks.dart';
6 :
7 : import 'util/placeholder.dart';
8 :
9 : // Function types returned by expectAsync# methods.
10 :
11 : typedef Func0<T> = T Function();
12 : typedef Func1<T, A> = T Function([A a]);
13 : typedef Func2<T, A, B> = T Function([A a, B b]);
14 : typedef Func3<T, A, B, C> = T Function([A a, B b, C c]);
15 : typedef Func4<T, A, B, C, D> = T Function([A a, B b, C c, D d]);
16 : typedef Func5<T, A, B, C, D, E> = T Function([A a, B b, C c, D d, E e]);
17 : typedef Func6<T, A, B, C, D, E, F> = T Function([A a, B b, C c, D d, E e, F f]);
18 :
19 : /// A wrapper for a function that ensures that it's called the appropriate
20 : /// number of times.
21 : ///
22 : /// The containing test won't be considered to have completed successfully until
23 : /// this function has been called the appropriate number of times.
24 : ///
25 : /// The wrapper function is accessible via [func]. It supports up to six
26 : /// optional and/or required positional arguments, but no named arguments.
27 : class _ExpectedFunction<T> {
28 : /// The wrapped callback.
29 : final Function _callback;
30 :
31 : /// The minimum number of calls that are expected to be made to the function.
32 : ///
33 : /// If fewer calls than this are made, the test will fail.
34 : final int _minExpectedCalls;
35 :
36 : /// The maximum number of calls that are expected to be made to the function.
37 : ///
38 : /// If more calls than this are made, the test will fail.
39 : final int _maxExpectedCalls;
40 :
41 : /// A callback that should return whether the function is not expected to have
42 : /// any more calls.
43 : ///
44 : /// This will be called after every time the function is run. The test case
45 : /// won't be allowed to terminate until it returns `true`.
46 : ///
47 : /// This may be `null`. If so, the function is considered to be done after
48 : /// it's been run once.
49 : final bool Function()? _isDone;
50 :
51 : /// A descriptive name for the function.
52 : final String _id;
53 :
54 : /// An optional description of why the function is expected to be called.
55 : ///
56 : /// If not passed, this will be an empty string.
57 : final String _reason;
58 :
59 : /// The number of times the function has been called.
60 : int _actualCalls = 0;
61 :
62 : /// The test in which this function was wrapped.
63 : late final TestHandle _test;
64 :
65 : /// Whether this function has been called the requisite number of times.
66 : late bool _complete;
67 :
68 : OutstandingWork? _outstandingWork;
69 :
70 : /// Wraps [callback] in a function that asserts that it's called at least
71 : /// [minExpected] times and no more than [maxExpected] times.
72 : ///
73 : /// If passed, [id] is used as a descriptive name fo the function and [reason]
74 : /// as a reason it's expected to be called. If [isDone] is passed, the test
75 : /// won't be allowed to complete until it returns `true`.
76 0 : _ExpectedFunction(Function callback, int minExpected, int maxExpected,
77 : {String? id, String? reason, bool Function()? isDone})
78 : : _callback = callback,
79 : _minExpectedCalls = minExpected,
80 : _maxExpectedCalls =
81 0 : (maxExpected == 0 && minExpected > 0) ? minExpected : maxExpected,
82 : _isDone = isDone,
83 0 : _reason = reason == null ? '' : '\n$reason',
84 0 : _id = _makeCallbackId(id, callback) {
85 : try {
86 0 : _test = TestHandle.current;
87 0 : } on OutsideTestException {
88 0 : throw StateError('`expectAsync` must be called within a test.');
89 : }
90 :
91 0 : if (maxExpected > 0 && minExpected > maxExpected) {
92 0 : throw ArgumentError('max ($maxExpected) may not be less than count '
93 : '($minExpected).');
94 : }
95 :
96 0 : if (isDone != null || minExpected > 0) {
97 0 : _outstandingWork = _test.markPending();
98 0 : _complete = false;
99 : } else {
100 0 : _complete = true;
101 : }
102 : }
103 :
104 : /// Tries to find a reasonable name for [callback].
105 : ///
106 : /// If [id] is passed, uses that. Otherwise, tries to determine a name from
107 : /// calling `toString`. If no name can be found, returns the empty string.
108 0 : static String _makeCallbackId(String? id, Function callback) {
109 0 : if (id != null) return '$id ';
110 :
111 : // If the callback is not an anonymous closure, try to get the
112 : // name.
113 0 : var toString = callback.toString();
114 : var prefix = "Function '";
115 0 : var start = toString.indexOf(prefix);
116 0 : if (start == -1) return '';
117 :
118 0 : start += prefix.length;
119 0 : var end = toString.indexOf("'", start);
120 0 : if (end == -1) return '';
121 0 : return '${toString.substring(start, end)} ';
122 : }
123 :
124 : /// Returns a function that has the same number of positional arguments as the
125 : /// wrapped function (up to a total of 6).
126 0 : Function get func {
127 0 : if (_callback is Function(Never, Never, Never, Never, Never, Never)) {
128 0 : return max6;
129 : }
130 0 : if (_callback is Function(Never, Never, Never, Never, Never)) return max5;
131 0 : if (_callback is Function(Never, Never, Never, Never)) return max4;
132 0 : if (_callback is Function(Never, Never, Never)) return max3;
133 0 : if (_callback is Function(Never, Never)) return max2;
134 0 : if (_callback is Function(Never)) return max1;
135 0 : if (_callback is Function()) return max0;
136 :
137 0 : _outstandingWork?.complete();
138 0 : throw ArgumentError(
139 : 'The wrapped function has more than 6 required arguments');
140 : }
141 :
142 : // This indirection is critical. It ensures the returned function has an
143 : // argument count of zero.
144 0 : T max0() => max6();
145 :
146 0 : T max1([Object? a0 = placeholder]) => max6(a0);
147 :
148 0 : T max2([Object? a0 = placeholder, Object? a1 = placeholder]) => max6(a0, a1);
149 :
150 0 : T max3(
151 : [Object? a0 = placeholder,
152 : Object? a1 = placeholder,
153 : Object? a2 = placeholder]) =>
154 0 : max6(a0, a1, a2);
155 :
156 0 : T max4(
157 : [Object? a0 = placeholder,
158 : Object? a1 = placeholder,
159 : Object? a2 = placeholder,
160 : Object? a3 = placeholder]) =>
161 0 : max6(a0, a1, a2, a3);
162 :
163 0 : T max5(
164 : [Object? a0 = placeholder,
165 : Object? a1 = placeholder,
166 : Object? a2 = placeholder,
167 : Object? a3 = placeholder,
168 : Object? a4 = placeholder]) =>
169 0 : max6(a0, a1, a2, a3, a4);
170 :
171 0 : T max6(
172 : [Object? a0 = placeholder,
173 : Object? a1 = placeholder,
174 : Object? a2 = placeholder,
175 : Object? a3 = placeholder,
176 : Object? a4 = placeholder,
177 : Object? a5 = placeholder]) =>
178 0 : _run([a0, a1, a2, a3, a4, a5].where((a) => a != placeholder));
179 :
180 : /// Runs the wrapped function with [args] and returns its return value.
181 0 : T _run(Iterable args) {
182 : // Note that in the old test, this returned `null` if it encountered an
183 : // error, where now it just re-throws that error because Zone machinery will
184 : // pass it to the invoker anyway.
185 : try {
186 0 : _actualCalls++;
187 0 : if (_test.shouldBeDone) {
188 0 : throw 'Callback ${_id}called ($_actualCalls) after test case '
189 0 : '${_test.name} had already completed.$_reason';
190 0 : } else if (_maxExpectedCalls >= 0 && _actualCalls > _maxExpectedCalls) {
191 0 : throw TestFailure('Callback ${_id}called more times than expected '
192 0 : '($_maxExpectedCalls).$_reason');
193 : }
194 :
195 0 : return Function.apply(_callback, args.toList()) as T;
196 : } finally {
197 0 : _afterRun();
198 : }
199 : }
200 :
201 : /// After each time the function is run, check to see if it's complete.
202 0 : void _afterRun() {
203 0 : if (_complete) return;
204 0 : if (_minExpectedCalls > 0 && _actualCalls < _minExpectedCalls) return;
205 0 : if (_isDone != null && !_isDone!()) return;
206 :
207 : // Mark this callback as complete and remove it from the test case's
208 : // oustanding callback count; if that hits zero the test is done.
209 0 : _complete = true;
210 0 : _outstandingWork?.complete();
211 : }
212 : }
213 :
214 : /// This function is deprecated because it doesn't work well with strong mode.
215 : /// Use [expectAsync0], [expectAsync1],
216 : /// [expectAsync2], [expectAsync3], [expectAsync4], [expectAsync5], or
217 : /// [expectAsync6] instead.
218 0 : @Deprecated('Will be removed in 0.13.0')
219 : Function expectAsync(Function callback,
220 : {int count = 1, int max = 0, String? id, String? reason}) =>
221 0 : _ExpectedFunction(callback, count, max, id: id, reason: reason).func;
222 :
223 : /// Informs the framework that the given [callback] of arity 0 is expected to be
224 : /// called [count] number of times (by default 1).
225 : ///
226 : /// Returns a wrapped function that should be used as a replacement of the
227 : /// original callback.
228 : ///
229 : /// The test framework will wait for the callback to run the [count] times
230 : /// before it considers the current test to be complete.
231 : ///
232 : /// [max] can be used to specify an upper bound on the number of calls; if this
233 : /// is exceeded the test will fail. If [max] is `0` (the default), the callback
234 : /// is expected to be called exactly [count] times. If [max] is `-1`, the
235 : /// callback is allowed to be called any number of times greater than [count].
236 : ///
237 : /// Both [id] and [reason] are optional and provide extra information about the
238 : /// callback when debugging. [id] should be the name of the callback, while
239 : /// [reason] should be the reason the callback is expected to be called.
240 : ///
241 : /// This method takes callbacks with zero arguments. See also
242 : /// [expectAsync1], [expectAsync2], [expectAsync3], [expectAsync4],
243 : /// [expectAsync5], and [expectAsync6] for callbacks with different arity.
244 0 : Func0<T> expectAsync0<T>(T Function() callback,
245 : {int count = 1, int max = 0, String? id, String? reason}) =>
246 0 : _ExpectedFunction<T>(callback, count, max, id: id, reason: reason).max0;
247 :
248 : /// Informs the framework that the given [callback] of arity 1 is expected to be
249 : /// called [count] number of times (by default 1).
250 : ///
251 : /// Returns a wrapped function that should be used as a replacement of the
252 : /// original callback.
253 : ///
254 : /// The test framework will wait for the callback to run the [count] times
255 : /// before it considers the current test to be complete.
256 : ///
257 : /// [max] can be used to specify an upper bound on the number of calls; if this
258 : /// is exceeded the test will fail. If [max] is `0` (the default), the callback
259 : /// is expected to be called exactly [count] times. If [max] is `-1`, the
260 : /// callback is allowed to be called any number of times greater than [count].
261 : ///
262 : /// Both [id] and [reason] are optional and provide extra information about the
263 : /// callback when debugging. [id] should be the name of the callback, while
264 : /// [reason] should be the reason the callback is expected to be called.
265 : ///
266 : /// This method takes callbacks with one argument. See also
267 : /// [expectAsync0], [expectAsync2], [expectAsync3], [expectAsync4],
268 : /// [expectAsync5], and [expectAsync6] for callbacks with different arity.
269 0 : Func1<T, A> expectAsync1<T, A>(T Function(A) callback,
270 : {int count = 1, int max = 0, String? id, String? reason}) =>
271 0 : _ExpectedFunction<T>(callback, count, max, id: id, reason: reason).max1;
272 :
273 : /// Informs the framework that the given [callback] of arity 2 is expected to be
274 : /// called [count] number of times (by default 1).
275 : ///
276 : /// Returns a wrapped function that should be used as a replacement of the
277 : /// original callback.
278 : ///
279 : /// The test framework will wait for the callback to run the [count] times
280 : /// before it considers the current test to be complete.
281 : ///
282 : /// [max] can be used to specify an upper bound on the number of calls; if this
283 : /// is exceeded the test will fail. If [max] is `0` (the default), the callback
284 : /// is expected to be called exactly [count] times. If [max] is `-1`, the
285 : /// callback is allowed to be called any number of times greater than [count].
286 : ///
287 : /// Both [id] and [reason] are optional and provide extra information about the
288 : /// callback when debugging. [id] should be the name of the callback, while
289 : /// [reason] should be the reason the callback is expected to be called.
290 : ///
291 : /// This method takes callbacks with two arguments. See also
292 : /// [expectAsync0], [expectAsync1], [expectAsync3], [expectAsync4],
293 : /// [expectAsync5], and [expectAsync6] for callbacks with different arity.
294 0 : Func2<T, A, B> expectAsync2<T, A, B>(T Function(A, B) callback,
295 : {int count = 1, int max = 0, String? id, String? reason}) =>
296 0 : _ExpectedFunction<T>(callback, count, max, id: id, reason: reason).max2;
297 :
298 : /// Informs the framework that the given [callback] of arity 3 is expected to be
299 : /// called [count] number of times (by default 1).
300 : ///
301 : /// Returns a wrapped function that should be used as a replacement of the
302 : /// original callback.
303 : ///
304 : /// The test framework will wait for the callback to run the [count] times
305 : /// before it considers the current test to be complete.
306 : ///
307 : /// [max] can be used to specify an upper bound on the number of calls; if this
308 : /// is exceeded the test will fail. If [max] is `0` (the default), the callback
309 : /// is expected to be called exactly [count] times. If [max] is `-1`, the
310 : /// callback is allowed to be called any number of times greater than [count].
311 : ///
312 : /// Both [id] and [reason] are optional and provide extra information about the
313 : /// callback when debugging. [id] should be the name of the callback, while
314 : /// [reason] should be the reason the callback is expected to be called.
315 : ///
316 : /// This method takes callbacks with three arguments. See also
317 : /// [expectAsync0], [expectAsync1], [expectAsync2], [expectAsync4],
318 : /// [expectAsync5], and [expectAsync6] for callbacks with different arity.
319 0 : Func3<T, A, B, C> expectAsync3<T, A, B, C>(T Function(A, B, C) callback,
320 : {int count = 1, int max = 0, String? id, String? reason}) =>
321 0 : _ExpectedFunction<T>(callback, count, max, id: id, reason: reason).max3;
322 :
323 : /// Informs the framework that the given [callback] of arity 4 is expected to be
324 : /// called [count] number of times (by default 1).
325 : ///
326 : /// Returns a wrapped function that should be used as a replacement of the
327 : /// original callback.
328 : ///
329 : /// The test framework will wait for the callback to run the [count] times
330 : /// before it considers the current test to be complete.
331 : ///
332 : /// [max] can be used to specify an upper bound on the number of calls; if this
333 : /// is exceeded the test will fail. If [max] is `0` (the default), the callback
334 : /// is expected to be called exactly [count] times. If [max] is `-1`, the
335 : /// callback is allowed to be called any number of times greater than [count].
336 : ///
337 : /// Both [id] and [reason] are optional and provide extra information about the
338 : /// callback when debugging. [id] should be the name of the callback, while
339 : /// [reason] should be the reason the callback is expected to be called.
340 : ///
341 : /// This method takes callbacks with four arguments. See also
342 : /// [expectAsync0], [expectAsync1], [expectAsync2], [expectAsync3],
343 : /// [expectAsync5], and [expectAsync6] for callbacks with different arity.
344 0 : Func4<T, A, B, C, D> expectAsync4<T, A, B, C, D>(
345 : T Function(A, B, C, D) callback,
346 : {int count = 1,
347 : int max = 0,
348 : String? id,
349 : String? reason}) =>
350 0 : _ExpectedFunction<T>(callback, count, max, id: id, reason: reason).max4;
351 :
352 : /// Informs the framework that the given [callback] of arity 5 is expected to be
353 : /// called [count] number of times (by default 1).
354 : ///
355 : /// Returns a wrapped function that should be used as a replacement of the
356 : /// original callback.
357 : ///
358 : /// The test framework will wait for the callback to run the [count] times
359 : /// before it considers the current test to be complete.
360 : ///
361 : /// [max] can be used to specify an upper bound on the number of calls; if this
362 : /// is exceeded the test will fail. If [max] is `0` (the default), the callback
363 : /// is expected to be called exactly [count] times. If [max] is `-1`, the
364 : /// callback is allowed to be called any number of times greater than [count].
365 : ///
366 : /// Both [id] and [reason] are optional and provide extra information about the
367 : /// callback when debugging. [id] should be the name of the callback, while
368 : /// [reason] should be the reason the callback is expected to be called.
369 : ///
370 : /// This method takes callbacks with five arguments. See also
371 : /// [expectAsync0], [expectAsync1], [expectAsync2], [expectAsync3],
372 : /// [expectAsync4], and [expectAsync6] for callbacks with different arity.
373 0 : Func5<T, A, B, C, D, E> expectAsync5<T, A, B, C, D, E>(
374 : T Function(A, B, C, D, E) callback,
375 : {int count = 1,
376 : int max = 0,
377 : String? id,
378 : String? reason}) =>
379 0 : _ExpectedFunction<T>(callback, count, max, id: id, reason: reason).max5;
380 :
381 : /// Informs the framework that the given [callback] of arity 6 is expected to be
382 : /// called [count] number of times (by default 1).
383 : ///
384 : /// Returns a wrapped function that should be used as a replacement of the
385 : /// original callback.
386 : ///
387 : /// The test framework will wait for the callback to run the [count] times
388 : /// before it considers the current test to be complete.
389 : ///
390 : /// [max] can be used to specify an upper bound on the number of calls; if this
391 : /// is exceeded the test will fail. If [max] is `0` (the default), the callback
392 : /// is expected to be called exactly [count] times. If [max] is `-1`, the
393 : /// callback is allowed to be called any number of times greater than [count].
394 : ///
395 : /// Both [id] and [reason] are optional and provide extra information about the
396 : /// callback when debugging. [id] should be the name of the callback, while
397 : /// [reason] should be the reason the callback is expected to be called.
398 : ///
399 : /// This method takes callbacks with six arguments. See also
400 : /// [expectAsync0], [expectAsync1], [expectAsync2], [expectAsync3],
401 : /// [expectAsync4], and [expectAsync5] for callbacks with different arity.
402 0 : Func6<T, A, B, C, D, E, F> expectAsync6<T, A, B, C, D, E, F>(
403 : T Function(A, B, C, D, E, F) callback,
404 : {int count = 1,
405 : int max = 0,
406 : String? id,
407 : String? reason}) =>
408 0 : _ExpectedFunction<T>(callback, count, max, id: id, reason: reason).max6;
409 :
410 : /// This function is deprecated because it doesn't work well with strong mode.
411 : /// Use [expectAsyncUntil0], [expectAsyncUntil1],
412 : /// [expectAsyncUntil2], [expectAsyncUntil3], [expectAsyncUntil4],
413 : /// [expectAsyncUntil5], or [expectAsyncUntil6] instead.
414 0 : @Deprecated('Will be removed in 0.13.0')
415 : Function expectAsyncUntil(Function callback, bool Function() isDone,
416 : {String? id, String? reason}) =>
417 0 : _ExpectedFunction(callback, 0, -1, id: id, reason: reason, isDone: isDone)
418 0 : .func;
419 :
420 : /// Informs the framework that the given [callback] of arity 0 is expected to be
421 : /// called until [isDone] returns true.
422 : ///
423 : /// Returns a wrapped function that should be used as a replacement of the
424 : /// original callback.
425 : ///
426 : /// [isDone] is called after each time the function is run. Only when it returns
427 : /// true will the callback be considered complete.
428 : ///
429 : /// Both [id] and [reason] are optional and provide extra information about the
430 : /// callback when debugging. [id] should be the name of the callback, while
431 : /// [reason] should be the reason the callback is expected to be called.
432 : ///
433 : /// This method takes callbacks with zero arguments. See also
434 : /// [expectAsyncUntil1], [expectAsyncUntil2], [expectAsyncUntil3],
435 : /// [expectAsyncUntil4], [expectAsyncUntil5], and [expectAsyncUntil6] for
436 : /// callbacks with different arity.
437 0 : Func0<T> expectAsyncUntil0<T>(T Function() callback, bool Function() isDone,
438 : {String? id, String? reason}) =>
439 0 : _ExpectedFunction<T>(callback, 0, -1,
440 : id: id, reason: reason, isDone: isDone)
441 0 : .max0;
442 :
443 : /// Informs the framework that the given [callback] of arity 1 is expected to be
444 : /// called until [isDone] returns true.
445 : ///
446 : /// Returns a wrapped function that should be used as a replacement of the
447 : /// original callback.
448 : ///
449 : /// [isDone] is called after each time the function is run. Only when it returns
450 : /// true will the callback be considered complete.
451 : ///
452 : /// Both [id] and [reason] are optional and provide extra information about the
453 : /// callback when debugging. [id] should be the name of the callback, while
454 : /// [reason] should be the reason the callback is expected to be called.
455 : ///
456 : /// This method takes callbacks with one argument. See also
457 : /// [expectAsyncUntil0], [expectAsyncUntil2], [expectAsyncUntil3],
458 : /// [expectAsyncUntil4], [expectAsyncUntil5], and [expectAsyncUntil6] for
459 : /// callbacks with different arity.
460 0 : Func1<T, A> expectAsyncUntil1<T, A>(
461 : T Function(A) callback, bool Function() isDone,
462 : {String? id, String? reason}) =>
463 0 : _ExpectedFunction<T>(callback, 0, -1,
464 : id: id, reason: reason, isDone: isDone)
465 0 : .max1;
466 :
467 : /// Informs the framework that the given [callback] of arity 2 is expected to be
468 : /// called until [isDone] returns true.
469 : ///
470 : /// Returns a wrapped function that should be used as a replacement of the
471 : /// original callback.
472 : ///
473 : /// [isDone] is called after each time the function is run. Only when it returns
474 : /// true will the callback be considered complete.
475 : ///
476 : /// Both [id] and [reason] are optional and provide extra information about the
477 : /// callback when debugging. [id] should be the name of the callback, while
478 : /// [reason] should be the reason the callback is expected to be called.
479 : ///
480 : /// This method takes callbacks with two arguments. See also
481 : /// [expectAsyncUntil0], [expectAsyncUntil1], [expectAsyncUntil3],
482 : /// [expectAsyncUntil4], [expectAsyncUntil5], and [expectAsyncUntil6] for
483 : /// callbacks with different arity.
484 0 : Func2<T, A, B> expectAsyncUntil2<T, A, B>(
485 : T Function(A, B) callback, bool Function() isDone,
486 : {String? id, String? reason}) =>
487 0 : _ExpectedFunction<T>(callback, 0, -1,
488 : id: id, reason: reason, isDone: isDone)
489 0 : .max2;
490 :
491 : /// Informs the framework that the given [callback] of arity 3 is expected to be
492 : /// called until [isDone] returns true.
493 : ///
494 : /// Returns a wrapped function that should be used as a replacement of the
495 : /// original callback.
496 : ///
497 : /// [isDone] is called after each time the function is run. Only when it returns
498 : /// true will the callback be considered complete.
499 : ///
500 : /// Both [id] and [reason] are optional and provide extra information about the
501 : /// callback when debugging. [id] should be the name of the callback, while
502 : /// [reason] should be the reason the callback is expected to be called.
503 : ///
504 : /// This method takes callbacks with three arguments. See also
505 : /// [expectAsyncUntil0], [expectAsyncUntil1], [expectAsyncUntil2],
506 : /// [expectAsyncUntil4], [expectAsyncUntil5], and [expectAsyncUntil6] for
507 : /// callbacks with different arity.
508 0 : Func3<T, A, B, C> expectAsyncUntil3<T, A, B, C>(
509 : T Function(A, B, C) callback, bool Function() isDone,
510 : {String? id, String? reason}) =>
511 0 : _ExpectedFunction<T>(callback, 0, -1,
512 : id: id, reason: reason, isDone: isDone)
513 0 : .max3;
514 :
515 : /// Informs the framework that the given [callback] of arity 4 is expected to be
516 : /// called until [isDone] returns true.
517 : ///
518 : /// Returns a wrapped function that should be used as a replacement of the
519 : /// original callback.
520 : ///
521 : /// [isDone] is called after each time the function is run. Only when it returns
522 : /// true will the callback be considered complete.
523 : ///
524 : /// Both [id] and [reason] are optional and provide extra information about the
525 : /// callback when debugging. [id] should be the name of the callback, while
526 : /// [reason] should be the reason the callback is expected to be called.
527 : ///
528 : /// This method takes callbacks with four arguments. See also
529 : /// [expectAsyncUntil0], [expectAsyncUntil1], [expectAsyncUntil2],
530 : /// [expectAsyncUntil3], [expectAsyncUntil5], and [expectAsyncUntil6] for
531 : /// callbacks with different arity.
532 0 : Func4<T, A, B, C, D> expectAsyncUntil4<T, A, B, C, D>(
533 : T Function(A, B, C, D) callback, bool Function() isDone,
534 : {String? id, String? reason}) =>
535 0 : _ExpectedFunction<T>(callback, 0, -1,
536 : id: id, reason: reason, isDone: isDone)
537 0 : .max4;
538 :
539 : /// Informs the framework that the given [callback] of arity 5 is expected to be
540 : /// called until [isDone] returns true.
541 : ///
542 : /// Returns a wrapped function that should be used as a replacement of the
543 : /// original callback.
544 : ///
545 : /// [isDone] is called after each time the function is run. Only when it returns
546 : /// true will the callback be considered complete.
547 : ///
548 : /// Both [id] and [reason] are optional and provide extra information about the
549 : /// callback when debugging. [id] should be the name of the callback, while
550 : /// [reason] should be the reason the callback is expected to be called.
551 : ///
552 : /// This method takes callbacks with five arguments. See also
553 : /// [expectAsyncUntil0], [expectAsyncUntil1], [expectAsyncUntil2],
554 : /// [expectAsyncUntil3], [expectAsyncUntil4], and [expectAsyncUntil6] for
555 : /// callbacks with different arity.
556 0 : Func5<T, A, B, C, D, E> expectAsyncUntil5<T, A, B, C, D, E>(
557 : T Function(A, B, C, D, E) callback, bool Function() isDone,
558 : {String? id, String? reason}) =>
559 0 : _ExpectedFunction<T>(callback, 0, -1,
560 : id: id, reason: reason, isDone: isDone)
561 0 : .max5;
562 :
563 : /// Informs the framework that the given [callback] of arity 6 is expected to be
564 : /// called until [isDone] returns true.
565 : ///
566 : /// Returns a wrapped function that should be used as a replacement of the
567 : /// original callback.
568 : ///
569 : /// [isDone] is called after each time the function is run. Only when it returns
570 : /// true will the callback be considered complete.
571 : ///
572 : /// Both [id] and [reason] are optional and provide extra information about the
573 : /// callback when debugging. [id] should be the name of the callback, while
574 : /// [reason] should be the reason the callback is expected to be called.
575 : ///
576 : /// This method takes callbacks with six arguments. See also
577 : /// [expectAsyncUntil0], [expectAsyncUntil1], [expectAsyncUntil2],
578 : /// [expectAsyncUntil3], [expectAsyncUntil4], and [expectAsyncUntil5] for
579 : /// callbacks with different arity.
580 0 : Func6<T, A, B, C, D, E, F> expectAsyncUntil6<T, A, B, C, D, E, F>(
581 : T Function(A, B, C, D, E, F) callback, bool Function() isDone,
582 : {String? id, String? reason}) =>
583 0 : _ExpectedFunction<T>(callback, 0, -1,
584 : id: id, reason: reason, isDone: isDone)
585 0 : .max6;
|