Commit 8eac6cd0 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Test API improvements: pumpAndSettle, autogenerate pointer IDs (#8751)

parent 898b6f85
...@@ -23,7 +23,7 @@ void main() { ...@@ -23,7 +23,7 @@ void main() {
final Point allDemosOrigin = tester.getTopRight(find.text('Demos')); final Point allDemosOrigin = tester.getTopRight(find.text('Demos'));
final Finder button = find.text('Buttons'); final Finder button = find.text('Buttons');
while (button.evaluate().isEmpty) { while (button.evaluate().isEmpty) {
await tester.scrollAt(allDemosOrigin, const Offset(0.0, -100.0)); await tester.dragFrom(allDemosOrigin, const Offset(0.0, -100.0));
await tester.pump(); // start the scroll await tester.pump(); // start the scroll
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
} }
......
...@@ -34,7 +34,7 @@ void main() { ...@@ -34,7 +34,7 @@ void main() {
await tester.pump(); // Launch the recipe page await tester.pump(); // Launch the recipe page
await tester.pump(const Duration(seconds: 1)); // transition is complete await tester.pump(const Duration(seconds: 1)); // transition is complete
await tester.scroll(find.text('Pesto Bruschetta'), const Offset(0.0, -300.0)); await tester.drag(find.text('Pesto Bruschetta'), const Offset(0.0, -300.0));
await tester.pump(); await tester.pump();
Navigator.pop(find.byType(Scaffold).evaluate().single); Navigator.pop(find.byType(Scaffold).evaluate().single);
...@@ -51,8 +51,7 @@ void main() { ...@@ -51,8 +51,7 @@ void main() {
await tester.pump(const Duration(seconds: 1)); // transition is complete await tester.pump(const Duration(seconds: 1)); // transition is complete
await tester.fling(find.text('Pesto Bruschetta'), const Offset(0.0, -200.0), 10000.0); await tester.fling(find.text('Pesto Bruschetta'), const Offset(0.0, -200.0), 10000.0);
await tester.pump(); // start fling await tester.pumpAndSettle(); // start and finish fling
await tester.pumpUntilNoTransientCallbacks();
expect(find.text('Sicilian-Style sardines'), findsOneWidget); expect(find.text('Sicilian-Style sardines'), findsOneWidget);
}); });
} }
...@@ -47,17 +47,17 @@ void main() { ...@@ -47,17 +47,17 @@ void main() {
await tester.pump(const Duration(seconds: 1)); // end animation await tester.pump(const Duration(seconds: 1)); // end animation
// Scroll it up // Scroll it up
await tester.scroll(find.text('(650) 555-1234'), const Offset(0.0, -50.0)); await tester.drag(find.text('(650) 555-1234'), const Offset(0.0, -50.0));
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
await tester.scroll(find.text('(650) 555-1234'), const Offset(0.0, -50.0)); await tester.drag(find.text('(650) 555-1234'), const Offset(0.0, -50.0));
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
await tester.scroll(find.text('(650) 555-1234'), const Offset(0.0, -50.0)); await tester.drag(find.text('(650) 555-1234'), const Offset(0.0, -50.0));
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
await tester.scroll(find.text('(650) 555-1234'), const Offset(0.0, -50.0)); await tester.drag(find.text('(650) 555-1234'), const Offset(0.0, -50.0));
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
await tester.scroll(find.text('(650) 555-1234'), const Offset(0.0, -50.0)); await tester.drag(find.text('(650) 555-1234'), const Offset(0.0, -50.0));
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
await tester.scroll(find.text('(650) 555-1234'), const Offset(0.0, -50.0)); await tester.drag(find.text('(650) 555-1234'), const Offset(0.0, -50.0));
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
await tester.pump(const Duration(hours: 100)); // for testing await tester.pump(const Duration(hours: 100)); // for testing
......
...@@ -127,8 +127,7 @@ Future<Null> runSmokeTest(WidgetTester tester) async { ...@@ -127,8 +127,7 @@ Future<Null> runSmokeTest(WidgetTester tester) async {
for (String routeName in routeNames) { for (String routeName in routeNames) {
final Finder finder = findGalleryItemByRouteName(tester, routeName); final Finder finder = findGalleryItemByRouteName(tester, routeName);
Scrollable.ensureVisible(tester.element(finder), alignment: 0.5); Scrollable.ensureVisible(tester.element(finder), alignment: 0.5);
await tester.pump(); await tester.pumpAndSettle();
await tester.pumpUntilNoTransientCallbacks();
await smokeDemo(tester, routeName); await smokeDemo(tester, routeName);
tester.binding.debugAssertNoTransientCallbacks('A transient callback was still active after leaving route $routeName'); tester.binding.debugAssertNoTransientCallbacks('A transient callback was still active after leaving route $routeName');
} }
......
...@@ -69,8 +69,7 @@ void main() { ...@@ -69,8 +69,7 @@ void main() {
final Point topLeft = tester.getTopLeft(find.byKey(sliderKey)); final Point topLeft = tester.getTopLeft(find.byKey(sliderKey));
const double unit = CupertinoThumbPainter.radius; const double unit = CupertinoThumbPainter.radius;
const double delta = 3.0 * unit; const double delta = 3.0 * unit;
await tester.scrollAt( await tester.dragFrom(topLeft + const Offset(unit, unit), const Offset(delta, 0.0));
topLeft + const Offset(unit, unit), const Offset(delta, 0.0));
final Size size = tester.getSize(find.byKey(sliderKey)); final Size size = tester.getSize(find.byKey(sliderKey));
expect(value, equals(delta / (size.width - 2.0 * (8.0 + CupertinoThumbPainter.radius)))); expect(value, equals(delta / (size.width - 2.0 * (8.0 + CupertinoThumbPainter.radius))));
await tester.pump(); // No animation should start. await tester.pump(); // No animation should start.
......
...@@ -40,14 +40,14 @@ void main() { ...@@ -40,14 +40,14 @@ void main() {
expect(find.text('About box'), findsNothing); expect(find.text('About box'), findsNothing);
await tester.tap(find.byType(IconButton)); await tester.tap(find.byType(IconButton));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100)); await tester.pumpAndSettle(const Duration(milliseconds: 100));
expect(find.text('About Pirate app'), findsOneWidget); expect(find.text('About Pirate app'), findsOneWidget);
expect(find.text('0.1.2'), findsNothing); expect(find.text('0.1.2'), findsNothing);
expect(find.text('About box'), findsNothing); expect(find.text('About box'), findsNothing);
await tester.tap(find.text('About Pirate app')); await tester.tap(find.text('About Pirate app'));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100)); await tester.pumpAndSettle(const Duration(milliseconds: 100));
expect(find.text('About Pirate app'), findsOneWidget); expect(find.text('About Pirate app'), findsOneWidget);
expect(find.text('0.1.2'), findsOneWidget); expect(find.text('0.1.2'), findsOneWidget);
...@@ -60,7 +60,7 @@ void main() { ...@@ -60,7 +60,7 @@ void main() {
}); });
await tester.tap(find.text('VIEW LICENSES')); await tester.tap(find.text('VIEW LICENSES'));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100)); await tester.pumpAndSettle(const Duration(milliseconds: 100));
expect(find.text('Pirate license'), findsOneWidget); expect(find.text('Pirate license'), findsOneWidget);
}); });
......
...@@ -24,13 +24,11 @@ void main() { ...@@ -24,13 +24,11 @@ void main() {
tester.state<NavigatorState>(find.byType(Navigator)).pushNamed('/next'); tester.state<NavigatorState>(find.byType(Navigator)).pushNamed('/next');
await tester.pump(); await tester.pumpAndSettle();
await tester.pumpUntilNoTransientCallbacks();
await tester.tap(find.byType(BackButton)); await tester.tap(find.byType(BackButton));
await tester.pump(); await tester.pumpAndSettle();
await tester.pumpUntilNoTransientCallbacks();
expect(find.text('Home'), findsOneWidget); expect(find.text('Home'), findsOneWidget);
}); });
......
...@@ -77,7 +77,7 @@ void main() { ...@@ -77,7 +77,7 @@ void main() {
await tester.pumpWidget(new MaterialApp( await tester.pumpWidget(new MaterialApp(
home: new Material(child: buildTable(sortColumnIndex: 1)) home: new Material(child: buildTable(sortColumnIndex: 1))
)); ));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 200)); await tester.pumpAndSettle(const Duration(milliseconds: 200));
await tester.tap(find.text('Calories')); await tester.tap(find.text('Calories'));
expect(log, <String>['column-sort: 1 false']); expect(log, <String>['column-sort: 1 false']);
...@@ -86,7 +86,7 @@ void main() { ...@@ -86,7 +86,7 @@ void main() {
await tester.pumpWidget(new MaterialApp( await tester.pumpWidget(new MaterialApp(
home: new Material(child: buildTable(sortColumnIndex: 1, sortAscending: false)) home: new Material(child: buildTable(sortColumnIndex: 1, sortAscending: false))
)); ));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 200)); await tester.pumpAndSettle(const Duration(milliseconds: 200));
await tester.tap(find.text('375')); await tester.tap(find.text('375'));
......
...@@ -63,23 +63,23 @@ void main() { ...@@ -63,23 +63,23 @@ void main() {
await tester.pump(const Duration(seconds: 2)); await tester.pump(const Duration(seconds: 2));
await tester.tapAt(const Point(380.0, 20.0)); await tester.tapAt(const Point(380.0, 20.0));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100)); await tester.pumpAndSettle(const Duration(milliseconds: 100));
expect(_selectedDate, equals(new DateTime(2016, DateTime.JULY, 1))); expect(_selectedDate, equals(new DateTime(2016, DateTime.JULY, 1)));
await tester.tapAt(const Point(300.0, 100.0)); await tester.tapAt(const Point(300.0, 100.0));
expect(_selectedDate, equals(new DateTime(2016, DateTime.AUGUST, 5))); expect(_selectedDate, equals(new DateTime(2016, DateTime.AUGUST, 5)));
await tester.pump(const Duration(seconds: 2)); await tester.pump(const Duration(seconds: 2));
await tester.scroll(find.byKey(_datePickerKey), const Offset(-300.0, 0.0)); await tester.drag(find.byKey(_datePickerKey), const Offset(-300.0, 0.0));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100)); await tester.pumpAndSettle(const Duration(milliseconds: 100));
expect(_selectedDate, equals(new DateTime(2016, DateTime.AUGUST, 5))); expect(_selectedDate, equals(new DateTime(2016, DateTime.AUGUST, 5)));
await tester.tapAt(const Point(45.0, 270.0)); await tester.tapAt(const Point(45.0, 270.0));
expect(_selectedDate, equals(new DateTime(2016, DateTime.SEPTEMBER, 25))); expect(_selectedDate, equals(new DateTime(2016, DateTime.SEPTEMBER, 25)));
await tester.pump(const Duration(seconds: 2)); await tester.pump(const Duration(seconds: 2));
await tester.scroll(find.byKey(_datePickerKey), const Offset(300.0, 0.0)); await tester.drag(find.byKey(_datePickerKey), const Offset(300.0, 0.0));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100)); await tester.pumpAndSettle(const Duration(milliseconds: 100));
expect(_selectedDate, equals(new DateTime(2016, DateTime.SEPTEMBER, 25))); expect(_selectedDate, equals(new DateTime(2016, DateTime.SEPTEMBER, 25)));
await tester.tapAt(const Point(210.0, 180.0)); await tester.tapAt(const Point(210.0, 180.0));
...@@ -144,7 +144,7 @@ void main() { ...@@ -144,7 +144,7 @@ void main() {
selectableDayPredicate: selectableDayPredicate selectableDayPredicate: selectableDayPredicate
); );
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
await callback(date); await callback(date);
} }
...@@ -173,7 +173,7 @@ void main() { ...@@ -173,7 +173,7 @@ void main() {
testWidgets('Can select a month', (WidgetTester tester) async { testWidgets('Can select a month', (WidgetTester tester) async {
await preparePicker(tester, (Future<DateTime> date) async { await preparePicker(tester, (Future<DateTime> date) async {
await tester.tap(find.byTooltip('Previous month')); await tester.tap(find.byTooltip('Previous month'));
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
await tester.tap(find.text('25')); await tester.tap(find.text('25'));
await tester.tap(find.text('OK')); await tester.tap(find.text('OK'));
expect(await date, equals(new DateTime(2015, DateTime.DECEMBER, 25))); expect(await date, equals(new DateTime(2015, DateTime.DECEMBER, 25)));
...@@ -224,10 +224,10 @@ void main() { ...@@ -224,10 +224,10 @@ void main() {
lastDate = new DateTime(2017, DateTime.FEBRUARY, 20); lastDate = new DateTime(2017, DateTime.FEBRUARY, 20);
await preparePicker(tester, (Future<DateTime> date) async { await preparePicker(tester, (Future<DateTime> date) async {
await tester.tap(find.byTooltip('Next month')); await tester.tap(find.byTooltip('Next month'));
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
// Shouldn't be possible to keep going into March. // Shouldn't be possible to keep going into March.
await tester.tap(find.byTooltip('Next month')); await tester.tap(find.byTooltip('Next month'));
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
// We're still in February // We're still in February
await tester.tap(find.text('20')); await tester.tap(find.text('20'));
// Days outside bound for new month pages also disabled. // Days outside bound for new month pages also disabled.
...@@ -243,10 +243,10 @@ void main() { ...@@ -243,10 +243,10 @@ void main() {
lastDate = initialDate; lastDate = initialDate;
await preparePicker(tester, (Future<DateTime> date) async { await preparePicker(tester, (Future<DateTime> date) async {
await tester.tap(find.byTooltip('Previous month')); await tester.tap(find.byTooltip('Previous month'));
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
// Shouldn't be possible to keep going into November. // Shouldn't be possible to keep going into November.
await tester.tap(find.byTooltip('Previous month')); await tester.tap(find.byTooltip('Previous month'));
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
// We're still in December // We're still in December
await tester.tap(find.text('10')); await tester.tap(find.text('10'));
// Days outside bound for new month pages also disabled. // Days outside bound for new month pages also disabled.
......
...@@ -131,7 +131,7 @@ void main() { ...@@ -131,7 +131,7 @@ void main() {
), ),
); );
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
expect(find.text('Title'), findsOneWidget); expect(find.text('Title'), findsOneWidget);
await tester.tap(find.text('First option')); await tester.tap(find.text('First option'));
...@@ -164,13 +164,13 @@ void main() { ...@@ -164,13 +164,13 @@ void main() {
), ),
); );
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
expect(find.text('Dialog1'), findsOneWidget); expect(find.text('Dialog1'), findsOneWidget);
// Tap on the barrier. // Tap on the barrier.
await tester.tapAt(const Point(10.0, 10.0)); await tester.tapAt(const Point(10.0, 10.0));
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
expect(find.text('Dialog1'), findsNothing); expect(find.text('Dialog1'), findsNothing);
showDialog<Null>( showDialog<Null>(
...@@ -184,13 +184,13 @@ void main() { ...@@ -184,13 +184,13 @@ void main() {
), ),
); );
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
expect(find.text('Dialog2'), findsOneWidget); expect(find.text('Dialog2'), findsOneWidget);
// Tap on the barrier, which shouldn't do anything this time. // Tap on the barrier, which shouldn't do anything this time.
await tester.tapAt(const Point(10.0, 10.0)); await tester.tapAt(const Point(10.0, 10.0));
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
expect(find.text('Dialog2'), findsOneWidget); expect(find.text('Dialog2'), findsOneWidget);
}); });
......
...@@ -90,7 +90,7 @@ void main() { ...@@ -90,7 +90,7 @@ void main() {
])); ]));
log.clear(); log.clear();
await tester.scroll(find.byType(ListView), const Offset(0.0, -300.0)); await tester.drag(find.byType(ListView), const Offset(0.0, -300.0));
await tester.pump(); await tester.pump();
expect(log, isEmpty); expect(log, isEmpty);
......
...@@ -96,10 +96,10 @@ void main() { ...@@ -96,10 +96,10 @@ void main() {
expect(log, isEmpty); expect(log, isEmpty);
await tester.tap(find.text('2')); await tester.tap(find.text('2'));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 200)); await tester.pumpAndSettle(const Duration(milliseconds: 200));
await tester.tap(find.text('8').last); await tester.tap(find.text('8').last);
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 200)); await tester.pumpAndSettle(const Duration(milliseconds: 200));
expect(log, <String>['rows-per-page-changed: 8']); expect(log, <String>['rows-per-page-changed: 8']);
log.clear(); log.clear();
......
...@@ -56,13 +56,12 @@ void main() { ...@@ -56,13 +56,12 @@ void main() {
); );
}); });
await tester.pumpUntilNoTransientCallbacks(); await tester.pumpAndSettle();
expect(find.text('Two'), findsOneWidget); expect(find.text('Two'), findsOneWidget);
await tester.scroll(find.text('Two'), const Offset(0.0, 400.0)); await tester.drag(find.text('Two'), const Offset(0.0, 400.0));
await tester.pump(); await tester.pumpAndSettle();
await tester.pumpUntilNoTransientCallbacks();
expect(find.text('Two'), findsNothing); expect(find.text('Two'), findsNothing);
}); });
......
...@@ -166,7 +166,7 @@ void main() { ...@@ -166,7 +166,7 @@ void main() {
expect(scrollOffset.offset, 0.0); expect(scrollOffset.offset, 0.0);
const double scrollDelta = 80.0; const double scrollDelta = 80.0;
await tester.scroll(find.byKey(drawerKey), const Offset(0.0, -scrollDelta)); await tester.drag(find.byKey(drawerKey), const Offset(0.0, -scrollDelta));
await tester.pump(); await tester.pump();
expect(scrollOffset.offset, scrollDelta); expect(scrollOffset.offset, scrollDelta);
...@@ -205,8 +205,7 @@ void main() { ...@@ -205,8 +205,7 @@ void main() {
scrollable.position.jumpTo(500.0); scrollable.position.jumpTo(500.0);
expect(scrollable.position.pixels, equals(500.0)); expect(scrollable.position.pixels, equals(500.0));
await tester.tapAt(const Point(100.0, 10.0)); await tester.tapAt(const Point(100.0, 10.0));
await tester.pump(); await tester.pumpAndSettle();
await tester.pumpUntilNoTransientCallbacks();
expect(scrollable.position.pixels, equals(0.0)); expect(scrollable.position.pixels, equals(0.0));
}); });
...@@ -289,7 +288,7 @@ void main() { ...@@ -289,7 +288,7 @@ void main() {
), ),
); );
await tester.scroll(find.text('body'), const Offset(0.0, -1000.0)); await tester.drag(find.text('body'), const Offset(0.0, -1000.0));
expect(didPressButton, isFalse); expect(didPressButton, isFalse);
await tester.tap(find.text('X')); await tester.tap(find.text('X'));
expect(didPressButton, isTrue); expect(didPressButton, isTrue);
......
...@@ -41,7 +41,7 @@ void main() { ...@@ -41,7 +41,7 @@ void main() {
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
await tester.scroll(find.byType(ListView), const Offset(0.0, -10.0)); await tester.drag(find.byType(ListView), const Offset(0.0, -10.0));
expect(SchedulerBinding.instance.transientCallbackCount, greaterThan(0)); expect(SchedulerBinding.instance.transientCallbackCount, greaterThan(0));
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
......
...@@ -70,9 +70,9 @@ void main() { ...@@ -70,9 +70,9 @@ void main() {
expect(value, equals(0.0)); expect(value, equals(0.0));
await tester.tap(find.byKey(sliderKey)); await tester.tap(find.byKey(sliderKey));
expect(value, equals(50.0)); expect(value, equals(50.0));
await tester.scroll(find.byKey(sliderKey), const Offset(5.0, 0.0)); await tester.drag(find.byKey(sliderKey), const Offset(5.0, 0.0));
expect(value, equals(50.0)); expect(value, equals(50.0));
await tester.scroll(find.byKey(sliderKey), const Offset(40.0, 0.0)); await tester.drag(find.byKey(sliderKey), const Offset(40.0, 0.0));
expect(value, equals(80.0)); expect(value, equals(80.0));
await tester.pump(); // Starts animation. await tester.pump(); // Starts animation.
......
...@@ -251,7 +251,7 @@ void main() { ...@@ -251,7 +251,7 @@ void main() {
expect(find.text('bar1'), findsOneWidget); expect(find.text('bar1'), findsOneWidget);
expect(find.text('bar2'), findsNothing); expect(find.text('bar2'), findsNothing);
await tester.pump(const Duration(milliseconds: 750)); // 0.75s // animation last frame; two second timer starts here await tester.pump(const Duration(milliseconds: 750)); // 0.75s // animation last frame; two second timer starts here
await tester.scroll(find.text('bar1'), const Offset(0.0, 50.0)); await tester.drag(find.text('bar1'), const Offset(0.0, 50.0));
await tester.pump(); // bar1 dismissed, bar2 begins animating await tester.pump(); // bar1 dismissed, bar2 begins animating
expect(find.text('bar1'), findsNothing); expect(find.text('bar1'), findsNothing);
expect(find.text('bar2'), findsOneWidget); expect(find.text('bar2'), findsOneWidget);
...@@ -381,7 +381,7 @@ void main() { ...@@ -381,7 +381,7 @@ void main() {
await tester.tap(find.text('X')); await tester.tap(find.text('X'));
await tester.pump(const Duration(milliseconds: 750)); await tester.pump(const Duration(milliseconds: 750));
await tester.pump(const Duration(milliseconds: 750)); await tester.pump(const Duration(milliseconds: 750));
await tester.scroll(find.text('snack'), const Offset(0.0, 50.0)); await tester.drag(find.text('snack'), const Offset(0.0, 50.0));
await tester.pump(); await tester.pump();
expect(closedReason, equals(SnackBarClosedReason.swipe)); expect(closedReason, equals(SnackBarClosedReason.swipe));
......
...@@ -60,21 +60,21 @@ void main() { ...@@ -60,21 +60,21 @@ void main() {
expect(value, isFalse); expect(value, isFalse);
await tester.scroll(find.byType(Switch), const Offset(-30.0, 0.0)); await tester.drag(find.byType(Switch), const Offset(-30.0, 0.0));
expect(value, isFalse); expect(value, isFalse);
await tester.scroll(find.byType(Switch), const Offset(30.0, 0.0)); await tester.drag(find.byType(Switch), const Offset(30.0, 0.0));
expect(value, isTrue); expect(value, isTrue);
await tester.pump(); await tester.pump();
await tester.scroll(find.byType(Switch), const Offset(30.0, 0.0)); await tester.drag(find.byType(Switch), const Offset(30.0, 0.0));
expect(value, isTrue); expect(value, isTrue);
await tester.pump(); await tester.pump();
await tester.scroll(find.byType(Switch), const Offset(-30.0, 0.0)); await tester.drag(find.byType(Switch), const Offset(-30.0, 0.0));
expect(value, isFalse); expect(value, isFalse);
}); });
......
...@@ -151,18 +151,15 @@ void main() { ...@@ -151,18 +151,15 @@ void main() {
expect(controller.previousIndex, 2); expect(controller.previousIndex, 2);
await tester.tap(find.text('C')); await tester.tap(find.text('C'));
await tester.pump(); await tester.pumpAndSettle();
await tester.pumpUntilNoTransientCallbacks();
expect(controller.index, 2); expect(controller.index, 2);
await tester.tap(find.text('B')); await tester.tap(find.text('B'));
await tester.pump(); await tester.pumpAndSettle();
await tester.pumpUntilNoTransientCallbacks();
expect(controller.index, 1); expect(controller.index, 1);
await tester.tap(find.text('A')); await tester.tap(find.text('A'));
await tester.pump(); await tester.pumpAndSettle();
await tester.pumpUntilNoTransientCallbacks();
expect(controller.index, 0); expect(controller.index, 0);
}); });
...@@ -179,8 +176,7 @@ void main() { ...@@ -179,8 +176,7 @@ void main() {
expect(tester.getCenter(find.text('FFFFFF')).x, greaterThan(401.0)); expect(tester.getCenter(find.text('FFFFFF')).x, greaterThan(401.0));
await tester.tap(find.text('FFFFFF')); await tester.tap(find.text('FFFFFF'));
await tester.pump(); await tester.pumpAndSettle();
await tester.pumpUntilNoTransientCallbacks();
expect(controller.index, 5); expect(controller.index, 5);
// The center of the FFFFFF item is now at the TabBar's center // The center of the FFFFFF item is now at the TabBar's center
expect(tester.getCenter(find.text('FFFFFF')).x, closeTo(400.0, 1.0)); expect(tester.getCenter(find.text('FFFFFF')).x, closeTo(400.0, 1.0));
...@@ -294,7 +290,7 @@ void main() { ...@@ -294,7 +290,7 @@ void main() {
// Fling to the left, switch from the 'LEFT' tab to the 'RIGHT' // Fling to the left, switch from the 'LEFT' tab to the 'RIGHT'
Point flingStart = tester.getCenter(find.text('LEFT CHILD')); Point flingStart = tester.getCenter(find.text('LEFT CHILD'));
await tester.flingFrom(flingStart, const Offset(-200.0, 0.0), 10000.0); await tester.flingFrom(flingStart, const Offset(-200.0, 0.0), 10000.0);
await tester.pumpUntilNoTransientCallbacks(); await tester.pumpAndSettle();
expect(controller.index, 1); expect(controller.index, 1);
expect(find.text('LEFT CHILD'), findsNothing); expect(find.text('LEFT CHILD'), findsNothing);
expect(find.text('RIGHT CHILD'), findsOneWidget); expect(find.text('RIGHT CHILD'), findsOneWidget);
...@@ -302,7 +298,7 @@ void main() { ...@@ -302,7 +298,7 @@ void main() {
// Fling to the right, switch back to the 'LEFT' tab // Fling to the right, switch back to the 'LEFT' tab
flingStart = tester.getCenter(find.text('RIGHT CHILD')); flingStart = tester.getCenter(find.text('RIGHT CHILD'));
await tester.flingFrom(flingStart, const Offset(200.0, 0.0), 10000.0); await tester.flingFrom(flingStart, const Offset(200.0, 0.0), 10000.0);
await tester.pumpUntilNoTransientCallbacks(); await tester.pumpAndSettle();
expect(controller.index, 0); expect(controller.index, 0);
expect(find.text('LEFT CHILD'), findsOneWidget); expect(find.text('LEFT CHILD'), findsOneWidget);
expect(find.text('RIGHT CHILD'), findsNothing); expect(find.text('RIGHT CHILD'), findsNothing);
...@@ -440,21 +436,21 @@ void main() { ...@@ -440,21 +436,21 @@ void main() {
}); });
await tester.tap(find.text('RIGHT')); await tester.tap(find.text('RIGHT'));
await tester.pumpUntilNoTransientCallbacks(); await tester.pumpAndSettle();
expect(value, 'RIGHT'); expect(value, 'RIGHT');
await tester.tap(find.text('LEFT')); await tester.tap(find.text('LEFT'));
await tester.pumpUntilNoTransientCallbacks(); await tester.pumpAndSettle();
expect(value, 'LEFT'); expect(value, 'LEFT');
final Point leftFlingStart = tester.getCenter(find.text('LEFT CHILD')); final Point leftFlingStart = tester.getCenter(find.text('LEFT CHILD'));
await tester.flingFrom(leftFlingStart, const Offset(-200.0, 0.0), 10000.0); await tester.flingFrom(leftFlingStart, const Offset(-200.0, 0.0), 10000.0);
await tester.pumpUntilNoTransientCallbacks(); await tester.pumpAndSettle();
expect(value, 'RIGHT'); expect(value, 'RIGHT');
final Point rightFlingStart = tester.getCenter(find.text('RIGHT CHILD')); final Point rightFlingStart = tester.getCenter(find.text('RIGHT CHILD'));
await tester.flingFrom(rightFlingStart, const Offset(200.0, 0.0), 10000.0); await tester.flingFrom(rightFlingStart, const Offset(200.0, 0.0), 10000.0);
await tester.pumpUntilNoTransientCallbacks(); await tester.pumpAndSettle();
expect(value, 'LEFT'); expect(value, 'LEFT');
}); });
......
...@@ -38,13 +38,13 @@ class _TimePickerLauncher extends StatelessWidget { ...@@ -38,13 +38,13 @@ class _TimePickerLauncher extends StatelessWidget {
Future<Point> startPicker(WidgetTester tester, ValueChanged<TimeOfDay> onChanged) async { Future<Point> startPicker(WidgetTester tester, ValueChanged<TimeOfDay> onChanged) async {
await tester.pumpWidget(new _TimePickerLauncher(onChanged: onChanged)); await tester.pumpWidget(new _TimePickerLauncher(onChanged: onChanged));
await tester.tap(find.text('X')); await tester.tap(find.text('X'));
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
return tester.getCenter(find.byKey(const Key('time-picker-dial'))); return tester.getCenter(find.byKey(const Key('time-picker-dial')));
} }
Future<Null> finishPicker(WidgetTester tester) async { Future<Null> finishPicker(WidgetTester tester) async {
await tester.tap(find.text('OK')); await tester.tap(find.text('OK'));
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
} }
void main() { void main() {
......
...@@ -35,7 +35,7 @@ void main() { ...@@ -35,7 +35,7 @@ void main() {
// Scroll the target text widget by offset and then return its origin // Scroll the target text widget by offset and then return its origin
// in global coordinates. // in global coordinates.
Future<Point> locationAfterScroll(String target, Offset offset) async { Future<Point> locationAfterScroll(String target, Offset offset) async {
await tester.scrollAt(tester.getTopLeft(find.text(target)), offset); await tester.dragFrom(tester.getTopLeft(find.text(target)), offset);
await tester.pump(); await tester.pump();
final RenderBox textBox = tester.renderObject(find.text(target)); final RenderBox textBox = tester.renderObject(find.text(target));
final Point widgetOrigin = textBox.localToGlobal(Point.origin); final Point widgetOrigin = textBox.localToGlobal(Point.origin);
...@@ -64,12 +64,12 @@ void main() { ...@@ -64,12 +64,12 @@ void main() {
await tester.pumpWidget(buildFrame(const BouncingScrollPhysics())); await tester.pumpWidget(buildFrame(const BouncingScrollPhysics()));
ScrollableState scrollable = tester.state(find.byType(Scrollable)); ScrollableState scrollable = tester.state(find.byType(Scrollable));
await tester.scrollAt(tester.getTopLeft(find.text('top')), const Offset(0.0, 400.0)); await tester.dragFrom(tester.getTopLeft(find.text('top')), const Offset(0.0, 400.0));
await tester.pump(); await tester.pump();
expect(scrollable.position.pixels, lessThan(0.0)); expect(scrollable.position.pixels, lessThan(0.0));
await tester.pump(const Duration(seconds: 1)); // Allow overscroll to settle await tester.pump(const Duration(seconds: 1)); // Allow overscroll to settle
await tester.scrollAt(tester.getTopLeft(find.text('bottom')), const Offset(0.0, -400.0)); await tester.dragFrom(tester.getTopLeft(find.text('bottom')), const Offset(0.0, -400.0));
await tester.pump(); await tester.pump();
expect(scrollable.position.pixels, greaterThan(0.0)); expect(scrollable.position.pixels, greaterThan(0.0));
await tester.pump(const Duration(seconds: 1)); // Allow overscroll to settle await tester.pump(const Duration(seconds: 1)); // Allow overscroll to settle
...@@ -79,12 +79,12 @@ void main() { ...@@ -79,12 +79,12 @@ void main() {
await tester.pumpWidget(buildFrame(const ClampingScrollPhysics())); await tester.pumpWidget(buildFrame(const ClampingScrollPhysics()));
scrollable = scrollable = tester.state(find.byType(Scrollable)); scrollable = scrollable = tester.state(find.byType(Scrollable));
await tester.scrollAt(tester.getTopLeft(find.text('top')), const Offset(0.0, 400.0)); await tester.dragFrom(tester.getTopLeft(find.text('top')), const Offset(0.0, 400.0));
await tester.pump(); await tester.pump();
expect(scrollable.position.pixels, equals(0.0)); expect(scrollable.position.pixels, equals(0.0));
await tester.pump(const Duration(seconds: 1)); // Allow overscroll to settle await tester.pump(const Duration(seconds: 1)); // Allow overscroll to settle
await tester.scrollAt(tester.getTopLeft(find.text('bottom')), const Offset(0.0, -400.0)); await tester.dragFrom(tester.getTopLeft(find.text('bottom')), const Offset(0.0, -400.0));
await tester.pump(); await tester.pump();
expect(scrollable.position.pixels, equals(50.0)); expect(scrollable.position.pixels, equals(50.0));
}); });
......
...@@ -118,7 +118,7 @@ void main() { ...@@ -118,7 +118,7 @@ void main() {
expect(panDelta, isNull); expect(panDelta, isNull);
expect(didEndPan, isFalse); expect(didEndPan, isFalse);
await tester.scrollAt(const Point(10.0, 10.0), const Offset(20.0, 30.0)); await tester.dragFrom(const Point(10.0, 10.0), const Offset(20.0, 30.0));
expect(didStartPan, isTrue); expect(didStartPan, isTrue);
expect(panDelta.dx, 20.0); expect(panDelta.dx, 20.0);
......
...@@ -47,7 +47,7 @@ void main() { ...@@ -47,7 +47,7 @@ void main() {
expect(find.text(kStates[12]), findsNothing); expect(find.text(kStates[12]), findsNothing);
expect(find.text('Nevada'), findsNothing); expect(find.text('Nevada'), findsNothing);
await tester.scroll(find.text('Arkansas'), const Offset(0.0, -200.0)); await tester.drag(find.text('Arkansas'), const Offset(0.0, -200.0));
await tester.pump(); await tester.pump();
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
...@@ -59,7 +59,7 @@ void main() { ...@@ -59,7 +59,7 @@ void main() {
log.clear(); log.clear();
} }
await tester.scroll(find.text('Delaware'), const Offset(0.0, -4000.0)); await tester.drag(find.text('Delaware'), const Offset(0.0, -4000.0));
await tester.pump(); await tester.pump();
expect(find.text('Alabama'), findsNothing); expect(find.text('Alabama'), findsNothing);
...@@ -72,7 +72,7 @@ void main() { ...@@ -72,7 +72,7 @@ void main() {
expect(log, equals(<String>['Tennessee'])); expect(log, equals(<String>['Tennessee']));
log.clear(); log.clear();
await tester.scroll(find.text('Tennessee'), const Offset(0.0, 200.0)); await tester.drag(find.text('Tennessee'), const Offset(0.0, 200.0));
await tester.pump(); await tester.pump();
await tester.tap(find.text('Tennessee')); await tester.tap(find.text('Tennessee'));
...@@ -114,7 +114,7 @@ void main() { ...@@ -114,7 +114,7 @@ void main() {
expect(find.text('Nevada'), findsNothing); expect(find.text('Nevada'), findsNothing);
await tester.scroll(find.text('Arkansas'), const Offset(0.0, -4000.0)); await tester.drag(find.text('Arkansas'), const Offset(0.0, -4000.0));
await tester.pump(); await tester.pump();
expect(find.text('Alabama'), findsNothing); expect(find.text('Alabama'), findsNothing);
......
...@@ -713,7 +713,7 @@ void main() { ...@@ -713,7 +713,7 @@ void main() {
// Scroll the target upwards by 25 pixels. The Hero flight's Y coordinate // Scroll the target upwards by 25 pixels. The Hero flight's Y coordinate
// will be redirected from 100 to 75. // will be redirected from 100 to 75.
await(tester.scroll(find.byKey(routeContainerKey), const Offset(0.0, -25.0))); await(tester.drag(find.byKey(routeContainerKey), const Offset(0.0, -25.0)));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
final double yAt110ms = tester.getTopLeft(find.byKey(routeHeroKey)).y; final double yAt110ms = tester.getTopLeft(find.byKey(routeHeroKey)).y;
...@@ -788,7 +788,7 @@ void main() { ...@@ -788,7 +788,7 @@ void main() {
expect(yAt100ms, lessThan(200.0)); expect(yAt100ms, lessThan(200.0));
expect(yAt100ms, greaterThan(100.0)); expect(yAt100ms, greaterThan(100.0));
await(tester.scroll(find.byKey(routeContainerKey), const Offset(0.0, -400.0))); await(tester.drag(find.byKey(routeContainerKey), const Offset(0.0, -400.0)));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
expect(find.byKey(routeContainerKey), findsNothing); // Scrolled off the top expect(find.byKey(routeContainerKey), findsNothing); // Scrolled off the top
......
...@@ -32,7 +32,7 @@ void main() { ...@@ -32,7 +32,7 @@ void main() {
await tester.pumpWidget(buildFrame()); await tester.pumpWidget(buildFrame());
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
await tester.scroll(find.text('1'), const Offset(-300.0, 0.0)); await tester.drag(find.text('1'), const Offset(-300.0, 0.0));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
// screen is 800px wide, and has the following items: // screen is 800px wide, and has the following items:
// -10..280 = 1 // -10..280 = 1
...@@ -47,9 +47,9 @@ void main() { ...@@ -47,9 +47,9 @@ void main() {
// the center of item 3 is visible, so this works; // the center of item 3 is visible, so this works;
// if item 3 was a bit wider, such that its center was past the 800px mark, this would fail, // if item 3 was a bit wider, such that its center was past the 800px mark, this would fail,
// because it wouldn't be hit tested when scrolling from its center, as scroll() does. // because it wouldn't be hit tested when scrolling from its center, as drag() does.
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
await tester.scroll(find.text('3'), const Offset(-290.0, 0.0)); await tester.drag(find.text('3'), const Offset(-290.0, 0.0));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
// screen is 800px wide, and has the following items: // screen is 800px wide, and has the following items:
// -10..280 = 2 // -10..280 = 2
...@@ -63,7 +63,7 @@ void main() { ...@@ -63,7 +63,7 @@ void main() {
expect(find.text('5'), findsNothing); expect(find.text('5'), findsNothing);
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
await tester.scroll(find.text('3'), const Offset(0.0, -290.0)); await tester.drag(find.text('3'), const Offset(0.0, -290.0));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
// unchanged // unchanged
expect(find.text('0'), findsNothing); expect(find.text('0'), findsNothing);
...@@ -74,7 +74,7 @@ void main() { ...@@ -74,7 +74,7 @@ void main() {
expect(find.text('5'), findsNothing); expect(find.text('5'), findsNothing);
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
await tester.scroll(find.text('3'), const Offset(-290.0, 0.0)); await tester.drag(find.text('3'), const Offset(-290.0, 0.0));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
// screen is 800px wide, and has the following items: // screen is 800px wide, and has the following items:
// -10..280 = 3 // -10..280 = 3
...@@ -93,7 +93,7 @@ void main() { ...@@ -93,7 +93,7 @@ void main() {
// to move item 3 entirely off screen therefore takes: // to move item 3 entirely off screen therefore takes:
// 60 + (290-60)*2 = 520 pixels // 60 + (290-60)*2 = 520 pixels
// plus a couple more to be sure // plus a couple more to be sure
await tester.scroll(find.text('3'), const Offset(-522.0, 0.0)); await tester.drag(find.text('3'), const Offset(-522.0, 0.0));
await tester.pump(); // just after release await tester.pump(); // just after release
// screen is 800px wide, and has the following items: // screen is 800px wide, and has the following items:
// -11..279 = 4 // -11..279 = 4
...@@ -118,7 +118,7 @@ void main() { ...@@ -118,7 +118,7 @@ void main() {
await tester.pumpWidget(new Container()); await tester.pumpWidget(new Container());
await tester.pumpWidget(buildFrame(), const Duration(seconds: 1)); await tester.pumpWidget(buildFrame(), const Duration(seconds: 1));
await tester.scroll(find.text('2'), const Offset(-280.0, 0.0)); await tester.drag(find.text('2'), const Offset(-280.0, 0.0));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
// screen is 800px wide, and has the following items: // screen is 800px wide, and has the following items:
// -280..10 = 0 // -280..10 = 0
...@@ -132,7 +132,7 @@ void main() { ...@@ -132,7 +132,7 @@ void main() {
expect(find.text('4'), findsNothing); expect(find.text('4'), findsNothing);
expect(find.text('5'), findsNothing); expect(find.text('5'), findsNothing);
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
await tester.scroll(find.text('2'), const Offset(-290.0, 0.0)); await tester.drag(find.text('2'), const Offset(-290.0, 0.0));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
// screen is 800px wide, and has the following items: // screen is 800px wide, and has the following items:
// -280..10 = 1 // -280..10 = 1
...@@ -162,7 +162,7 @@ void main() { ...@@ -162,7 +162,7 @@ void main() {
expect(find.text('4'), findsNothing); expect(find.text('4'), findsNothing);
expect(find.text('5'), findsNothing); expect(find.text('5'), findsNothing);
await tester.scroll(find.text('0'), const Offset(300.0, 0.0)); await tester.drag(find.text('0'), const Offset(300.0, 0.0));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
// screen is 800px wide, and has the following items: // screen is 800px wide, and has the following items:
// -80..210 = 3 // -80..210 = 3
...@@ -177,9 +177,9 @@ void main() { ...@@ -177,9 +177,9 @@ void main() {
// the center of item 3 is visible, so this works; // the center of item 3 is visible, so this works;
// if item 3 was a bit wider, such that its center was past the 800px mark, this would fail, // if item 3 was a bit wider, such that its center was past the 800px mark, this would fail,
// because it wouldn't be hit tested when scrolling from its center, as scroll() does. // because it wouldn't be hit tested when scrolling from its center, as drag() does.
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
await tester.scroll(find.text('2'), const Offset(290.0, 0.0)); await tester.drag(find.text('2'), const Offset(290.0, 0.0));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
// screen is 800px wide, and has the following items: // screen is 800px wide, and has the following items:
// -10..280 = 4 // -10..280 = 4
...@@ -193,7 +193,7 @@ void main() { ...@@ -193,7 +193,7 @@ void main() {
expect(find.text('5'), findsNothing); expect(find.text('5'), findsNothing);
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
await tester.scroll(find.text('2'), const Offset(0.0, 290.0)); await tester.drag(find.text('2'), const Offset(0.0, 290.0));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
// unchanged // unchanged
expect(find.text('0'), findsNothing); expect(find.text('0'), findsNothing);
...@@ -204,7 +204,7 @@ void main() { ...@@ -204,7 +204,7 @@ void main() {
expect(find.text('5'), findsNothing); expect(find.text('5'), findsNothing);
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
await tester.scroll(find.text('3'), const Offset(290.0, 0.0)); await tester.drag(find.text('3'), const Offset(290.0, 0.0));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
// screen is 800px wide, and has the following items: // screen is 800px wide, and has the following items:
// -10..280 = 5 // -10..280 = 5
...@@ -223,7 +223,7 @@ void main() { ...@@ -223,7 +223,7 @@ void main() {
// to move item 3 entirely off screen therefore takes: // to move item 3 entirely off screen therefore takes:
// 60 + (290-60)*2 = 520 pixels // 60 + (290-60)*2 = 520 pixels
// plus a couple more to be sure // plus a couple more to be sure
await tester.scroll(find.text('4'), const Offset(522.0, 0.0)); await tester.drag(find.text('4'), const Offset(522.0, 0.0));
await tester.pump(); // just after release await tester.pump(); // just after release
// screen is 800px wide, and has the following items: // screen is 800px wide, and has the following items:
// 280..570 = 5 // 280..570 = 5
......
...@@ -31,7 +31,7 @@ void main() { ...@@ -31,7 +31,7 @@ void main() {
expect(find.text('3'), findsNothing); expect(find.text('3'), findsNothing);
expect(find.text('4'), findsNothing); expect(find.text('4'), findsNothing);
await tester.scroll(find.byType(ListView), const Offset(0.0, -250.0)); await tester.drag(find.byType(ListView), const Offset(0.0, -250.0));
await tester.pump(); await tester.pump();
expect(find.text('0'), findsNothing); expect(find.text('0'), findsNothing);
...@@ -42,7 +42,7 @@ void main() { ...@@ -42,7 +42,7 @@ void main() {
expect(find.text('5'), findsNothing); expect(find.text('5'), findsNothing);
expect(find.text('6'), findsNothing); expect(find.text('6'), findsNothing);
await tester.scroll(find.byType(ListView), const Offset(0.0, 200.0)); await tester.drag(find.byType(ListView), const Offset(0.0, 200.0));
await tester.pump(); await tester.pump();
expect(find.text('0'), findsOneWidget); expect(find.text('0'), findsOneWidget);
......
...@@ -24,7 +24,7 @@ void main() { ...@@ -24,7 +24,7 @@ void main() {
await tester.pumpWidget(buildFrame()); await tester.pumpWidget(buildFrame());
await tester.pump(); await tester.pump();
await tester.scroll(find.text('1'), const Offset(0.0, -300.0)); await tester.drag(find.text('1'), const Offset(0.0, -300.0));
await tester.pump(); await tester.pump();
// screen is 600px high, and has the following items: // screen is 600px high, and has the following items:
// -10..280 = 1 // -10..280 = 1
...@@ -38,7 +38,7 @@ void main() { ...@@ -38,7 +38,7 @@ void main() {
expect(find.text('5'), findsNothing); expect(find.text('5'), findsNothing);
await tester.pump(); await tester.pump();
await tester.scroll(find.text('2'), const Offset(0.0, -290.0)); await tester.drag(find.text('2'), const Offset(0.0, -290.0));
await tester.pump(); await tester.pump();
// screen is 600px high, and has the following items: // screen is 600px high, and has the following items:
// -10..280 = 2 // -10..280 = 2
...@@ -52,7 +52,7 @@ void main() { ...@@ -52,7 +52,7 @@ void main() {
expect(find.text('5'), findsNothing); expect(find.text('5'), findsNothing);
await tester.pump(); await tester.pump();
await tester.scroll(find.text('3'), const Offset(-300.0, 0.0)); await tester.drag(find.text('3'), const Offset(-300.0, 0.0));
await tester.pump(); await tester.pump();
// nothing should have changed // nothing should have changed
expect(find.text('0'), findsNothing); expect(find.text('0'), findsNothing);
...@@ -88,7 +88,7 @@ void main() { ...@@ -88,7 +88,7 @@ void main() {
expect(find.text('4'), findsNothing); expect(find.text('4'), findsNothing);
expect(find.text('5'), findsNothing); expect(find.text('5'), findsNothing);
await tester.scroll(find.text('0'), const Offset(0.0, -300.0)); await tester.drag(find.text('0'), const Offset(0.0, -300.0));
await tester.pump(); await tester.pump();
// screen is 600px high, and has the following items: // screen is 600px high, and has the following items:
// -50..240 = 0 // -50..240 = 0
......
...@@ -35,7 +35,7 @@ void main() { ...@@ -35,7 +35,7 @@ void main() {
expect(painter, doesNotOverscroll); expect(painter, doesNotOverscroll);
// the scroll gesture from tester.scroll happens in zero time, so nothing should appear: // the scroll gesture from tester.scroll happens in zero time, so nothing should appear:
await tester.scroll(find.byType(Scrollable), const Offset(0.0, 100.0)); await tester.drag(find.byType(Scrollable), const Offset(0.0, 100.0));
expect(painter, doesNotOverscroll); expect(painter, doesNotOverscroll);
await tester.pump(); // allow the ticker to register itself await tester.pump(); // allow the ticker to register itself
expect(painter, doesNotOverscroll); expect(painter, doesNotOverscroll);
...@@ -51,7 +51,7 @@ void main() { ...@@ -51,7 +51,7 @@ void main() {
await slowDrag(tester, const Point(200.0, 200.0), const Offset(0.0, 5.0)); await slowDrag(tester, const Point(200.0, 200.0), const Offset(0.0, 5.0));
expect(painter, paints..circle(color: const Color(0x0DFFFFFF))); expect(painter, paints..circle(color: const Color(0x0DFFFFFF)));
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
expect(painter, doesNotOverscroll); expect(painter, doesNotOverscroll);
}); });
...@@ -86,7 +86,7 @@ void main() { ...@@ -86,7 +86,7 @@ void main() {
throw 'Dragging on right hand side did not overscroll on right hand side.'; throw 'Dragging on right hand side did not overscroll on right hand side.';
})); }));
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
expect(painter, doesNotOverscroll); expect(painter, doesNotOverscroll);
}); });
...@@ -118,7 +118,7 @@ void main() { ...@@ -118,7 +118,7 @@ void main() {
} }
await gesture.up(); await gesture.up();
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
expect(painter, doesNotOverscroll); expect(painter, doesNotOverscroll);
}); });
...@@ -136,7 +136,7 @@ void main() { ...@@ -136,7 +136,7 @@ void main() {
await slowDrag(tester, const Point(200.0, 200.0), const Offset(0.0, 5.0)); await slowDrag(tester, const Point(200.0, 200.0), const Offset(0.0, 5.0));
expect(painter, paints..save()..circle()..restore()..save()..scale(y: -1.0)..restore()..restore()); expect(painter, paints..save()..circle()..restore()..save()..scale(y: -1.0)..restore()..restore());
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
expect(painter, doesNotOverscroll); expect(painter, doesNotOverscroll);
}); });
...@@ -154,7 +154,7 @@ void main() { ...@@ -154,7 +154,7 @@ void main() {
await slowDrag(tester, const Point(200.0, 200.0), const Offset(0.0, 5.0)); await slowDrag(tester, const Point(200.0, 200.0), const Offset(0.0, 5.0));
expect(painter, paints..save()..scale(y: -1.0)..restore()..save()..circle()..restore()..restore()); expect(painter, paints..save()..scale(y: -1.0)..restore()..save()..circle()..restore()..restore());
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
expect(painter, doesNotOverscroll); expect(painter, doesNotOverscroll);
}); });
}); });
...@@ -175,7 +175,7 @@ void main() { ...@@ -175,7 +175,7 @@ void main() {
await slowDrag(tester, const Point(200.0, 200.0), const Offset(0.0, -5.0)); await slowDrag(tester, const Point(200.0, 200.0), const Offset(0.0, -5.0));
expect(painter, paints..circle()..circle()); expect(painter, paints..circle()..circle());
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
expect(painter, doesNotOverscroll); expect(painter, doesNotOverscroll);
}); });
...@@ -197,7 +197,7 @@ void main() { ...@@ -197,7 +197,7 @@ void main() {
expect(painter, paints..rotate(angle: math.PI / 2.0)..circle() expect(painter, paints..rotate(angle: math.PI / 2.0)..circle()
..rotate(angle: math.PI / 2.0)..circle()); ..rotate(angle: math.PI / 2.0)..circle());
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
expect(painter, doesNotOverscroll); expect(painter, doesNotOverscroll);
}); });
...@@ -220,8 +220,8 @@ void main() { ...@@ -220,8 +220,8 @@ void main() {
), ),
); );
await tester.scrollAt(const Point(100.0, 100.0), const Offset(0.0, 2000.0)); await tester.dragFrom(const Point(100.0, 100.0), const Offset(0.0, 2000.0));
await tester.pumpUntilNoTransientCallbacks(); await tester.pumpAndSettle();
}); });
testWidgets('Changing settings', (WidgetTester tester) async { testWidgets('Changing settings', (WidgetTester tester) async {
...@@ -245,7 +245,7 @@ void main() { ...@@ -245,7 +245,7 @@ void main() {
expect(painter, paints..rotate(angle: math.PI / 2.0)..circle(color: const Color(0x0A00FF00))); expect(painter, paints..rotate(angle: math.PI / 2.0)..circle(color: const Color(0x0A00FF00)));
expect(painter, isNot(paints..circle()..circle())); expect(painter, isNot(paints..circle()..circle()));
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
await tester.pumpWidget( await tester.pumpWidget(
new ScrollConfiguration( new ScrollConfiguration(
behavior: new TestScrollBehavior2(), behavior: new TestScrollBehavior2(),
......
...@@ -37,20 +37,20 @@ void main() { ...@@ -37,20 +37,20 @@ void main() {
expect(find.text('Alaska'), findsNothing); expect(find.text('Alaska'), findsNothing);
await tester.scroll(find.byType(PageView), const Offset(-10.0, 0.0)); await tester.drag(find.byType(PageView), const Offset(-10.0, 0.0));
await tester.pump(); await tester.pump();
expect(find.text('Alabama'), findsOneWidget); expect(find.text('Alabama'), findsOneWidget);
expect(find.text('Alaska'), findsOneWidget); expect(find.text('Alaska'), findsOneWidget);
expect(find.text('Arizona'), findsNothing); expect(find.text('Arizona'), findsNothing);
await tester.pumpUntilNoTransientCallbacks(_frameDuration); await tester.pumpAndSettle(_frameDuration);
expect(find.text('Alabama'), findsOneWidget); expect(find.text('Alabama'), findsOneWidget);
expect(find.text('Alaska'), findsNothing); expect(find.text('Alaska'), findsNothing);
await tester.scroll(find.byType(PageView), const Offset(-401.0, 0.0)); await tester.drag(find.byType(PageView), const Offset(-401.0, 0.0));
await tester.pumpUntilNoTransientCallbacks(_frameDuration); await tester.pumpAndSettle(_frameDuration);
expect(find.text('Alabama'), findsNothing); expect(find.text('Alabama'), findsNothing);
expect(find.text('Alaska'), findsOneWidget); expect(find.text('Alaska'), findsOneWidget);
...@@ -62,14 +62,14 @@ void main() { ...@@ -62,14 +62,14 @@ void main() {
await tester.fling( await tester.fling(
find.byType(PageView), const Offset(-200.0, 0.0), 1000.0); find.byType(PageView), const Offset(-200.0, 0.0), 1000.0);
await tester.pumpUntilNoTransientCallbacks(_frameDuration); await tester.pumpAndSettle(_frameDuration);
expect(find.text('Alabama'), findsNothing); expect(find.text('Alabama'), findsNothing);
expect(find.text('Alaska'), findsNothing); expect(find.text('Alaska'), findsNothing);
expect(find.text('Arizona'), findsOneWidget); expect(find.text('Arizona'), findsOneWidget);
await tester.fling(find.byType(PageView), const Offset(200.0, 0.0), 1000.0); await tester.fling(find.byType(PageView), const Offset(200.0, 0.0), 1000.0);
await tester.pumpUntilNoTransientCallbacks(_frameDuration); await tester.pumpAndSettle(_frameDuration);
expect(find.text('Alabama'), findsNothing); expect(find.text('Alabama'), findsNothing);
expect(find.text('Alaska'), findsOneWidget); expect(find.text('Alaska'), findsOneWidget);
...@@ -93,19 +93,18 @@ void main() { ...@@ -93,19 +93,18 @@ void main() {
)); ));
Size sizeOf(int i) => tester.getSize(find.byKey(new ValueKey<int>(i))); Size sizeOf(int i) => tester.getSize(find.byKey(new ValueKey<int>(i)));
double leftOf(int i) => double leftOf(int i) => tester.getTopLeft(find.byKey(new ValueKey<int>(i))).x;
tester.getTopLeft(find.byKey(new ValueKey<int>(i))).x;
expect(leftOf(0), equals(0.0)); expect(leftOf(0), equals(0.0));
expect(sizeOf(0), equals(const Size(800.0, 600.0))); expect(sizeOf(0), equals(const Size(800.0, 600.0)));
await tester.scroll(find.byType(PageView), const Offset(100.0, 0.0)); await tester.drag(find.byType(PageView), const Offset(100.0, 0.0));
await tester.pump(); await tester.pump();
expect(leftOf(0), equals(100.0)); expect(leftOf(0), equals(100.0));
expect(sizeOf(0), equals(const Size(800.0, 600.0))); expect(sizeOf(0), equals(const Size(800.0, 600.0)));
await tester.scroll(find.byType(PageView), const Offset(-200.0, 0.0)); await tester.drag(find.byType(PageView), const Offset(-200.0, 0.0));
await tester.pump(); await tester.pump();
expect(leftOf(0), equals(-100.0)); expect(leftOf(0), equals(-100.0));
...@@ -121,18 +120,15 @@ void main() { ...@@ -121,18 +120,15 @@ void main() {
height: 400.0, height: 400.0,
child: new PageView( child: new PageView(
controller: controller, controller: controller,
children: children: kStates.map<Widget>((String state) => new Text(state)).toList(),
kStates.map<Widget>((String state) => new Text(state)).toList(),
), ),
), ),
)); ));
expect(find.text('California'), findsOneWidget); expect(find.text('California'), findsOneWidget);
controller.nextPage( controller.nextPage(duration: const Duration(milliseconds: 150), curve: Curves.ease);
duration: const Duration(milliseconds: 150), curve: Curves.ease); await tester.pumpAndSettle(const Duration(milliseconds: 100));
await tester
.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100));
expect(find.text('Colorado'), findsOneWidget); expect(find.text('Colorado'), findsOneWidget);
...@@ -142,18 +138,15 @@ void main() { ...@@ -142,18 +138,15 @@ void main() {
height: 400.0, height: 400.0,
child: new PageView( child: new PageView(
controller: controller, controller: controller,
children: children: kStates.map<Widget>((String state) => new Text(state)).toList(),
kStates.map<Widget>((String state) => new Text(state)).toList(),
), ),
), ),
)); ));
expect(find.text('Colorado'), findsOneWidget); expect(find.text('Colorado'), findsOneWidget);
controller.previousPage( controller.previousPage(duration: const Duration(milliseconds: 150), curve: Curves.ease);
duration: const Duration(milliseconds: 150), curve: Curves.ease); await tester.pumpAndSettle(const Duration(milliseconds: 100));
await tester
.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100));
expect(find.text('California'), findsOneWidget); expect(find.text('California'), findsOneWidget);
}); });
...@@ -164,17 +157,15 @@ void main() { ...@@ -164,17 +157,15 @@ void main() {
width: 600.0, width: 600.0,
height: 400.0, height: 400.0,
child: new PageView( child: new PageView(
children: children: kStates.map<Widget>((String state) => new Text(state)).toList(),
kStates.map<Widget>((String state) => new Text(state)).toList(),
), ),
), ),
)); ));
expect(find.text('Alabama'), findsOneWidget); expect(find.text('Alabama'), findsOneWidget);
await tester.scroll(find.byType(PageView), const Offset(-1250.0, 0.0)); await tester.drag(find.byType(PageView), const Offset(-1250.0, 0.0));
await tester await tester.pumpAndSettle(const Duration(milliseconds: 100));
.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100));
expect(find.text('Arizona'), findsOneWidget); expect(find.text('Arizona'), findsOneWidget);
...@@ -183,8 +174,7 @@ void main() { ...@@ -183,8 +174,7 @@ void main() {
width: 250.0, width: 250.0,
height: 100.0, height: 100.0,
child: new PageView( child: new PageView(
children: children: kStates.map<Widget>((String state) => new Text(state)).toList(),
kStates.map<Widget>((String state) => new Text(state)).toList(),
), ),
), ),
)); ));
...@@ -196,8 +186,7 @@ void main() { ...@@ -196,8 +186,7 @@ void main() {
width: 450.0, width: 450.0,
height: 400.0, height: 400.0,
child: new PageView( child: new PageView(
children: children: kStates.map<Widget>((String state) => new Text(state)).toList(),
kStates.map<Widget>((String state) => new Text(state)).toList(),
), ),
), ),
)); ));
...@@ -211,8 +200,7 @@ void main() { ...@@ -211,8 +200,7 @@ void main() {
width: 0.0, width: 0.0,
height: 0.0, height: 0.0,
child: new PageView( child: new PageView(
children: children: kStates.map<Widget>((String state) => new Text(state)).toList(),
kStates.map<Widget>((String state) => new Text(state)).toList(),
), ),
), ),
)); ));
...@@ -224,8 +212,7 @@ void main() { ...@@ -224,8 +212,7 @@ void main() {
width: 200.0, width: 200.0,
height: 200.0, height: 200.0,
child: new PageView( child: new PageView(
children: children: kStates.map<Widget>((String state) => new Text(state)).toList(),
kStates.map<Widget>((String state) => new Text(state)).toList(),
), ),
), ),
)); ));
...@@ -274,7 +261,7 @@ void main() { ...@@ -274,7 +261,7 @@ void main() {
expect(log, isEmpty); expect(log, isEmpty);
await gesture.up(); await gesture.up();
await tester.pumpUntilNoTransientCallbacks(); await tester.pumpAndSettle();
expect(log, isEmpty); expect(log, isEmpty);
...@@ -352,8 +339,7 @@ void main() { ...@@ -352,8 +339,7 @@ void main() {
controller.jumpToPage(10); controller.jumpToPage(10);
await tester.pump(); await tester.pump();
expect( expect(tester.getTopLeft(find.text('Connecticut')), const Point(-50.0, 0.0));
tester.getTopLeft(find.text('Connecticut')), const Point(-50.0, 0.0));
expect(tester.getTopLeft(find.text('Delaware')), const Point(50.0, 0.0)); expect(tester.getTopLeft(find.text('Delaware')), const Point(50.0, 0.0));
expect(tester.getTopLeft(find.text('Florida')), const Point(150.0, 0.0)); expect(tester.getTopLeft(find.text('Florida')), const Point(150.0, 0.0));
expect(tester.getTopLeft(find.text('Georgia')), const Point(250.0, 0.0)); expect(tester.getTopLeft(find.text('Georgia')), const Point(250.0, 0.0));
...@@ -387,8 +373,7 @@ void main() { ...@@ -387,8 +373,7 @@ void main() {
await tester.pumpWidget(build(controller)); await tester.pumpWidget(build(controller));
expect(tester.getTopLeft(find.text('Alabama')), const Point(-100.0, 0.0)); expect(tester.getTopLeft(find.text('Alabama')), const Point(-100.0, 0.0));
expect( expect(tester.getBottomRight(find.text('Alabama')), const Point(900.0, 600.0));
tester.getBottomRight(find.text('Alabama')), const Point(900.0, 600.0));
controller.jumpToPage(10); controller.jumpToPage(10);
await tester.pump(); await tester.pump();
...@@ -398,8 +383,9 @@ void main() { ...@@ -398,8 +383,9 @@ void main() {
testWidgets('PageView does not report page changed on overscroll', testWidgets('PageView does not report page changed on overscroll',
(WidgetTester tester) async { (WidgetTester tester) async {
final PageController controller = final PageController controller = new PageController(
new PageController(initialPage: kStates.length - 1); initialPage: kStates.length - 1,
);
int changeIndex = 0; int changeIndex = 0;
Widget build() { Widget build() {
return new PageView( return new PageView(
......
...@@ -43,9 +43,8 @@ Widget buildFrame({ ...@@ -43,9 +43,8 @@ Widget buildFrame({
Future<Null> page(WidgetTester tester, Offset offset) { Future<Null> page(WidgetTester tester, Offset offset) {
return TestAsyncUtils.guard(() async { return TestAsyncUtils.guard(() async {
final String itemText = currentPage != null ? currentPage.toString() : '0'; final String itemText = currentPage != null ? currentPage.toString() : '0';
await tester.scroll(find.text(itemText), offset); await tester.drag(find.text(itemText), offset);
await tester.pump(); await tester.pumpAndSettle();
await tester.pumpUntilNoTransientCallbacks();
}); });
} }
......
...@@ -39,7 +39,7 @@ void main() { ...@@ -39,7 +39,7 @@ void main() {
expect(realOffset(), equals(controller.offset)); expect(realOffset(), equals(controller.offset));
controller.animateTo(326.0, duration: const Duration(milliseconds: 300), curve: Curves.ease); controller.animateTo(326.0, duration: const Duration(milliseconds: 300), curve: Curves.ease);
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100)); await tester.pumpAndSettle(const Duration(milliseconds: 100));
expect(controller.offset, equals(326.0)); expect(controller.offset, equals(326.0));
expect(realOffset(), equals(controller.offset)); expect(realOffset(), equals(controller.offset));
...@@ -228,7 +228,6 @@ void main() { ...@@ -228,7 +228,6 @@ void main() {
controller.jumpTo(1.0); controller.jumpTo(1.0);
controller.animateTo(1.0, duration: const Duration(seconds: 1), curve: Curves.linear); controller.animateTo(1.0, duration: const Duration(seconds: 1), curve: Curves.linear);
await tester.pump(); await tester.pumpAndSettle();
await tester.pumpUntilNoTransientCallbacks();
}); });
} }
...@@ -34,7 +34,7 @@ void main() { ...@@ -34,7 +34,7 @@ void main() {
expect(find.text('Nevada'), findsNothing); expect(find.text('Nevada'), findsNothing);
await tester.scroll(find.text('Alabama'), const Offset(0.0, -4000.0)); await tester.drag(find.text('Alabama'), const Offset(0.0, -4000.0));
await tester.pump(); await tester.pump();
expect(find.text('Alabama'), findsNothing); expect(find.text('Alabama'), findsNothing);
...@@ -67,7 +67,7 @@ void main() { ...@@ -67,7 +67,7 @@ void main() {
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100)); await tester.pumpAndSettle(const Duration(milliseconds: 100));
final Viewport viewport = tester.widget(find.byType(Viewport)); final Viewport viewport = tester.widget(find.byType(Viewport));
expect(viewport.offset.pixels, equals(2400.0)); expect(viewport.offset.pixels, equals(2400.0));
...@@ -105,7 +105,7 @@ void main() { ...@@ -105,7 +105,7 @@ void main() {
expect(find.text('Nevada'), findsNothing); expect(find.text('Nevada'), findsNothing);
await tester.scroll(find.text('Alabama'), const Offset(0.0, -4000.0)); await tester.drag(find.text('Alabama'), const Offset(0.0, -4000.0));
await tester.pump(); await tester.pump();
expect(find.text('Alabama'), findsNothing); expect(find.text('Alabama'), findsNothing);
......
...@@ -44,7 +44,7 @@ void main() { ...@@ -44,7 +44,7 @@ void main() {
expect(find.text('2'), findsNothing); expect(find.text('2'), findsNothing);
expect(find.text('3'), findsNothing); expect(find.text('3'), findsNothing);
await tester.scroll(find.text('1'), const Offset(0.0, -500.0)); await tester.drag(find.text('1'), const Offset(0.0, -500.0));
await tester.pump(); await tester.pump();
// -100..300 = 1 // -100..300 = 1
// 300..600 = 2 // 300..600 = 2
...@@ -56,7 +56,7 @@ void main() { ...@@ -56,7 +56,7 @@ void main() {
expect(find.text('4'), findsNothing); expect(find.text('4'), findsNothing);
expect(find.text('5'), findsNothing); expect(find.text('5'), findsNothing);
await tester.scroll(find.text('1'), const Offset(0.0, 150.0)); await tester.drag(find.text('1'), const Offset(0.0, 150.0));
await tester.pump(); await tester.pump();
// Child '0' is now back onscreen, but by less than `padding.top`. // Child '0' is now back onscreen, but by less than `padding.top`.
// -250..050 = 0 // -250..050 = 0
......
...@@ -28,7 +28,7 @@ void main() { ...@@ -28,7 +28,7 @@ void main() {
), ),
), ),
)); ));
await tester.scroll(find.text('2'), const Offset(-280.0, 0.0)); await tester.drag(find.text('2'), const Offset(-280.0, 0.0));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
// screen is 800px wide, and has the following items: // screen is 800px wide, and has the following items:
// -280..10 = 0 // -280..10 = 0
...@@ -65,7 +65,7 @@ void main() { ...@@ -65,7 +65,7 @@ void main() {
), ),
), ),
)); ));
await tester.scroll(find.text('1'), const Offset(0.0, -280.0)); await tester.drag(find.text('1'), const Offset(0.0, -280.0));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
// screen is 600px tall, and has the following items: // screen is 600px tall, and has the following items:
// -280..10 = 0 // -280..10 = 0
......
...@@ -45,7 +45,7 @@ void main() { ...@@ -45,7 +45,7 @@ void main() {
final RenderBox box = tester.renderObject(find.byType(Container)); final RenderBox box = tester.renderObject(find.byType(Container));
expect(box.localToGlobal(Point.origin), equals(Point.origin)); expect(box.localToGlobal(Point.origin), equals(Point.origin));
await tester.scroll(find.byType(SingleChildScrollView), const Offset(-200.0, -200.0)); await tester.drag(find.byType(SingleChildScrollView), const Offset(-200.0, -200.0));
expect(box.localToGlobal(Point.origin), equals(const Point(0.0, -200.0))); expect(box.localToGlobal(Point.origin), equals(const Point(0.0, -200.0)));
}); });
......
...@@ -28,7 +28,7 @@ void main() { ...@@ -28,7 +28,7 @@ void main() {
expect(find.text('1'), findsNothing); expect(find.text('1'), findsNothing);
expect(find.text('2'), findsNothing); expect(find.text('2'), findsNothing);
await tester.scroll(find.byType(Scrollable), const Offset(0.0, -700.0)); await tester.drag(find.byType(Scrollable), const Offset(0.0, -700.0));
await tester.pump(); await tester.pump();
expect(find.text('0'), findsNothing); expect(find.text('0'), findsNothing);
...@@ -37,7 +37,7 @@ void main() { ...@@ -37,7 +37,7 @@ void main() {
expect(find.text('3'), findsNothing); expect(find.text('3'), findsNothing);
expect(find.text('4'), findsNothing); expect(find.text('4'), findsNothing);
await tester.scroll(find.byType(Scrollable), const Offset(0.0, 200.0)); await tester.drag(find.byType(Scrollable), const Offset(0.0, 200.0));
await tester.pump(); await tester.pump();
expect(find.text('0'), findsOneWidget); expect(find.text('0'), findsOneWidget);
......
...@@ -42,7 +42,7 @@ void main() { ...@@ -42,7 +42,7 @@ void main() {
expect(position.minScrollExtent, 0.0); expect(position.minScrollExtent, 0.0);
expect(position.maxScrollExtent, max); expect(position.maxScrollExtent, max);
position.animateTo(10000.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(10000.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 10)); await tester.pumpAndSettle(const Duration(milliseconds: 50));
expect(position.pixels, max); expect(position.pixels, max);
expect(position.minScrollExtent, 0.0); expect(position.minScrollExtent, 0.0);
expect(position.maxScrollExtent, max); expect(position.maxScrollExtent, max);
...@@ -68,7 +68,7 @@ void main() { ...@@ -68,7 +68,7 @@ void main() {
verifyPaintPosition(key3, const Offset(0.0, 600.0), false); verifyPaintPosition(key3, const Offset(0.0, 600.0), false);
position.animateTo(bigHeight - 600.0 + delegate.maxExtent, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(bigHeight - 600.0 + delegate.maxExtent, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 1000)); await tester.pumpAndSettle(const Duration(milliseconds: 1000));
verifyPaintPosition(key1, const Offset(0.0, 0.0), true); verifyPaintPosition(key1, const Offset(0.0, 0.0), true);
verifyPaintPosition(key2, new Offset(0.0, 600.0 - delegate.maxExtent), true); verifyPaintPosition(key2, new Offset(0.0, 600.0 - delegate.maxExtent), true);
verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, 600.0 - delegate.maxExtent, 800.0, delegate.maxExtent)); verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, 600.0 - delegate.maxExtent, 800.0, delegate.maxExtent));
...@@ -76,42 +76,42 @@ void main() { ...@@ -76,42 +76,42 @@ void main() {
assert(delegate.maxExtent * 2.0 < 600.0); // make sure this fits on the test screen... assert(delegate.maxExtent * 2.0 < 600.0); // make sure this fits on the test screen...
position.animateTo(bigHeight - 600.0 + delegate.maxExtent * 2.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(bigHeight - 600.0 + delegate.maxExtent * 2.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 1000)); await tester.pumpAndSettle(const Duration(milliseconds: 1000));
verifyPaintPosition(key1, const Offset(0.0, 0.0), true); verifyPaintPosition(key1, const Offset(0.0, 0.0), true);
verifyPaintPosition(key2, new Offset(0.0, 600.0 - delegate.maxExtent * 2.0), true); verifyPaintPosition(key2, new Offset(0.0, 600.0 - delegate.maxExtent * 2.0), true);
verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, 600.0 - delegate.maxExtent * 2.0, 800.0, delegate.maxExtent)); verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, 600.0 - delegate.maxExtent * 2.0, 800.0, delegate.maxExtent));
verifyPaintPosition(key3, new Offset(0.0, 600.0 - delegate.maxExtent), true); verifyPaintPosition(key3, new Offset(0.0, 600.0 - delegate.maxExtent), true);
position.animateTo(bigHeight, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(bigHeight, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 1000)); await tester.pumpAndSettle(const Duration(milliseconds: 1000));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key2, const Offset(0.0, 0.0), true);
verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, 0.0, 800.0, delegate.maxExtent)); verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, 0.0, 800.0, delegate.maxExtent));
verifyPaintPosition(key3, new Offset(0.0, delegate.maxExtent), true); verifyPaintPosition(key3, new Offset(0.0, delegate.maxExtent), true);
position.animateTo(bigHeight + delegate.maxExtent * 0.1, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(bigHeight + delegate.maxExtent * 0.1, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 1000)); await tester.pumpAndSettle(const Duration(milliseconds: 1000));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key2, const Offset(0.0, 0.0), true);
verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, 0.0, 800.0, delegate.maxExtent * 0.9)); verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, 0.0, 800.0, delegate.maxExtent * 0.9));
verifyPaintPosition(key3, new Offset(0.0, delegate.maxExtent * 0.9), true); verifyPaintPosition(key3, new Offset(0.0, delegate.maxExtent * 0.9), true);
position.animateTo(bigHeight + delegate.maxExtent * 0.5, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(bigHeight + delegate.maxExtent * 0.5, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 1000)); await tester.pumpAndSettle(const Duration(milliseconds: 1000));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key2, const Offset(0.0, 0.0), true);
verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, 0.0, 800.0, delegate.maxExtent * 0.5)); verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, 0.0, 800.0, delegate.maxExtent * 0.5));
verifyPaintPosition(key3, new Offset(0.0, delegate.maxExtent * 0.5), true); verifyPaintPosition(key3, new Offset(0.0, delegate.maxExtent * 0.5), true);
position.animateTo(bigHeight + delegate.maxExtent * 0.9, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(bigHeight + delegate.maxExtent * 0.9, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 1000)); await tester.pumpAndSettle(const Duration(milliseconds: 1000));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key2, const Offset(0.0, 0.0), true);
verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, -delegate.maxExtent * 0.4, 800.0, delegate.maxExtent * 0.5)); verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, -delegate.maxExtent * 0.4, 800.0, delegate.maxExtent * 0.5));
verifyPaintPosition(key3, new Offset(0.0, delegate.maxExtent * 0.1), true); verifyPaintPosition(key3, new Offset(0.0, delegate.maxExtent * 0.1), true);
position.animateTo(bigHeight + delegate.maxExtent * 2.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(bigHeight + delegate.maxExtent * 2.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 1000)); await tester.pumpAndSettle(const Duration(milliseconds: 1000));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), false); verifyPaintPosition(key2, const Offset(0.0, 0.0), false);
verifyPaintPosition(key3, const Offset(0.0, 0.0), true); verifyPaintPosition(key3, const Offset(0.0, 0.0), true);
...@@ -137,13 +137,13 @@ void main() { ...@@ -137,13 +137,13 @@ void main() {
verifyPaintPosition(key3, const Offset(0.0, 600.0), false); verifyPaintPosition(key3, const Offset(0.0, 600.0), false);
position.animateTo(bigHeight + delegate.maxExtent * 2.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(bigHeight + delegate.maxExtent * 2.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 1000)); await tester.pumpAndSettle(const Duration(milliseconds: 1000));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), false); verifyPaintPosition(key2, const Offset(0.0, 0.0), false);
verifyPaintPosition(key3, const Offset(0.0, 0.0), true); verifyPaintPosition(key3, const Offset(0.0, 0.0), true);
position.animateTo(bigHeight + delegate.maxExtent * 1.9, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(bigHeight + delegate.maxExtent * 1.9, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 1000)); await tester.pumpAndSettle(const Duration(milliseconds: 1000));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), false); verifyPaintPosition(key2, const Offset(0.0, 0.0), false);
verifyPaintPosition(key3, const Offset(0.0, 0.0), true); verifyPaintPosition(key3, const Offset(0.0, 0.0), true);
...@@ -169,14 +169,14 @@ void main() { ...@@ -169,14 +169,14 @@ void main() {
verifyPaintPosition(key3, const Offset(0.0, 600.0), false); verifyPaintPosition(key3, const Offset(0.0, 600.0), false);
position.animateTo(bigHeight + delegate.maxExtent * 2.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(bigHeight + delegate.maxExtent * 2.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 1000)); await tester.pumpAndSettle(const Duration(milliseconds: 1000));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), false); verifyPaintPosition(key2, const Offset(0.0, 0.0), false);
verifyPaintPosition(key3, const Offset(0.0, 0.0), true); verifyPaintPosition(key3, const Offset(0.0, 0.0), true);
position.animateTo(bigHeight + delegate.maxExtent * 1.9, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(bigHeight + delegate.maxExtent * 1.9, curve: Curves.linear, duration: const Duration(minutes: 1));
position.updateUserScrollDirection(ScrollDirection.forward); // ignore: INVALID_USE_OF_PROTECTED_MEMBER, since this is using a protected method for testing purposes position.updateUserScrollDirection(ScrollDirection.forward); // ignore: INVALID_USE_OF_PROTECTED_MEMBER, since this is using a protected method for testing purposes
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 1000)); await tester.pumpAndSettle(const Duration(milliseconds: 1000));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key2, const Offset(0.0, 0.0), true);
verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, -delegate.maxExtent * 0.4, 800.0, delegate.maxExtent * 0.5)); verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, -delegate.maxExtent * 0.4, 800.0, delegate.maxExtent * 0.5));
......
...@@ -45,7 +45,7 @@ void main() { ...@@ -45,7 +45,7 @@ void main() {
expect(position.minScrollExtent, 0.0); expect(position.minScrollExtent, 0.0);
expect(position.maxScrollExtent, max); expect(position.maxScrollExtent, max);
position.animateTo(10000.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(10000.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 10)); await tester.pumpAndSettle(const Duration(milliseconds: 10));
expect(position.pixels, max); expect(position.pixels, max);
expect(position.minScrollExtent, 0.0); expect(position.minScrollExtent, 0.0);
expect(position.maxScrollExtent, max); expect(position.maxScrollExtent, max);
...@@ -77,21 +77,21 @@ void main() { ...@@ -77,21 +77,21 @@ void main() {
verifyPaintPosition(key4, const Offset(0.0, 600.0), false); verifyPaintPosition(key4, const Offset(0.0, 600.0), false);
verifyPaintPosition(key5, const Offset(0.0, 600.0), false); verifyPaintPosition(key5, const Offset(0.0, 600.0), false);
position.animateTo(550.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(550.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100)); await tester.pumpAndSettle(const Duration(milliseconds: 100));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key2, const Offset(0.0, 0.0), true);
verifyPaintPosition(key3, const Offset(0.0, 200.0), true); verifyPaintPosition(key3, const Offset(0.0, 200.0), true);
verifyPaintPosition(key4, const Offset(0.0, 400.0), true); verifyPaintPosition(key4, const Offset(0.0, 400.0), true);
verifyPaintPosition(key5, const Offset(0.0, 600.0), false); verifyPaintPosition(key5, const Offset(0.0, 600.0), false);
position.animateTo(600.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(600.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 200)); await tester.pumpAndSettle(const Duration(milliseconds: 200));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key2, const Offset(0.0, 0.0), true);
verifyPaintPosition(key3, const Offset(0.0, 150.0), true); verifyPaintPosition(key3, const Offset(0.0, 150.0), true);
verifyPaintPosition(key4, const Offset(0.0, 350.0), true); verifyPaintPosition(key4, const Offset(0.0, 350.0), true);
verifyPaintPosition(key5, const Offset(0.0, 600.0), false); verifyPaintPosition(key5, const Offset(0.0, 600.0), false);
position.animateTo(650.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(650.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 300)); await tester.pumpAndSettle(const Duration(milliseconds: 300));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key2, const Offset(0.0, 0.0), true);
verifyPaintPosition(key3, const Offset(0.0, 100.0), true); verifyPaintPosition(key3, const Offset(0.0, 100.0), true);
...@@ -99,7 +99,7 @@ void main() { ...@@ -99,7 +99,7 @@ void main() {
verifyPaintPosition(key4, const Offset(0.0, 300.0), true); verifyPaintPosition(key4, const Offset(0.0, 300.0), true);
verifyPaintPosition(key5, const Offset(0.0, 600.0), false); verifyPaintPosition(key5, const Offset(0.0, 600.0), false);
position.animateTo(700.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(700.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 400)); await tester.pumpAndSettle(const Duration(milliseconds: 400));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key2, const Offset(0.0, 0.0), true);
verifyPaintPosition(key3, const Offset(0.0, 100.0), true); verifyPaintPosition(key3, const Offset(0.0, 100.0), true);
...@@ -107,7 +107,7 @@ void main() { ...@@ -107,7 +107,7 @@ void main() {
verifyPaintPosition(key4, const Offset(0.0, 250.0), true); verifyPaintPosition(key4, const Offset(0.0, 250.0), true);
verifyPaintPosition(key5, const Offset(0.0, 600.0), false); verifyPaintPosition(key5, const Offset(0.0, 600.0), false);
position.animateTo(750.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(750.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 500)); await tester.pumpAndSettle(const Duration(milliseconds: 500));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key2, const Offset(0.0, 0.0), true);
verifyPaintPosition(key3, const Offset(0.0, 100.0), true); verifyPaintPosition(key3, const Offset(0.0, 100.0), true);
...@@ -115,28 +115,28 @@ void main() { ...@@ -115,28 +115,28 @@ void main() {
verifyPaintPosition(key4, const Offset(0.0, 200.0), true); verifyPaintPosition(key4, const Offset(0.0, 200.0), true);
verifyPaintPosition(key5, const Offset(0.0, 600.0), false); verifyPaintPosition(key5, const Offset(0.0, 600.0), false);
position.animateTo(800.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(800.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 60)); await tester.pumpAndSettle(const Duration(milliseconds: 60));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key2, const Offset(0.0, 0.0), true);
verifyPaintPosition(key3, const Offset(0.0, 100.0), true); verifyPaintPosition(key3, const Offset(0.0, 100.0), true);
verifyPaintPosition(key4, const Offset(0.0, 150.0), true); verifyPaintPosition(key4, const Offset(0.0, 150.0), true);
verifyPaintPosition(key5, const Offset(0.0, 600.0), false); verifyPaintPosition(key5, const Offset(0.0, 600.0), false);
position.animateTo(850.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(850.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 70)); await tester.pumpAndSettle(const Duration(milliseconds: 70));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key2, const Offset(0.0, 0.0), true);
verifyPaintPosition(key3, const Offset(0.0, 100.0), true); verifyPaintPosition(key3, const Offset(0.0, 100.0), true);
verifyPaintPosition(key4, const Offset(0.0, 100.0), true); verifyPaintPosition(key4, const Offset(0.0, 100.0), true);
verifyPaintPosition(key5, const Offset(0.0, 600.0), false); verifyPaintPosition(key5, const Offset(0.0, 600.0), false);
position.animateTo(900.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(900.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 80)); await tester.pumpAndSettle(const Duration(milliseconds: 80));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key2, const Offset(0.0, 0.0), true);
verifyPaintPosition(key3, const Offset(0.0, 100.0), true); verifyPaintPosition(key3, const Offset(0.0, 100.0), true);
verifyPaintPosition(key4, const Offset(0.0, 50.0), true); verifyPaintPosition(key4, const Offset(0.0, 50.0), true);
verifyPaintPosition(key5, const Offset(0.0, 600.0), false); verifyPaintPosition(key5, const Offset(0.0, 600.0), false);
position.animateTo(950.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(950.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 90)); await tester.pumpAndSettle(const Duration(milliseconds: 90));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key2, const Offset(0.0, 0.0), true);
verifyPaintPosition(key3, const Offset(0.0, 100.0), true); verifyPaintPosition(key3, const Offset(0.0, 100.0), true);
...@@ -167,7 +167,7 @@ void main() { ...@@ -167,7 +167,7 @@ void main() {
expect(position.minScrollExtent, 0.0); expect(position.minScrollExtent, 0.0);
expect(position.maxScrollExtent, max); expect(position.maxScrollExtent, max);
position.animateTo(10000.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(10000.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 10)); await tester.pumpAndSettle(const Duration(milliseconds: 10));
expect(position.pixels, max); expect(position.pixels, max);
expect(position.minScrollExtent, 0.0); expect(position.minScrollExtent, 0.0);
expect(position.maxScrollExtent, max); expect(position.maxScrollExtent, max);
......
...@@ -36,7 +36,7 @@ void main() { ...@@ -36,7 +36,7 @@ void main() {
expect(position.minScrollExtent, 0.0); expect(position.minScrollExtent, 0.0);
expect(position.maxScrollExtent, max); expect(position.maxScrollExtent, max);
position.animateTo(10000.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(10000.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 10)); await tester.pumpAndSettle(const Duration(milliseconds: 10));
expect(position.pixels, max); expect(position.pixels, max);
expect(position.minScrollExtent, 0.0); expect(position.minScrollExtent, 0.0);
expect(position.maxScrollExtent, max); expect(position.maxScrollExtent, max);
...@@ -62,7 +62,7 @@ void main() { ...@@ -62,7 +62,7 @@ void main() {
); );
final ScrollPosition position = tester.state<ScrollableState>(find.byType(Scrollable)).position; final ScrollPosition position = tester.state<ScrollableState>(find.byType(Scrollable)).position;
position.animateTo(RenderBigSliver.height + delegate.maxExtent - 5.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(RenderBigSliver.height + delegate.maxExtent - 5.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 1000)); await tester.pumpAndSettle(const Duration(milliseconds: 1000));
final RenderBox box = tester.renderObject<RenderBox>(find.byType(Container)); final RenderBox box = tester.renderObject<RenderBox>(find.byType(Container));
final Rect rect = new Rect.fromPoints(box.localToGlobal(Point.origin), box.localToGlobal(box.size.bottomRight(Point.origin))); final Rect rect = new Rect.fromPoints(box.localToGlobal(Point.origin), box.localToGlobal(box.size.bottomRight(Point.origin)));
expect(rect, equals(new Rect.fromLTWH(0.0, -195.0, 800.0, 200.0))); expect(rect, equals(new Rect.fromLTWH(0.0, -195.0, 800.0, 200.0)));
......
...@@ -164,31 +164,31 @@ void main() { ...@@ -164,31 +164,31 @@ void main() {
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 122)); await tester.pumpAndSettle(const Duration(milliseconds: 122));
position.animateTo(-10000.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(-10000.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 122)); await tester.pumpAndSettle(const Duration(milliseconds: 122));
position.animateTo(10000.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(10000.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 122)); await tester.pumpAndSettle(const Duration(milliseconds: 122));
position.animateTo(-10000.0, curve: Curves.linear, duration: const Duration(seconds: 1)); position.animateTo(-10000.0, curve: Curves.linear, duration: const Duration(seconds: 1));
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 122)); await tester.pumpAndSettle(const Duration(milliseconds: 122));
position.animateTo(10000.0, curve: Curves.linear, duration: const Duration(seconds: 1)); position.animateTo(10000.0, curve: Curves.linear, duration: const Duration(seconds: 1));
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 122)); await tester.pumpAndSettle(const Duration(milliseconds: 122));
}); });
} }
...@@ -38,7 +38,7 @@ void main() { ...@@ -38,7 +38,7 @@ void main() {
expect(position.minScrollExtent, 0.0); expect(position.minScrollExtent, 0.0);
expect(position.maxScrollExtent, max); expect(position.maxScrollExtent, max);
position.animateTo(10000.0, curve: Curves.linear, duration: const Duration(minutes: 1)); position.animateTo(10000.0, curve: Curves.linear, duration: const Duration(minutes: 1));
await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 10)); await tester.pumpAndSettle(const Duration(milliseconds: 10));
expect(position.pixels, max); expect(position.pixels, max);
expect(position.minScrollExtent, 0.0); expect(position.minScrollExtent, 0.0);
expect(position.maxScrollExtent, max); expect(position.maxScrollExtent, max);
......
...@@ -82,8 +82,7 @@ void main() { ...@@ -82,8 +82,7 @@ void main() {
await tester.pumpWidget(new Foo()); await tester.pumpWidget(new Foo());
expect(tester.state<ScrollableState>(find.byType(Scrollable)).position.pixels, 0.0); expect(tester.state<ScrollableState>(find.byType(Scrollable)).position.pixels, 0.0);
await tester.tap(find.byType(GestureDetector).first); await tester.tap(find.byType(GestureDetector).first);
await tester.pump(); await tester.pumpAndSettle();
await tester.pumpUntilNoTransientCallbacks();
expect(tester.state<ScrollableState>(find.byType(Scrollable)).position.pixels, 200.0); expect(tester.state<ScrollableState>(find.byType(Scrollable)).position.pixels, 200.0);
}); });
} }
...@@ -248,16 +248,16 @@ class WidgetController { ...@@ -248,16 +248,16 @@ class WidgetController {
// INTERACTION // INTERACTION
/// Dispatch a pointer down / pointer up sequence at the center of /// Dispatch a pointer down / pointer up sequence at the center of
/// the given widget, assuming it is exposed. If the center of the /// the given widget, assuming it is exposed.
/// widget is not exposed, this might send events to another ///
/// object. /// If the center of the widget is not exposed, this might send events to
Future<Null> tap(Finder finder, { int pointer: 1 }) { /// another object.
Future<Null> tap(Finder finder, { int pointer }) {
return tapAt(getCenter(finder), pointer: pointer); return tapAt(getCenter(finder), pointer: pointer);
} }
/// Dispatch a pointer down / pointer up sequence at the given /// Dispatch a pointer down / pointer up sequence at the given location.
/// location. Future<Null> tapAt(Point location, { int pointer }) {
Future<Null> tapAt(Point location, { int pointer: 1 }) {
return TestAsyncUtils.guard(() async { return TestAsyncUtils.guard(() async {
final TestGesture gesture = await startGesture(location, pointer: pointer); final TestGesture gesture = await startGesture(location, pointer: pointer);
await gesture.up(); await gesture.up();
...@@ -267,16 +267,17 @@ class WidgetController { ...@@ -267,16 +267,17 @@ class WidgetController {
/// Dispatch a pointer down / pointer up sequence (with a delay of /// Dispatch a pointer down / pointer up sequence (with a delay of
/// [kLongPressTimeout] + [kPressTimeout] between the two events) at the /// [kLongPressTimeout] + [kPressTimeout] between the two events) at the
/// center of the given widget, assuming it is exposed. If the center of the /// center of the given widget, assuming it is exposed.
/// widget is not exposed, this might send events to another ///
/// object. /// If the center of the widget is not exposed, this might send events to
Future<Null> longPress(Finder finder, { int pointer: 1 }) { /// another object.
Future<Null> longPress(Finder finder, { int pointer }) {
return longPressAt(getCenter(finder), pointer: pointer); return longPressAt(getCenter(finder), pointer: pointer);
} }
/// Dispatch a pointer down / pointer up sequence at the given location with /// Dispatch a pointer down / pointer up sequence at the given location with
/// a delay of [kLongPressTimeout] + [kPressTimeout] between the two events. /// a delay of [kLongPressTimeout] + [kPressTimeout] between the two events.
Future<Null> longPressAt(Point location, { int pointer: 1 }) { Future<Null> longPressAt(Point location, { int pointer }) {
return TestAsyncUtils.guard(() async { return TestAsyncUtils.guard(() async {
final TestGesture gesture = await startGesture(location, pointer: pointer); final TestGesture gesture = await startGesture(location, pointer: pointer);
await pump(kLongPressTimeout + kPressTimeout); await pump(kLongPressTimeout + kPressTimeout);
...@@ -286,25 +287,33 @@ class WidgetController { ...@@ -286,25 +287,33 @@ class WidgetController {
} }
/// Attempts a fling gesture starting from the center of the given /// Attempts a fling gesture starting from the center of the given
/// widget, moving the given distance, reaching the given velocity. /// widget, moving the given distance, reaching the given speed.
/// ///
/// If the middle of the widget is not exposed, this might send /// If the middle of the widget is not exposed, this might send
/// events to another object. /// events to another object.
/// ///
/// This can pump frames. See [flingFrom] for a discussion of how the /// This can pump frames. See [flingFrom] for a discussion of how the
/// `offset`, `velocity` and `frameInterval` arguments affect this. /// `offset`, `velocity` and `frameInterval` arguments affect this.
Future<Null> fling(Finder finder, Offset offset, double velocity, { int pointer: 1, Duration frameInterval: const Duration(milliseconds: 16) }) { ///
return flingFrom(getCenter(finder), offset, velocity, pointer: pointer, frameInterval: frameInterval); /// The `speed` is in pixels per second in the direction given by `offset`.
///
/// A fling is essentially a drag that ends at a particular speed. If you
/// just want to drag and end without a fling, use [drag].
Future<Null> fling(Finder finder, Offset offset, double speed, {
int pointer,
Duration frameInterval: const Duration(milliseconds: 16),
}) {
return flingFrom(getCenter(finder), offset, speed, pointer: pointer, frameInterval: frameInterval);
} }
/// Attempts a fling gesture starting from the given location, /// Attempts a fling gesture starting from the given location, moving the
/// moving the given distance, reaching the given velocity. /// given distance, reaching the given speed.
/// ///
/// Exactly 50 pointer events are synthesized. /// Exactly 50 pointer events are synthesized.
/// ///
/// The offset and velocity control the interval between each pointer event. /// The offset and speed control the interval between each pointer event. For
/// For example, if the offset is 200 pixels, and the velocity is 800 pixels /// example, if the offset is 200 pixels down, and the speed is 800 pixels per
/// per second, the pointer events will be sent for each increment of 4 pixels /// second, the pointer events will be sent for each increment of 4 pixels
/// (200/50), over 250ms (200/800), meaning events will be sent every 1.25ms /// (200/50), over 250ms (200/800), meaning events will be sent every 1.25ms
/// (250/200). /// (250/200).
/// ///
...@@ -312,27 +321,30 @@ class WidgetController { ...@@ -312,27 +321,30 @@ class WidgetController {
/// calls to [pump]). If the total duration is longer than `frameInterval`, /// calls to [pump]). If the total duration is longer than `frameInterval`,
/// then one frame is pumped each time that amount of time elapses while /// then one frame is pumped each time that amount of time elapses while
/// sending events, or each time an event is synthesised, whichever is rarer. /// sending events, or each time an event is synthesised, whichever is rarer.
Future<Null> flingFrom(Point startLocation, Offset offset, double velocity, { int pointer: 1, Duration frameInterval: const Duration(milliseconds: 16) }) { ///
/// A fling is essentially a drag that ends at a particular speed. If you
/// just want to drag and end without a fling, use [dragFrom].
Future<Null> flingFrom(Point startLocation, Offset offset, double speed, { int pointer, Duration frameInterval: const Duration(milliseconds: 16) }) {
assert(offset.distance > 0.0); assert(offset.distance > 0.0);
assert(velocity > 0.0); // velocity is pixels/second assert(speed > 0.0); // speed is pixels/second
return TestAsyncUtils.guard(() async { return TestAsyncUtils.guard(() async {
final TestPointer p = new TestPointer(pointer); final TestPointer testPointer = new TestPointer(pointer ?? _getNextPointer());
final HitTestResult result = hitTestOnBinding(startLocation); final HitTestResult result = hitTestOnBinding(startLocation);
const int kMoveCount = 50; // Needs to be >= kHistorySize, see _LeastSquaresVelocityTrackerStrategy const int kMoveCount = 50; // Needs to be >= kHistorySize, see _LeastSquaresVelocityTrackerStrategy
final double timeStampDelta = 1000.0 * offset.distance / (kMoveCount * velocity); final double timeStampDelta = 1000.0 * offset.distance / (kMoveCount * speed);
double timeStamp = 0.0; double timeStamp = 0.0;
double lastTimeStamp = timeStamp; double lastTimeStamp = timeStamp;
await sendEventToBinding(p.down(startLocation, timeStamp: new Duration(milliseconds: timeStamp.round())), result); await sendEventToBinding(testPointer.down(startLocation, timeStamp: new Duration(milliseconds: timeStamp.round())), result);
for (int i = 0; i <= kMoveCount; i += 1) { for (int i = 0; i <= kMoveCount; i += 1) {
final Point location = startLocation + Offset.lerp(Offset.zero, offset, i / kMoveCount); final Point location = startLocation + Offset.lerp(Offset.zero, offset, i / kMoveCount);
await sendEventToBinding(p.move(location, timeStamp: new Duration(milliseconds: timeStamp.round())), result); await sendEventToBinding(testPointer.move(location, timeStamp: new Duration(milliseconds: timeStamp.round())), result);
timeStamp += timeStampDelta; timeStamp += timeStampDelta;
if (timeStamp - lastTimeStamp > frameInterval.inMilliseconds) { if (timeStamp - lastTimeStamp > frameInterval.inMilliseconds) {
await pump(new Duration(milliseconds: (timeStamp - lastTimeStamp).truncate())); await pump(new Duration(milliseconds: (timeStamp - lastTimeStamp).truncate()));
lastTimeStamp = timeStamp; lastTimeStamp = timeStamp;
} }
} }
await sendEventToBinding(p.up(timeStamp: new Duration(milliseconds: timeStamp.round())), result); await sendEventToBinding(testPointer.up(timeStamp: new Duration(milliseconds: timeStamp.round())), result);
return null; return null;
}); });
} }
...@@ -352,13 +364,20 @@ class WidgetController { ...@@ -352,13 +364,20 @@ class WidgetController {
/// ///
/// If the middle of the widget is not exposed, this might send /// If the middle of the widget is not exposed, this might send
/// events to another object. /// events to another object.
Future<Null> scroll(Finder finder, Offset offset, { int pointer: 1 }) { ///
return scrollAt(getCenter(finder), offset, pointer: pointer); /// If you want the drag to end with a speed so that the gesture recognition
/// system identifies the gesture as a fling, consider using [fling] instead.
Future<Null> drag(Finder finder, Offset offset, { int pointer }) {
return dragFrom(getCenter(finder), offset, pointer: pointer);
} }
/// Attempts a drag gesture consisting of a pointer down, a move by /// Attempts a drag gesture consisting of a pointer down, a move by
/// the given offset, and a pointer up. /// the given offset, and a pointer up.
Future<Null> scrollAt(Point startLocation, Offset offset, { int pointer: 1 }) { ///
/// If you want the drag to end with a speed so that the gesture recognition
/// system identifies the gesture as a fling, consider using [flingFrom]
/// instead.
Future<Null> dragFrom(Point startLocation, Offset offset, { int pointer }) {
return TestAsyncUtils.guard(() async { return TestAsyncUtils.guard(() async {
final TestGesture gesture = await startGesture(startLocation, pointer: pointer); final TestGesture gesture = await startGesture(startLocation, pointer: pointer);
await gesture.moveBy(offset); await gesture.moveBy(offset);
...@@ -367,10 +386,27 @@ class WidgetController { ...@@ -367,10 +386,27 @@ class WidgetController {
}); });
} }
/// The next available pointer identifier.
///
/// This is the default pointer identifier that will be used the next time the
/// [startGesture] method is called without an explicit pointer identifier.
int nextPointer = 1;
int _getNextPointer() {
final int result = nextPointer;
nextPointer += 1;
return result;
}
/// Begins a gesture at a particular point, and returns the /// Begins a gesture at a particular point, and returns the
/// [TestGesture] object which you can use to continue the gesture. /// [TestGesture] object which you can use to continue the gesture.
Future<TestGesture> startGesture(Point downLocation, { int pointer: 1 }) { Future<TestGesture> startGesture(Point downLocation, { int pointer }) {
return TestGesture.down(downLocation, pointer: pointer, hitTester: hitTestOnBinding, dispatcher: sendEventToBinding); return TestGesture.down(
downLocation,
pointer: pointer ?? _getNextPointer(),
hitTester: hitTestOnBinding,
dispatcher: sendEventToBinding,
);
} }
/// Forwards the given location to the binding's hitTest logic. /// Forwards the given location to the binding's hitTest logic.
......
...@@ -15,8 +15,12 @@ export 'dart:ui' show Point; ...@@ -15,8 +15,12 @@ export 'dart:ui' show Point;
/// You can use this to manually simulate individual events, but the /// You can use this to manually simulate individual events, but the
/// simplest way to generate coherent gestures is to use [TestGesture]. /// simplest way to generate coherent gestures is to use [TestGesture].
class TestPointer { class TestPointer {
/// Creates a [TestPointer]. By default, the pointer identifier used is 1, however /// Creates a [TestPointer]. By default, the pointer identifier used is 1,
/// this can be overridden by providing an argument to the constructor. /// however this can be overridden by providing an argument to the
/// constructor.
///
/// Multiple [TestPointer]s created with the same pointer identifier will
/// interfere with each other if they are used in parallel.
TestPointer([ this.pointer = 1 ]); TestPointer([ this.pointer = 1 ]);
/// The pointer identifier used for events generated by this object. /// The pointer identifier used for events generated by this object.
...@@ -123,7 +127,7 @@ class TestGesture { ...@@ -123,7 +127,7 @@ class TestGesture {
/// Create a [TestGesture] by starting with a pointerDown at the /// Create a [TestGesture] by starting with a pointerDown at the
/// given point. /// given point.
/// ///
/// By default, the pointer ID used is 1. This can be overridden by /// By default, the pointer identifier used is 1. This can be overridden by
/// providing the `pointer` argument. /// providing the `pointer` argument.
/// ///
/// A function to use for hit testing should be provided via the `hitTester` /// A function to use for hit testing should be provided via the `hitTester`
......
...@@ -191,8 +191,10 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker ...@@ -191,8 +191,10 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
} }
/// Repeatedly calls [pump] with the given `duration` until there are no /// Repeatedly calls [pump] with the given `duration` until there are no
/// longer any transient callbacks scheduled. If no transient callbacks are /// longer any transient callbacks scheduled. This will call [pump] at least
/// scheduled when the function is called, it returns without calling [pump]. /// once, even if no transient callbacks are scheduled when the function is
/// called, in case there are dirty widgets to rebuild which will themselves
/// register new transient callbacks.
/// ///
/// This essentially waits for all animations to have completed. /// This essentially waits for all animations to have completed.
/// ///
...@@ -209,7 +211,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker ...@@ -209,7 +211,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
/// ///
/// Alternatively, one can check that the return value from this function /// Alternatively, one can check that the return value from this function
/// matches the expected number of pumps. /// matches the expected number of pumps.
Future<int> pumpUntilNoTransientCallbacks([ Future<int> pumpAndSettle([
Duration duration = const Duration(milliseconds: 100), Duration duration = const Duration(milliseconds: 100),
EnginePhase phase = EnginePhase.sendSemanticsTree EnginePhase phase = EnginePhase.sendSemanticsTree
]) { ]) {
...@@ -217,10 +219,10 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker ...@@ -217,10 +219,10 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
assert(duration > Duration.ZERO); assert(duration > Duration.ZERO);
int count = 0; int count = 0;
return TestAsyncUtils.guard(() async { return TestAsyncUtils.guard(() async {
while (binding.transientCallbackCount > 0) { do {
await binding.pump(duration, phase); await binding.pump(duration, phase);
count += 1; count += 1;
} } while (binding.transientCallbackCount > 0);
}).then<int>((Null _) => count); }).then<int>((Null _) => count);
} }
......
...@@ -77,11 +77,11 @@ void main() { ...@@ -77,11 +77,11 @@ void main() {
duration: const Duration(milliseconds: 5100), duration: const Duration(milliseconds: 5100),
vsync: tester, vsync: tester,
); );
count = await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); count = await tester.pumpAndSettle(const Duration(seconds: 1));
expect(count, 0); expect(count, 1); // it always pumps at least one frame
test.forward(from: 0.0); test.forward(from: 0.0);
count = await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); count = await tester.pumpAndSettle(const Duration(seconds: 1));
// 1 frame at t=0, starting the animation // 1 frame at t=0, starting the animation
// 1 frame at t=1 // 1 frame at t=1
// 1 frame at t=2 // 1 frame at t=2
...@@ -93,13 +93,13 @@ void main() { ...@@ -93,13 +93,13 @@ void main() {
test.forward(from: 0.0); test.forward(from: 0.0);
await tester.pump(); // starts the animation await tester.pump(); // starts the animation
count = await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); count = await tester.pumpAndSettle(const Duration(seconds: 1));
expect(count, 6); expect(count, 6);
test.forward(from: 0.0); test.forward(from: 0.0);
await tester.pump(); // starts the animation await tester.pump(); // starts the animation
await tester.pump(); // has no effect await tester.pump(); // has no effect
count = await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); count = await tester.pumpAndSettle(const Duration(seconds: 1));
expect(count, 6); expect(count, 6);
}); });
}); });
...@@ -180,9 +180,9 @@ void main() { ...@@ -180,9 +180,9 @@ void main() {
expect(failure, isNotNull); expect(failure, isNotNull);
expect( expect(
failure.message, failure.message,
contains('Actual: ?:<zero widgets with text "bar" that has ancestor(s) with type Column with text "foo"') contains('Actual: ?:<zero widgets with text "bar" that has ancestor(s) with type Column with text "foo"')
); );
}); });
}); });
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment