revert widgettester breaking change (#62914)
This commit is contained in:
parent
732083018c
commit
8081455394
@ -608,9 +608,12 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
|
||||
Future<int> pumpAndSettle([
|
||||
Duration duration = const Duration(milliseconds: 100),
|
||||
EnginePhase phase = EnginePhase.sendSemanticsUpdate,
|
||||
Duration timeout = const Duration(minutes: 10),
|
||||
]) {
|
||||
assert(duration != null);
|
||||
assert(duration > Duration.zero);
|
||||
assert(timeout != null);
|
||||
assert(timeout > Duration.zero);
|
||||
assert(() {
|
||||
final WidgetsBinding binding = this.binding;
|
||||
if (binding is LiveTestWidgetsFlutterBinding &&
|
||||
@ -623,8 +626,11 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
|
||||
return true;
|
||||
}());
|
||||
return TestAsyncUtils.guard<int>(() async {
|
||||
final DateTime endTime = binding.clock.fromNowBy(timeout);
|
||||
int count = 0;
|
||||
do {
|
||||
if (binding.clock.now().isAfter(endTime))
|
||||
throw FlutterError('pumpAndSettle timed out');
|
||||
await binding.pump(duration, phase);
|
||||
count += 1;
|
||||
} while (binding.hasScheduledFrame);
|
||||
|
@ -465,11 +465,21 @@ void main() {
|
||||
|
||||
testWidgets('pumpAndSettle control test', (WidgetTester tester) async {
|
||||
final AnimationController controller = AnimationController(
|
||||
duration: const Duration(seconds: 1),
|
||||
duration: const Duration(minutes: 525600),
|
||||
vsync: const TestVSync(),
|
||||
);
|
||||
expect(await tester.pumpAndSettle(), 1);
|
||||
controller.forward();
|
||||
try {
|
||||
await tester.pumpAndSettle();
|
||||
expect(true, isFalse);
|
||||
} catch (e) {
|
||||
expect(e, isFlutterError);
|
||||
}
|
||||
controller.stop();
|
||||
expect(await tester.pumpAndSettle(), 1);
|
||||
controller.duration = const Duration(seconds: 1);
|
||||
controller.forward();
|
||||
expect(await tester.pumpAndSettle(const Duration(milliseconds: 300)), 5); // 0, 300, 600, 900, 1200ms
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user