diff --git a/examples/flutter_gallery/test/example_code_display_test.dart b/examples/flutter_gallery/test/example_code_display_test.dart index 178d126ceb..fcc9142815 100644 --- a/examples/flutter_gallery/test/example_code_display_test.dart +++ b/examples/flutter_gallery/test/example_code_display_test.dart @@ -23,7 +23,7 @@ void main() { final Point allDemosOrigin = tester.getTopRight(find.text('Demos')); final Finder button = find.text('Buttons'); 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(const Duration(seconds: 1)); } diff --git a/examples/flutter_gallery/test/pesto_test.dart b/examples/flutter_gallery/test/pesto_test.dart index 62d71aded7..a1c57a2abc 100644 --- a/examples/flutter_gallery/test/pesto_test.dart +++ b/examples/flutter_gallery/test/pesto_test.dart @@ -34,7 +34,7 @@ void main() { await tester.pump(); // Launch the recipe page 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(); Navigator.pop(find.byType(Scaffold).evaluate().single); @@ -51,8 +51,7 @@ void main() { 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.pump(); // start fling - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); // start and finish fling expect(find.text('Sicilian-Style sardines'), findsOneWidget); }); } diff --git a/examples/flutter_gallery/test/simple_smoke_test.dart b/examples/flutter_gallery/test/simple_smoke_test.dart index 34bde46472..7fcbea3dfc 100644 --- a/examples/flutter_gallery/test/simple_smoke_test.dart +++ b/examples/flutter_gallery/test/simple_smoke_test.dart @@ -47,17 +47,17 @@ void main() { await tester.pump(const Duration(seconds: 1)); // end animation // 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.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.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.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.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.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(hours: 100)); // for testing diff --git a/examples/flutter_gallery/test/smoke_test.dart b/examples/flutter_gallery/test/smoke_test.dart index e1b8913751..e477e79363 100644 --- a/examples/flutter_gallery/test/smoke_test.dart +++ b/examples/flutter_gallery/test/smoke_test.dart @@ -127,8 +127,7 @@ Future runSmokeTest(WidgetTester tester) async { for (String routeName in routeNames) { final Finder finder = findGalleryItemByRouteName(tester, routeName); Scrollable.ensureVisible(tester.element(finder), alignment: 0.5); - await tester.pump(); - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); await smokeDemo(tester, routeName); tester.binding.debugAssertNoTransientCallbacks('A transient callback was still active after leaving route $routeName'); } diff --git a/packages/flutter/test/cupertino/slider_test.dart b/packages/flutter/test/cupertino/slider_test.dart index 180e446f37..b54707b289 100644 --- a/packages/flutter/test/cupertino/slider_test.dart +++ b/packages/flutter/test/cupertino/slider_test.dart @@ -69,8 +69,7 @@ void main() { final Point topLeft = tester.getTopLeft(find.byKey(sliderKey)); const double unit = CupertinoThumbPainter.radius; const double delta = 3.0 * unit; - await tester.scrollAt( - topLeft + const Offset(unit, unit), const Offset(delta, 0.0)); + await tester.dragFrom(topLeft + const Offset(unit, unit), const Offset(delta, 0.0)); final Size size = tester.getSize(find.byKey(sliderKey)); expect(value, equals(delta / (size.width - 2.0 * (8.0 + CupertinoThumbPainter.radius)))); await tester.pump(); // No animation should start. diff --git a/packages/flutter/test/material/about_test.dart b/packages/flutter/test/material/about_test.dart index 8af789b718..e3c3588de5 100644 --- a/packages/flutter/test/material/about_test.dart +++ b/packages/flutter/test/material/about_test.dart @@ -40,14 +40,14 @@ void main() { expect(find.text('About box'), findsNothing); 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('0.1.2'), findsNothing); expect(find.text('About box'), findsNothing); 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('0.1.2'), findsOneWidget); @@ -60,7 +60,7 @@ void main() { }); 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); }); diff --git a/packages/flutter/test/material/back_button_test.dart b/packages/flutter/test/material/back_button_test.dart index 29dc4fd226..526b861586 100644 --- a/packages/flutter/test/material/back_button_test.dart +++ b/packages/flutter/test/material/back_button_test.dart @@ -24,13 +24,11 @@ void main() { tester.state(find.byType(Navigator)).pushNamed('/next'); - await tester.pump(); - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); await tester.tap(find.byType(BackButton)); - await tester.pump(); - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); expect(find.text('Home'), findsOneWidget); }); diff --git a/packages/flutter/test/material/data_table_test.dart b/packages/flutter/test/material/data_table_test.dart index c3568a0c85..ff3efee4f8 100644 --- a/packages/flutter/test/material/data_table_test.dart +++ b/packages/flutter/test/material/data_table_test.dart @@ -77,7 +77,7 @@ void main() { await tester.pumpWidget(new MaterialApp( 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')); expect(log, ['column-sort: 1 false']); @@ -86,7 +86,7 @@ void main() { await tester.pumpWidget(new MaterialApp( 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')); diff --git a/packages/flutter/test/material/date_picker_test.dart b/packages/flutter/test/material/date_picker_test.dart index 6bb169214a..ba00d94561 100644 --- a/packages/flutter/test/material/date_picker_test.dart +++ b/packages/flutter/test/material/date_picker_test.dart @@ -63,23 +63,23 @@ void main() { await tester.pump(const Duration(seconds: 2)); 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))); await tester.tapAt(const Point(300.0, 100.0)); expect(_selectedDate, equals(new DateTime(2016, DateTime.AUGUST, 5))); await tester.pump(const Duration(seconds: 2)); - await tester.scroll(find.byKey(_datePickerKey), const Offset(-300.0, 0.0)); - await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100)); + await tester.drag(find.byKey(_datePickerKey), const Offset(-300.0, 0.0)); + await tester.pumpAndSettle(const Duration(milliseconds: 100)); expect(_selectedDate, equals(new DateTime(2016, DateTime.AUGUST, 5))); await tester.tapAt(const Point(45.0, 270.0)); expect(_selectedDate, equals(new DateTime(2016, DateTime.SEPTEMBER, 25))); await tester.pump(const Duration(seconds: 2)); - await tester.scroll(find.byKey(_datePickerKey), const Offset(300.0, 0.0)); - await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100)); + await tester.drag(find.byKey(_datePickerKey), const Offset(300.0, 0.0)); + await tester.pumpAndSettle(const Duration(milliseconds: 100)); expect(_selectedDate, equals(new DateTime(2016, DateTime.SEPTEMBER, 25))); await tester.tapAt(const Point(210.0, 180.0)); @@ -144,7 +144,7 @@ void main() { selectableDayPredicate: selectableDayPredicate ); - await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); + await tester.pumpAndSettle(const Duration(seconds: 1)); await callback(date); } @@ -173,7 +173,7 @@ void main() { testWidgets('Can select a month', (WidgetTester tester) async { await preparePicker(tester, (Future date) async { 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('OK')); expect(await date, equals(new DateTime(2015, DateTime.DECEMBER, 25))); @@ -224,10 +224,10 @@ void main() { lastDate = new DateTime(2017, DateTime.FEBRUARY, 20); await preparePicker(tester, (Future date) async { 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. 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 await tester.tap(find.text('20')); // Days outside bound for new month pages also disabled. @@ -243,10 +243,10 @@ void main() { lastDate = initialDate; await preparePicker(tester, (Future date) async { 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. 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 await tester.tap(find.text('10')); // Days outside bound for new month pages also disabled. diff --git a/packages/flutter/test/material/dialog_test.dart b/packages/flutter/test/material/dialog_test.dart index aac6a25d8d..7275737841 100644 --- a/packages/flutter/test/material/dialog_test.dart +++ b/packages/flutter/test/material/dialog_test.dart @@ -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); await tester.tap(find.text('First option')); @@ -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); // Tap on the barrier. 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); showDialog( @@ -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); // Tap on the barrier, which shouldn't do anything this time. 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); }); diff --git a/packages/flutter/test/material/material_test.dart b/packages/flutter/test/material/material_test.dart index 2c99fc61b4..92594b7d9e 100644 --- a/packages/flutter/test/material/material_test.dart +++ b/packages/flutter/test/material/material_test.dart @@ -90,7 +90,7 @@ void main() { ])); 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(); expect(log, isEmpty); diff --git a/packages/flutter/test/material/paginated_data_table_test.dart b/packages/flutter/test/material/paginated_data_table_test.dart index b4a9c8c8d6..4398d6b007 100644 --- a/packages/flutter/test/material/paginated_data_table_test.dart +++ b/packages/flutter/test/material/paginated_data_table_test.dart @@ -96,10 +96,10 @@ void main() { expect(log, isEmpty); 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.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 200)); + await tester.pumpAndSettle(const Duration(milliseconds: 200)); expect(log, ['rows-per-page-changed: 8']); log.clear(); diff --git a/packages/flutter/test/material/persistent_bottom_sheet_test.dart b/packages/flutter/test/material/persistent_bottom_sheet_test.dart index b3efb11e34..329eb4416e 100644 --- a/packages/flutter/test/material/persistent_bottom_sheet_test.dart +++ b/packages/flutter/test/material/persistent_bottom_sheet_test.dart @@ -56,13 +56,12 @@ void main() { ); }); - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); expect(find.text('Two'), findsOneWidget); - await tester.scroll(find.text('Two'), const Offset(0.0, 400.0)); - await tester.pump(); - await tester.pumpUntilNoTransientCallbacks(); + await tester.drag(find.text('Two'), const Offset(0.0, 400.0)); + await tester.pumpAndSettle(); expect(find.text('Two'), findsNothing); }); diff --git a/packages/flutter/test/material/scaffold_test.dart b/packages/flutter/test/material/scaffold_test.dart index 26eca28ae4..58b3f6a37f 100644 --- a/packages/flutter/test/material/scaffold_test.dart +++ b/packages/flutter/test/material/scaffold_test.dart @@ -166,7 +166,7 @@ void main() { expect(scrollOffset.offset, 0.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(); expect(scrollOffset.offset, scrollDelta); @@ -205,8 +205,7 @@ void main() { scrollable.position.jumpTo(500.0); expect(scrollable.position.pixels, equals(500.0)); await tester.tapAt(const Point(100.0, 10.0)); - await tester.pump(); - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); expect(scrollable.position.pixels, equals(0.0)); }); @@ -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); await tester.tap(find.text('X')); expect(didPressButton, isTrue); diff --git a/packages/flutter/test/material/scrollbar_test.dart b/packages/flutter/test/material/scrollbar_test.dart index 2e1d75840c..8b1484b934 100644 --- a/packages/flutter/test/material/scrollbar_test.dart +++ b/packages/flutter/test/material/scrollbar_test.dart @@ -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.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)); await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200)); diff --git a/packages/flutter/test/material/slider_test.dart b/packages/flutter/test/material/slider_test.dart index 9c06aa3e1d..5a93f49fbc 100644 --- a/packages/flutter/test/material/slider_test.dart +++ b/packages/flutter/test/material/slider_test.dart @@ -70,9 +70,9 @@ void main() { expect(value, equals(0.0)); await tester.tap(find.byKey(sliderKey)); 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)); - 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)); await tester.pump(); // Starts animation. diff --git a/packages/flutter/test/material/snack_bar_test.dart b/packages/flutter/test/material/snack_bar_test.dart index 3489fe160e..21641d8920 100644 --- a/packages/flutter/test/material/snack_bar_test.dart +++ b/packages/flutter/test/material/snack_bar_test.dart @@ -251,7 +251,7 @@ void main() { expect(find.text('bar1'), findsOneWidget); expect(find.text('bar2'), findsNothing); 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 expect(find.text('bar1'), findsNothing); expect(find.text('bar2'), findsOneWidget); @@ -381,7 +381,7 @@ void main() { await tester.tap(find.text('X')); 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(); expect(closedReason, equals(SnackBarClosedReason.swipe)); diff --git a/packages/flutter/test/material/switch_test.dart b/packages/flutter/test/material/switch_test.dart index 62ce7ba454..1f60d91f20 100644 --- a/packages/flutter/test/material/switch_test.dart +++ b/packages/flutter/test/material/switch_test.dart @@ -60,21 +60,21 @@ void main() { 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); - 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); 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); 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); }); diff --git a/packages/flutter/test/material/tabs_test.dart b/packages/flutter/test/material/tabs_test.dart index 1bfa94a360..25d19ffa8b 100644 --- a/packages/flutter/test/material/tabs_test.dart +++ b/packages/flutter/test/material/tabs_test.dart @@ -151,18 +151,15 @@ void main() { expect(controller.previousIndex, 2); await tester.tap(find.text('C')); - await tester.pump(); - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); expect(controller.index, 2); await tester.tap(find.text('B')); - await tester.pump(); - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); expect(controller.index, 1); await tester.tap(find.text('A')); - await tester.pump(); - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); expect(controller.index, 0); }); @@ -179,8 +176,7 @@ void main() { expect(tester.getCenter(find.text('FFFFFF')).x, greaterThan(401.0)); await tester.tap(find.text('FFFFFF')); - await tester.pump(); - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); expect(controller.index, 5); // 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)); @@ -294,7 +290,7 @@ void main() { // Fling to the left, switch from the 'LEFT' tab to the 'RIGHT' Point flingStart = tester.getCenter(find.text('LEFT CHILD')); await tester.flingFrom(flingStart, const Offset(-200.0, 0.0), 10000.0); - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); expect(controller.index, 1); expect(find.text('LEFT CHILD'), findsNothing); expect(find.text('RIGHT CHILD'), findsOneWidget); @@ -302,7 +298,7 @@ void main() { // Fling to the right, switch back to the 'LEFT' tab flingStart = tester.getCenter(find.text('RIGHT CHILD')); await tester.flingFrom(flingStart, const Offset(200.0, 0.0), 10000.0); - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); expect(controller.index, 0); expect(find.text('LEFT CHILD'), findsOneWidget); expect(find.text('RIGHT CHILD'), findsNothing); @@ -440,21 +436,21 @@ void main() { }); await tester.tap(find.text('RIGHT')); - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); expect(value, 'RIGHT'); await tester.tap(find.text('LEFT')); - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); expect(value, 'LEFT'); final Point leftFlingStart = tester.getCenter(find.text('LEFT CHILD')); await tester.flingFrom(leftFlingStart, const Offset(-200.0, 0.0), 10000.0); - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); expect(value, 'RIGHT'); final Point rightFlingStart = tester.getCenter(find.text('RIGHT CHILD')); await tester.flingFrom(rightFlingStart, const Offset(200.0, 0.0), 10000.0); - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); expect(value, 'LEFT'); }); diff --git a/packages/flutter/test/material/time_picker_test.dart b/packages/flutter/test/material/time_picker_test.dart index 651bee007d..6f83e957b9 100644 --- a/packages/flutter/test/material/time_picker_test.dart +++ b/packages/flutter/test/material/time_picker_test.dart @@ -38,13 +38,13 @@ class _TimePickerLauncher extends StatelessWidget { Future startPicker(WidgetTester tester, ValueChanged onChanged) async { await tester.pumpWidget(new _TimePickerLauncher(onChanged: onChanged)); 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'))); } Future finishPicker(WidgetTester tester) async { await tester.tap(find.text('OK')); - await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); + await tester.pumpAndSettle(const Duration(seconds: 1)); } void main() { diff --git a/packages/flutter/test/widgets/clamp_overscrolls_test.dart b/packages/flutter/test/widgets/clamp_overscrolls_test.dart index 5ae4ac9a21..264b15743b 100644 --- a/packages/flutter/test/widgets/clamp_overscrolls_test.dart +++ b/packages/flutter/test/widgets/clamp_overscrolls_test.dart @@ -35,7 +35,7 @@ void main() { // Scroll the target text widget by offset and then return its origin // in global coordinates. Future 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(); final RenderBox textBox = tester.renderObject(find.text(target)); final Point widgetOrigin = textBox.localToGlobal(Point.origin); @@ -64,12 +64,12 @@ void main() { await tester.pumpWidget(buildFrame(const BouncingScrollPhysics())); 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(); expect(scrollable.position.pixels, lessThan(0.0)); 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(); expect(scrollable.position.pixels, greaterThan(0.0)); await tester.pump(const Duration(seconds: 1)); // Allow overscroll to settle @@ -79,12 +79,12 @@ void main() { await tester.pumpWidget(buildFrame(const ClampingScrollPhysics())); 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(); expect(scrollable.position.pixels, equals(0.0)); 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(); expect(scrollable.position.pixels, equals(50.0)); }); diff --git a/packages/flutter/test/widgets/gesture_detector_test.dart b/packages/flutter/test/widgets/gesture_detector_test.dart index 8ac18c5f1e..62aa845f84 100644 --- a/packages/flutter/test/widgets/gesture_detector_test.dart +++ b/packages/flutter/test/widgets/gesture_detector_test.dart @@ -118,7 +118,7 @@ void main() { expect(panDelta, isNull); 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(panDelta.dx, 20.0); diff --git a/packages/flutter/test/widgets/grid_view_test.dart b/packages/flutter/test/widgets/grid_view_test.dart index f2a0dc93c4..e81dfaef49 100644 --- a/packages/flutter/test/widgets/grid_view_test.dart +++ b/packages/flutter/test/widgets/grid_view_test.dart @@ -47,7 +47,7 @@ void main() { expect(find.text(kStates[12]), 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(); for (int i = 0; i < 4; ++i) @@ -59,7 +59,7 @@ void main() { 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(); expect(find.text('Alabama'), findsNothing); @@ -72,7 +72,7 @@ void main() { expect(log, equals(['Tennessee'])); 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.tap(find.text('Tennessee')); @@ -114,7 +114,7 @@ void main() { 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(); expect(find.text('Alabama'), findsNothing); diff --git a/packages/flutter/test/widgets/heroes_test.dart b/packages/flutter/test/widgets/heroes_test.dart index b732954656..08803dc5dc 100644 --- a/packages/flutter/test/widgets/heroes_test.dart +++ b/packages/flutter/test/widgets/heroes_test.dart @@ -713,7 +713,7 @@ void main() { // Scroll the target upwards by 25 pixels. The Hero flight's Y coordinate // 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(const Duration(milliseconds: 10)); final double yAt110ms = tester.getTopLeft(find.byKey(routeHeroKey)).y; @@ -788,7 +788,7 @@ void main() { expect(yAt100ms, lessThan(200.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(const Duration(milliseconds: 10)); expect(find.byKey(routeContainerKey), findsNothing); // Scrolled off the top diff --git a/packages/flutter/test/widgets/list_view_horizontal_test.dart b/packages/flutter/test/widgets/list_view_horizontal_test.dart index e13f93b311..49cc844006 100644 --- a/packages/flutter/test/widgets/list_view_horizontal_test.dart +++ b/packages/flutter/test/widgets/list_view_horizontal_test.dart @@ -32,7 +32,7 @@ void main() { await tester.pumpWidget(buildFrame()); 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)); // screen is 800px wide, and has the following items: // -10..280 = 1 @@ -47,9 +47,9 @@ void main() { // 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, - // 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.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)); // screen is 800px wide, and has the following items: // -10..280 = 2 @@ -63,7 +63,7 @@ void main() { expect(find.text('5'), findsNothing); 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)); // unchanged expect(find.text('0'), findsNothing); @@ -74,7 +74,7 @@ void main() { expect(find.text('5'), findsNothing); 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)); // screen is 800px wide, and has the following items: // -10..280 = 3 @@ -93,7 +93,7 @@ void main() { // to move item 3 entirely off screen therefore takes: // 60 + (290-60)*2 = 520 pixels // 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 // screen is 800px wide, and has the following items: // -11..279 = 4 @@ -118,7 +118,7 @@ void main() { await tester.pumpWidget(new Container()); 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)); // screen is 800px wide, and has the following items: // -280..10 = 0 @@ -132,7 +132,7 @@ void main() { expect(find.text('4'), findsNothing); expect(find.text('5'), findsNothing); 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)); // screen is 800px wide, and has the following items: // -280..10 = 1 @@ -162,7 +162,7 @@ void main() { expect(find.text('4'), 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)); // screen is 800px wide, and has the following items: // -80..210 = 3 @@ -177,9 +177,9 @@ void main() { // 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, - // 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.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)); // screen is 800px wide, and has the following items: // -10..280 = 4 @@ -193,7 +193,7 @@ void main() { expect(find.text('5'), findsNothing); 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)); // unchanged expect(find.text('0'), findsNothing); @@ -204,7 +204,7 @@ void main() { expect(find.text('5'), findsNothing); 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)); // screen is 800px wide, and has the following items: // -10..280 = 5 @@ -223,7 +223,7 @@ void main() { // to move item 3 entirely off screen therefore takes: // 60 + (290-60)*2 = 520 pixels // 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 // screen is 800px wide, and has the following items: // 280..570 = 5 diff --git a/packages/flutter/test/widgets/list_view_test.dart b/packages/flutter/test/widgets/list_view_test.dart index 14e1c4650d..e4a6b59ad4 100644 --- a/packages/flutter/test/widgets/list_view_test.dart +++ b/packages/flutter/test/widgets/list_view_test.dart @@ -31,7 +31,7 @@ void main() { expect(find.text('3'), 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(); expect(find.text('0'), findsNothing); @@ -42,7 +42,7 @@ void main() { expect(find.text('5'), 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(); expect(find.text('0'), findsOneWidget); diff --git a/packages/flutter/test/widgets/list_view_vertical_test.dart b/packages/flutter/test/widgets/list_view_vertical_test.dart index 4e5b8ec048..1c6b196801 100644 --- a/packages/flutter/test/widgets/list_view_vertical_test.dart +++ b/packages/flutter/test/widgets/list_view_vertical_test.dart @@ -24,7 +24,7 @@ void main() { await tester.pumpWidget(buildFrame()); 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(); // screen is 600px high, and has the following items: // -10..280 = 1 @@ -38,7 +38,7 @@ void main() { expect(find.text('5'), findsNothing); 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(); // screen is 600px high, and has the following items: // -10..280 = 2 @@ -52,7 +52,7 @@ void main() { expect(find.text('5'), findsNothing); 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(); // nothing should have changed expect(find.text('0'), findsNothing); @@ -88,7 +88,7 @@ void main() { expect(find.text('4'), 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(); // screen is 600px high, and has the following items: // -50..240 = 0 diff --git a/packages/flutter/test/widgets/overscroll_indicator_test.dart b/packages/flutter/test/widgets/overscroll_indicator_test.dart index 47d08a9a48..9f20eab1ef 100644 --- a/packages/flutter/test/widgets/overscroll_indicator_test.dart +++ b/packages/flutter/test/widgets/overscroll_indicator_test.dart @@ -35,7 +35,7 @@ void main() { expect(painter, doesNotOverscroll); // 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); await tester.pump(); // allow the ticker to register itself expect(painter, doesNotOverscroll); @@ -51,7 +51,7 @@ void main() { await slowDrag(tester, const Point(200.0, 200.0), const Offset(0.0, 5.0)); 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); }); @@ -86,7 +86,7 @@ void main() { 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); }); @@ -118,7 +118,7 @@ void main() { } await gesture.up(); - await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); + await tester.pumpAndSettle(const Duration(seconds: 1)); expect(painter, doesNotOverscroll); }); @@ -136,7 +136,7 @@ void main() { 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()); - await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); + await tester.pumpAndSettle(const Duration(seconds: 1)); expect(painter, doesNotOverscroll); }); @@ -154,7 +154,7 @@ void main() { 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()); - await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); + await tester.pumpAndSettle(const Duration(seconds: 1)); expect(painter, doesNotOverscroll); }); }); @@ -175,7 +175,7 @@ void main() { await slowDrag(tester, const Point(200.0, 200.0), const Offset(0.0, -5.0)); expect(painter, paints..circle()..circle()); - await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); + await tester.pumpAndSettle(const Duration(seconds: 1)); expect(painter, doesNotOverscroll); }); @@ -197,7 +197,7 @@ void main() { expect(painter, paints..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); }); @@ -220,8 +220,8 @@ void main() { ), ); - await tester.scrollAt(const Point(100.0, 100.0), const Offset(0.0, 2000.0)); - await tester.pumpUntilNoTransientCallbacks(); + await tester.dragFrom(const Point(100.0, 100.0), const Offset(0.0, 2000.0)); + await tester.pumpAndSettle(); }); testWidgets('Changing settings', (WidgetTester tester) async { @@ -245,7 +245,7 @@ void main() { expect(painter, paints..rotate(angle: math.PI / 2.0)..circle(color: const Color(0x0A00FF00))); expect(painter, isNot(paints..circle()..circle())); - await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); + await tester.pumpAndSettle(const Duration(seconds: 1)); await tester.pumpWidget( new ScrollConfiguration( behavior: new TestScrollBehavior2(), diff --git a/packages/flutter/test/widgets/page_view_test.dart b/packages/flutter/test/widgets/page_view_test.dart index 8d57a779af..3cb90fb4b6 100644 --- a/packages/flutter/test/widgets/page_view_test.dart +++ b/packages/flutter/test/widgets/page_view_test.dart @@ -37,20 +37,20 @@ void main() { 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(); expect(find.text('Alabama'), findsOneWidget); expect(find.text('Alaska'), findsOneWidget); expect(find.text('Arizona'), findsNothing); - await tester.pumpUntilNoTransientCallbacks(_frameDuration); + await tester.pumpAndSettle(_frameDuration); expect(find.text('Alabama'), findsOneWidget); expect(find.text('Alaska'), findsNothing); - await tester.scroll(find.byType(PageView), const Offset(-401.0, 0.0)); - await tester.pumpUntilNoTransientCallbacks(_frameDuration); + await tester.drag(find.byType(PageView), const Offset(-401.0, 0.0)); + await tester.pumpAndSettle(_frameDuration); expect(find.text('Alabama'), findsNothing); expect(find.text('Alaska'), findsOneWidget); @@ -62,14 +62,14 @@ void main() { 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('Alaska'), findsNothing); expect(find.text('Arizona'), findsOneWidget); 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('Alaska'), findsOneWidget); @@ -93,19 +93,18 @@ void main() { )); Size sizeOf(int i) => tester.getSize(find.byKey(new ValueKey(i))); - double leftOf(int i) => - tester.getTopLeft(find.byKey(new ValueKey(i))).x; + double leftOf(int i) => tester.getTopLeft(find.byKey(new ValueKey(i))).x; expect(leftOf(0), equals(0.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(); expect(leftOf(0), equals(100.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(); expect(leftOf(0), equals(-100.0)); @@ -121,18 +120,15 @@ void main() { height: 400.0, child: new PageView( controller: controller, - children: - kStates.map((String state) => new Text(state)).toList(), + children: kStates.map((String state) => new Text(state)).toList(), ), ), )); expect(find.text('California'), findsOneWidget); - controller.nextPage( - duration: const Duration(milliseconds: 150), curve: Curves.ease); - await tester - .pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100)); + controller.nextPage(duration: const Duration(milliseconds: 150), curve: Curves.ease); + await tester.pumpAndSettle(const Duration(milliseconds: 100)); expect(find.text('Colorado'), findsOneWidget); @@ -142,18 +138,15 @@ void main() { height: 400.0, child: new PageView( controller: controller, - children: - kStates.map((String state) => new Text(state)).toList(), + children: kStates.map((String state) => new Text(state)).toList(), ), ), )); expect(find.text('Colorado'), findsOneWidget); - controller.previousPage( - duration: const Duration(milliseconds: 150), curve: Curves.ease); - await tester - .pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100)); + controller.previousPage(duration: const Duration(milliseconds: 150), curve: Curves.ease); + await tester.pumpAndSettle(const Duration(milliseconds: 100)); expect(find.text('California'), findsOneWidget); }); @@ -164,17 +157,15 @@ void main() { width: 600.0, height: 400.0, child: new PageView( - children: - kStates.map((String state) => new Text(state)).toList(), + children: kStates.map((String state) => new Text(state)).toList(), ), ), )); expect(find.text('Alabama'), findsOneWidget); - await tester.scroll(find.byType(PageView), const Offset(-1250.0, 0.0)); - await tester - .pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100)); + await tester.drag(find.byType(PageView), const Offset(-1250.0, 0.0)); + await tester.pumpAndSettle(const Duration(milliseconds: 100)); expect(find.text('Arizona'), findsOneWidget); @@ -183,8 +174,7 @@ void main() { width: 250.0, height: 100.0, child: new PageView( - children: - kStates.map((String state) => new Text(state)).toList(), + children: kStates.map((String state) => new Text(state)).toList(), ), ), )); @@ -196,8 +186,7 @@ void main() { width: 450.0, height: 400.0, child: new PageView( - children: - kStates.map((String state) => new Text(state)).toList(), + children: kStates.map((String state) => new Text(state)).toList(), ), ), )); @@ -211,8 +200,7 @@ void main() { width: 0.0, height: 0.0, child: new PageView( - children: - kStates.map((String state) => new Text(state)).toList(), + children: kStates.map((String state) => new Text(state)).toList(), ), ), )); @@ -224,8 +212,7 @@ void main() { width: 200.0, height: 200.0, child: new PageView( - children: - kStates.map((String state) => new Text(state)).toList(), + children: kStates.map((String state) => new Text(state)).toList(), ), ), )); @@ -274,7 +261,7 @@ void main() { expect(log, isEmpty); await gesture.up(); - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); expect(log, isEmpty); @@ -352,8 +339,7 @@ void main() { controller.jumpToPage(10); await tester.pump(); - expect( - tester.getTopLeft(find.text('Connecticut')), const Point(-50.0, 0.0)); + expect(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('Florida')), const Point(150.0, 0.0)); expect(tester.getTopLeft(find.text('Georgia')), const Point(250.0, 0.0)); @@ -387,8 +373,7 @@ void main() { await tester.pumpWidget(build(controller)); expect(tester.getTopLeft(find.text('Alabama')), const Point(-100.0, 0.0)); - expect( - tester.getBottomRight(find.text('Alabama')), const Point(900.0, 600.0)); + expect(tester.getBottomRight(find.text('Alabama')), const Point(900.0, 600.0)); controller.jumpToPage(10); await tester.pump(); @@ -398,8 +383,9 @@ void main() { testWidgets('PageView does not report page changed on overscroll', (WidgetTester tester) async { - final PageController controller = - new PageController(initialPage: kStates.length - 1); + final PageController controller = new PageController( + initialPage: kStates.length - 1, + ); int changeIndex = 0; Widget build() { return new PageView( diff --git a/packages/flutter/test/widgets/pageable_list_test.dart b/packages/flutter/test/widgets/pageable_list_test.dart index f3f5ce13f6..0e95a70df3 100644 --- a/packages/flutter/test/widgets/pageable_list_test.dart +++ b/packages/flutter/test/widgets/pageable_list_test.dart @@ -43,9 +43,8 @@ Widget buildFrame({ Future page(WidgetTester tester, Offset offset) { return TestAsyncUtils.guard(() async { final String itemText = currentPage != null ? currentPage.toString() : '0'; - await tester.scroll(find.text(itemText), offset); - await tester.pump(); - await tester.pumpUntilNoTransientCallbacks(); + await tester.drag(find.text(itemText), offset); + await tester.pumpAndSettle(); }); } diff --git a/packages/flutter/test/widgets/scroll_controller_test.dart b/packages/flutter/test/widgets/scroll_controller_test.dart index 5aba22a5d2..b9a1d81de4 100644 --- a/packages/flutter/test/widgets/scroll_controller_test.dart +++ b/packages/flutter/test/widgets/scroll_controller_test.dart @@ -39,7 +39,7 @@ void main() { expect(realOffset(), equals(controller.offset)); 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(realOffset(), equals(controller.offset)); @@ -228,7 +228,6 @@ void main() { controller.jumpTo(1.0); controller.animateTo(1.0, duration: const Duration(seconds: 1), curve: Curves.linear); - await tester.pump(); - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); }); } diff --git a/packages/flutter/test/widgets/scroll_view_test.dart b/packages/flutter/test/widgets/scroll_view_test.dart index 64a45927ea..6aa8d47d24 100644 --- a/packages/flutter/test/widgets/scroll_view_test.dart +++ b/packages/flutter/test/widgets/scroll_view_test.dart @@ -34,7 +34,7 @@ void main() { 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(); expect(find.text('Alabama'), findsNothing); @@ -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.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100)); + await tester.pumpAndSettle(const Duration(milliseconds: 100)); final Viewport viewport = tester.widget(find.byType(Viewport)); expect(viewport.offset.pixels, equals(2400.0)); @@ -105,7 +105,7 @@ void main() { 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(); expect(find.text('Alabama'), findsNothing); diff --git a/packages/flutter/test/widgets/scrollable_grid_test.dart b/packages/flutter/test/widgets/scrollable_grid_test.dart index 4fe938ed96..671099c10d 100644 --- a/packages/flutter/test/widgets/scrollable_grid_test.dart +++ b/packages/flutter/test/widgets/scrollable_grid_test.dart @@ -44,7 +44,7 @@ void main() { expect(find.text('2'), 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(); // -100..300 = 1 // 300..600 = 2 @@ -56,7 +56,7 @@ void main() { expect(find.text('4'), 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(); // Child '0' is now back onscreen, but by less than `padding.top`. // -250..050 = 0 diff --git a/packages/flutter/test/widgets/scrollable_list_hit_testing_test.dart b/packages/flutter/test/widgets/scrollable_list_hit_testing_test.dart index 7f61576042..8e5b9e1e49 100644 --- a/packages/flutter/test/widgets/scrollable_list_hit_testing_test.dart +++ b/packages/flutter/test/widgets/scrollable_list_hit_testing_test.dart @@ -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)); // screen is 800px wide, and has the following items: // -280..10 = 0 @@ -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)); // screen is 600px tall, and has the following items: // -280..10 = 0 diff --git a/packages/flutter/test/widgets/single_child_scroll_view_test.dart b/packages/flutter/test/widgets/single_child_scroll_view_test.dart index 4edc80b482..7cb28121d1 100644 --- a/packages/flutter/test/widgets/single_child_scroll_view_test.dart +++ b/packages/flutter/test/widgets/single_child_scroll_view_test.dart @@ -45,7 +45,7 @@ void main() { final RenderBox box = tester.renderObject(find.byType(Container)); 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))); }); diff --git a/packages/flutter/test/widgets/sliver_fill_remaining_test.dart b/packages/flutter/test/widgets/sliver_fill_remaining_test.dart index 8dbcd50007..28fb6197a6 100644 --- a/packages/flutter/test/widgets/sliver_fill_remaining_test.dart +++ b/packages/flutter/test/widgets/sliver_fill_remaining_test.dart @@ -28,7 +28,7 @@ void main() { expect(find.text('1'), 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(); expect(find.text('0'), findsNothing); @@ -37,7 +37,7 @@ void main() { expect(find.text('3'), 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(); expect(find.text('0'), findsOneWidget); diff --git a/packages/flutter/test/widgets/slivers_appbar_floating_test.dart b/packages/flutter/test/widgets/slivers_appbar_floating_test.dart index 4608a06511..c7ded30a29 100644 --- a/packages/flutter/test/widgets/slivers_appbar_floating_test.dart +++ b/packages/flutter/test/widgets/slivers_appbar_floating_test.dart @@ -42,7 +42,7 @@ void main() { expect(position.minScrollExtent, 0.0); expect(position.maxScrollExtent, max); 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.minScrollExtent, 0.0); expect(position.maxScrollExtent, max); @@ -68,7 +68,7 @@ void main() { verifyPaintPosition(key3, const Offset(0.0, 600.0), false); 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(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)); @@ -76,42 +76,42 @@ void main() { 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)); - await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 1000)); + await tester.pumpAndSettle(const Duration(milliseconds: 1000)); verifyPaintPosition(key1, const Offset(0.0, 0.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)); verifyPaintPosition(key3, new Offset(0.0, 600.0 - delegate.maxExtent), true); 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(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)); verifyPaintPosition(key3, new Offset(0.0, delegate.maxExtent), true); 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(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)); 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)); - await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 1000)); + await tester.pumpAndSettle(const Duration(milliseconds: 1000)); verifyPaintPosition(key1, const Offset(0.0, 0.0), false); 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)); 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)); - await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 1000)); + await tester.pumpAndSettle(const Duration(milliseconds: 1000)); verifyPaintPosition(key1, const Offset(0.0, 0.0), false); 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)); 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)); - await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 1000)); + await tester.pumpAndSettle(const Duration(milliseconds: 1000)); verifyPaintPosition(key1, 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); @@ -137,13 +137,13 @@ void main() { verifyPaintPosition(key3, const Offset(0.0, 600.0), false); 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(key2, const Offset(0.0, 0.0), false); verifyPaintPosition(key3, const Offset(0.0, 0.0), true); 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(key2, const Offset(0.0, 0.0), false); verifyPaintPosition(key3, const Offset(0.0, 0.0), true); @@ -169,14 +169,14 @@ void main() { verifyPaintPosition(key3, const Offset(0.0, 600.0), false); 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(key2, const Offset(0.0, 0.0), false); 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.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(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)); diff --git a/packages/flutter/test/widgets/slivers_appbar_pinned_test.dart b/packages/flutter/test/widgets/slivers_appbar_pinned_test.dart index cfb19bae73..34eac49e2b 100644 --- a/packages/flutter/test/widgets/slivers_appbar_pinned_test.dart +++ b/packages/flutter/test/widgets/slivers_appbar_pinned_test.dart @@ -45,7 +45,7 @@ void main() { expect(position.minScrollExtent, 0.0); expect(position.maxScrollExtent, max); 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.minScrollExtent, 0.0); expect(position.maxScrollExtent, max); @@ -77,21 +77,21 @@ void main() { verifyPaintPosition(key4, 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)); - await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 100)); + await tester.pumpAndSettle(const Duration(milliseconds: 100)); verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key3, const Offset(0.0, 200.0), true); verifyPaintPosition(key4, const Offset(0.0, 400.0), true); verifyPaintPosition(key5, const Offset(0.0, 600.0), false); 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(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key3, const Offset(0.0, 150.0), true); verifyPaintPosition(key4, const Offset(0.0, 350.0), true); verifyPaintPosition(key5, const Offset(0.0, 600.0), false); 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(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key3, const Offset(0.0, 100.0), true); @@ -99,7 +99,7 @@ void main() { verifyPaintPosition(key4, const Offset(0.0, 300.0), true); verifyPaintPosition(key5, const Offset(0.0, 600.0), false); 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(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key3, const Offset(0.0, 100.0), true); @@ -107,7 +107,7 @@ void main() { verifyPaintPosition(key4, const Offset(0.0, 250.0), true); verifyPaintPosition(key5, const Offset(0.0, 600.0), false); 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(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key3, const Offset(0.0, 100.0), true); @@ -115,28 +115,28 @@ void main() { verifyPaintPosition(key4, const Offset(0.0, 200.0), true); verifyPaintPosition(key5, const Offset(0.0, 600.0), false); 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(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key3, const Offset(0.0, 100.0), true); verifyPaintPosition(key4, const Offset(0.0, 150.0), true); verifyPaintPosition(key5, const Offset(0.0, 600.0), false); 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(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key3, 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); 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(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key3, const Offset(0.0, 100.0), true); verifyPaintPosition(key4, const Offset(0.0, 50.0), true); verifyPaintPosition(key5, const Offset(0.0, 600.0), false); 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(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key3, const Offset(0.0, 100.0), true); @@ -167,7 +167,7 @@ void main() { expect(position.minScrollExtent, 0.0); expect(position.maxScrollExtent, max); 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.minScrollExtent, 0.0); expect(position.maxScrollExtent, max); diff --git a/packages/flutter/test/widgets/slivers_appbar_scrolling_test.dart b/packages/flutter/test/widgets/slivers_appbar_scrolling_test.dart index 6b87ad7188..aea4c402f3 100644 --- a/packages/flutter/test/widgets/slivers_appbar_scrolling_test.dart +++ b/packages/flutter/test/widgets/slivers_appbar_scrolling_test.dart @@ -36,7 +36,7 @@ void main() { expect(position.minScrollExtent, 0.0); expect(position.maxScrollExtent, max); 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.minScrollExtent, 0.0); expect(position.maxScrollExtent, max); @@ -62,7 +62,7 @@ void main() { ); final ScrollPosition position = tester.state(find.byType(Scrollable)).position; 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(find.byType(Container)); 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))); diff --git a/packages/flutter/test/widgets/slivers_evil_test.dart b/packages/flutter/test/widgets/slivers_evil_test.dart index 860c98b290..38fb0515fe 100644 --- a/packages/flutter/test/widgets/slivers_evil_test.dart +++ b/packages/flutter/test/widgets/slivers_evil_test.dart @@ -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: 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)); await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10)); 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)); await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10)); 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)); await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10)); 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)); await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 50)); - await tester.pumpUntilNoTransientCallbacks(const Duration(milliseconds: 122)); + await tester.pumpAndSettle(const Duration(milliseconds: 122)); }); } diff --git a/packages/flutter/test/widgets/slivers_protocol_test.dart b/packages/flutter/test/widgets/slivers_protocol_test.dart index a2385ae2fd..ef41f751c3 100644 --- a/packages/flutter/test/widgets/slivers_protocol_test.dart +++ b/packages/flutter/test/widgets/slivers_protocol_test.dart @@ -38,7 +38,7 @@ void main() { expect(position.minScrollExtent, 0.0); expect(position.maxScrollExtent, max); 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.minScrollExtent, 0.0); expect(position.maxScrollExtent, max); diff --git a/packages/flutter/test/widgets/state_setting_in_scrollables_test.dart b/packages/flutter/test/widgets/state_setting_in_scrollables_test.dart index bfd44b7819..63971895b1 100644 --- a/packages/flutter/test/widgets/state_setting_in_scrollables_test.dart +++ b/packages/flutter/test/widgets/state_setting_in_scrollables_test.dart @@ -82,8 +82,7 @@ void main() { await tester.pumpWidget(new Foo()); expect(tester.state(find.byType(Scrollable)).position.pixels, 0.0); await tester.tap(find.byType(GestureDetector).first); - await tester.pump(); - await tester.pumpUntilNoTransientCallbacks(); + await tester.pumpAndSettle(); expect(tester.state(find.byType(Scrollable)).position.pixels, 200.0); }); } diff --git a/packages/flutter_test/lib/src/controller.dart b/packages/flutter_test/lib/src/controller.dart index 89273bfc02..4d1787f186 100644 --- a/packages/flutter_test/lib/src/controller.dart +++ b/packages/flutter_test/lib/src/controller.dart @@ -248,16 +248,16 @@ class WidgetController { // INTERACTION /// Dispatch a pointer down / pointer up sequence at the center of - /// the given widget, assuming it is exposed. If the center of the - /// widget is not exposed, this might send events to another - /// object. - Future tap(Finder finder, { int pointer: 1 }) { + /// the given widget, assuming it is exposed. + /// + /// If the center of the widget is not exposed, this might send events to + /// another object. + Future tap(Finder finder, { int pointer }) { return tapAt(getCenter(finder), pointer: pointer); } - /// Dispatch a pointer down / pointer up sequence at the given - /// location. - Future tapAt(Point location, { int pointer: 1 }) { + /// Dispatch a pointer down / pointer up sequence at the given location. + Future tapAt(Point location, { int pointer }) { return TestAsyncUtils.guard(() async { final TestGesture gesture = await startGesture(location, pointer: pointer); await gesture.up(); @@ -267,16 +267,17 @@ class WidgetController { /// Dispatch a pointer down / pointer up sequence (with a delay of /// [kLongPressTimeout] + [kPressTimeout] between the two events) at the - /// center of the given widget, assuming it is exposed. If the center of the - /// widget is not exposed, this might send events to another - /// object. - Future longPress(Finder finder, { int pointer: 1 }) { + /// center of the given widget, assuming it is exposed. + /// + /// If the center of the widget is not exposed, this might send events to + /// another object. + Future longPress(Finder finder, { int pointer }) { return longPressAt(getCenter(finder), pointer: pointer); } /// Dispatch a pointer down / pointer up sequence at the given location with /// a delay of [kLongPressTimeout] + [kPressTimeout] between the two events. - Future longPressAt(Point location, { int pointer: 1 }) { + Future longPressAt(Point location, { int pointer }) { return TestAsyncUtils.guard(() async { final TestGesture gesture = await startGesture(location, pointer: pointer); await pump(kLongPressTimeout + kPressTimeout); @@ -286,25 +287,33 @@ class WidgetController { } /// 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 /// events to another object. /// /// This can pump frames. See [flingFrom] for a discussion of how the /// `offset`, `velocity` and `frameInterval` arguments affect this. - Future 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 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, - /// moving the given distance, reaching the given velocity. + /// Attempts a fling gesture starting from the given location, moving the + /// given distance, reaching the given speed. /// /// Exactly 50 pointer events are synthesized. /// - /// The offset and velocity control the interval between each pointer event. - /// For example, if the offset is 200 pixels, and the velocity is 800 pixels - /// per second, the pointer events will be sent for each increment of 4 pixels + /// The offset and speed control the interval between each pointer event. For + /// example, if the offset is 200 pixels down, and the speed is 800 pixels per + /// 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 /// (250/200). /// @@ -312,27 +321,30 @@ class WidgetController { /// calls to [pump]). If the total duration is longer than `frameInterval`, /// 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. - Future 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 flingFrom(Point startLocation, Offset offset, double speed, { int pointer, Duration frameInterval: const Duration(milliseconds: 16) }) { 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 { - final TestPointer p = new TestPointer(pointer); + final TestPointer testPointer = new TestPointer(pointer ?? _getNextPointer()); final HitTestResult result = hitTestOnBinding(startLocation); 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 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) { 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; if (timeStamp - lastTimeStamp > frameInterval.inMilliseconds) { await pump(new Duration(milliseconds: (timeStamp - lastTimeStamp).truncate())); 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; }); } @@ -352,13 +364,20 @@ class WidgetController { /// /// If the middle of the widget is not exposed, this might send /// events to another object. - Future 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 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 /// the given offset, and a pointer up. - Future 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 dragFrom(Point startLocation, Offset offset, { int pointer }) { return TestAsyncUtils.guard(() async { final TestGesture gesture = await startGesture(startLocation, pointer: pointer); await gesture.moveBy(offset); @@ -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 /// [TestGesture] object which you can use to continue the gesture. - Future startGesture(Point downLocation, { int pointer: 1 }) { - return TestGesture.down(downLocation, pointer: pointer, hitTester: hitTestOnBinding, dispatcher: sendEventToBinding); + Future startGesture(Point downLocation, { int pointer }) { + return TestGesture.down( + downLocation, + pointer: pointer ?? _getNextPointer(), + hitTester: hitTestOnBinding, + dispatcher: sendEventToBinding, + ); } /// Forwards the given location to the binding's hitTest logic. diff --git a/packages/flutter_test/lib/src/test_pointer.dart b/packages/flutter_test/lib/src/test_pointer.dart index 75e20bd560..f22b9a9d50 100644 --- a/packages/flutter_test/lib/src/test_pointer.dart +++ b/packages/flutter_test/lib/src/test_pointer.dart @@ -15,8 +15,12 @@ export 'dart:ui' show Point; /// You can use this to manually simulate individual events, but the /// simplest way to generate coherent gestures is to use [TestGesture]. class TestPointer { - /// Creates a [TestPointer]. By default, the pointer identifier used is 1, however - /// this can be overridden by providing an argument to the constructor. + /// Creates a [TestPointer]. By default, the pointer identifier used is 1, + /// 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 ]); /// The pointer identifier used for events generated by this object. @@ -123,7 +127,7 @@ class TestGesture { /// Create a [TestGesture] by starting with a pointerDown at the /// 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. /// /// A function to use for hit testing should be provided via the `hitTester` diff --git a/packages/flutter_test/lib/src/widget_tester.dart b/packages/flutter_test/lib/src/widget_tester.dart index a56aa8ab26..8d127c7155 100644 --- a/packages/flutter_test/lib/src/widget_tester.dart +++ b/packages/flutter_test/lib/src/widget_tester.dart @@ -191,8 +191,10 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker } /// Repeatedly calls [pump] with the given `duration` until there are no - /// longer any transient callbacks scheduled. If no transient callbacks are - /// scheduled when the function is called, it returns without calling [pump]. + /// longer any transient callbacks scheduled. This will call [pump] at least + /// 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. /// @@ -209,7 +211,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker /// /// Alternatively, one can check that the return value from this function /// matches the expected number of pumps. - Future pumpUntilNoTransientCallbacks([ + Future pumpAndSettle([ Duration duration = const Duration(milliseconds: 100), EnginePhase phase = EnginePhase.sendSemanticsTree ]) { @@ -217,10 +219,10 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker assert(duration > Duration.ZERO); int count = 0; return TestAsyncUtils.guard(() async { - while (binding.transientCallbackCount > 0) { + do { await binding.pump(duration, phase); count += 1; - } + } while (binding.transientCallbackCount > 0); }).then((Null _) => count); } diff --git a/packages/flutter_test/test/widget_tester_test.dart b/packages/flutter_test/test/widget_tester_test.dart index bf8b3b1150..e4253f7a84 100644 --- a/packages/flutter_test/test/widget_tester_test.dart +++ b/packages/flutter_test/test/widget_tester_test.dart @@ -77,11 +77,11 @@ void main() { duration: const Duration(milliseconds: 5100), vsync: tester, ); - count = await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); - expect(count, 0); + count = await tester.pumpAndSettle(const Duration(seconds: 1)); + expect(count, 1); // it always pumps at least one frame 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=1 // 1 frame at t=2 @@ -93,13 +93,13 @@ void main() { test.forward(from: 0.0); 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); test.forward(from: 0.0); await tester.pump(); // starts the animation 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); }); }); @@ -180,9 +180,9 @@ void main() { expect(failure, isNotNull); expect( - failure.message, - contains('Actual: ?: