Skip to content

Commit 297a034

Browse files
authored
Update scroll tests to use pumpUntilNoTransientCallbacks (flutter#8495)
This ensures that both timer/microtask queues are cleared out rather than assuming that all work is completed in a specified amount of time.
1 parent 34c63af commit 297a034

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

packages/flutter/test/material/scaffold_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ void main() {
206206
expect(scrollable.position.pixels, equals(500.0));
207207
await tester.tapAt(const Point(100.0, 10.0));
208208
await tester.pump();
209-
await tester.pump(const Duration(seconds: 1));
209+
await tester.pumpUntilNoTransientCallbacks();
210210
expect(scrollable.position.pixels, equals(0.0));
211211
});
212212

packages/flutter/test/material/tabs_test.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,17 @@ void main() {
152152

153153
await tester.tap(find.text('C'));
154154
await tester.pump();
155-
await tester.pump(const Duration(seconds: 1));
155+
await tester.pumpUntilNoTransientCallbacks();
156156
expect(controller.index, 2);
157157

158158
await tester.tap(find.text('B'));
159159
await tester.pump();
160-
await tester.pump(const Duration(seconds: 1));
160+
await tester.pumpUntilNoTransientCallbacks();
161161
expect(controller.index, 1);
162162

163163
await tester.tap(find.text('A'));
164164
await tester.pump();
165-
await tester.pump(const Duration(seconds: 1));
165+
await tester.pumpUntilNoTransientCallbacks();
166166
expect(controller.index, 0);
167167
});
168168

@@ -180,7 +180,7 @@ void main() {
180180

181181
await tester.tap(find.text('FFFFFF'));
182182
await tester.pump();
183-
await tester.pump(const Duration(seconds: 1)); // finish the scroll animation
183+
await tester.pumpUntilNoTransientCallbacks();
184184
expect(controller.index, 5);
185185
// The center of the FFFFFF item is now at the TabBar's center
186186
expect(tester.getCenter(find.text('FFFFFF')).x, closeTo(400.0, 1.0));

packages/flutter/test/widgets/state_setting_in_scrollables_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void main() {
8383
expect(tester.state<ScrollableState>(find.byType(Scrollable)).position.pixels, 0.0);
8484
await tester.tap(find.byType(GestureDetector).first);
8585
await tester.pump();
86-
await tester.pump(const Duration(seconds: 1));
86+
await tester.pumpUntilNoTransientCallbacks();
8787
expect(tester.state<ScrollableState>(find.byType(Scrollable)).position.pixels, 200.0);
8888
});
8989
}

0 commit comments

Comments
 (0)