Unverified Commit 19722fb9 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Clean up dismissable_test to be less fragile (#89870)

This cleans up the dismissable_test to be less fragile, and make it harder to forget to reset things between runs.

I eliminated a bunch of globals that were susceptible to being missed and passed them in to buildTest instead, and removed some values that were always the same (itemExtent).
parent 83dfb223
...@@ -6,21 +6,20 @@ import 'package:flutter/gestures.dart' show DragStartBehavior; ...@@ -6,21 +6,20 @@ import 'package:flutter/gestures.dart' show DragStartBehavior;
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
const double itemExtent = 100.0;
const Axis defaultScrollDirection = Axis.vertical;
Axis scrollDirection = defaultScrollDirection;
const DismissDirection defaultDismissDirection = DismissDirection.horizontal; const DismissDirection defaultDismissDirection = DismissDirection.horizontal;
DismissDirection dismissDirection = defaultDismissDirection;
late DismissDirection reportedDismissDirection;
List<int> dismissedItems = <int>[];
Widget? background;
const double crossAxisEndOffset = 0.5; const double crossAxisEndOffset = 0.5;
DismissDirection reportedDismissDirection = DismissDirection.horizontal;
List<int> dismissedItems = <int>[];
Widget buildTest({ Widget buildTest({
Axis scrollDirection = Axis.vertical,
DismissDirection dismissDirection = defaultDismissDirection,
double? startToEndThreshold, double? startToEndThreshold,
TextDirection textDirection = TextDirection.ltr, TextDirection textDirection = TextDirection.ltr,
Future<bool?> Function(BuildContext context, DismissDirection direction)? confirmDismiss, Future<bool?> Function(BuildContext context, DismissDirection direction)? confirmDismiss,
ScrollController? controller, ScrollController? controller,
Widget? background,
}) { }) {
return Directionality( return Directionality(
textDirection: textDirection, textDirection: textDirection,
...@@ -50,8 +49,8 @@ Widget buildTest({ ...@@ -50,8 +49,8 @@ Widget buildTest({
: <DismissDirection, double>{DismissDirection.startToEnd: startToEndThreshold}, : <DismissDirection, double>{DismissDirection.startToEnd: startToEndThreshold},
crossAxisEndOffset: crossAxisEndOffset, crossAxisEndOffset: crossAxisEndOffset,
child: SizedBox( child: SizedBox(
width: itemExtent, width: 100.0,
height: itemExtent, height: 100.0,
child: Text(item.toString()), child: Text(item.toString()),
), ),
); );
...@@ -63,7 +62,7 @@ Widget buildTest({ ...@@ -63,7 +62,7 @@ Widget buildTest({
controller: controller, controller: controller,
dragStartBehavior: DragStartBehavior.down, dragStartBehavior: DragStartBehavior.down,
scrollDirection: scrollDirection, scrollDirection: scrollDirection,
itemExtent: itemExtent, itemExtent: 100.0,
children: <int>[0, 1, 2, 3, 4, 5, 6, 7, 8] children: <int>[0, 1, 2, 3, 4, 5, 6, 7, 8]
.where((int i) => !dismissedItems.contains(i)) .where((int i) => !dismissedItems.contains(i))
.map<Widget>(buildDismissibleItem).toList(), .map<Widget>(buildDismissibleItem).toList(),
...@@ -226,22 +225,18 @@ class Test1215DismissibleWidget extends StatelessWidget { ...@@ -226,22 +225,18 @@ class Test1215DismissibleWidget extends StatelessWidget {
void main() { void main() {
setUp(() { setUp(() {
// Reset "results" variables.
reportedDismissDirection = defaultDismissDirection;
dismissedItems = <int>[]; dismissedItems = <int>[];
background = null;
});
tearDown(() {
// Restore the default values of dismissDirection and scrollDirection
// in order to ensure consistency when the test order is randomized.
dismissDirection = defaultDismissDirection;
scrollDirection = defaultScrollDirection;
}); });
testWidgets('Horizontal drag triggers dismiss scrollDirection=vertical', (WidgetTester tester) async { testWidgets('Horizontal drag triggers dismiss scrollDirection=vertical', (WidgetTester tester) async {
scrollDirection = Axis.vertical; await tester.pumpWidget(
dismissDirection = DismissDirection.horizontal; buildTest(
scrollDirection: Axis.vertical,
await tester.pumpWidget(buildTest()); dismissDirection: DismissDirection.horizontal,
),
);
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, gestureDirection: AxisDirection.right); await dismissItem(tester, 0, gestureDirection: AxisDirection.right);
...@@ -256,10 +251,12 @@ void main() { ...@@ -256,10 +251,12 @@ void main() {
}); });
testWidgets('Horizontal fling triggers dismiss scrollDirection=vertical', (WidgetTester tester) async { testWidgets('Horizontal fling triggers dismiss scrollDirection=vertical', (WidgetTester tester) async {
scrollDirection = Axis.vertical; await tester.pumpWidget(
dismissDirection = DismissDirection.horizontal; buildTest(
scrollDirection: Axis.vertical,
await tester.pumpWidget(buildTest()); dismissDirection: DismissDirection.horizontal,
),
);
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, gestureDirection: AxisDirection.right, mechanism: flingElement); await dismissItem(tester, 0, gestureDirection: AxisDirection.right, mechanism: flingElement);
...@@ -274,10 +271,13 @@ void main() { ...@@ -274,10 +271,13 @@ void main() {
}); });
testWidgets('Horizontal fling does not trigger at zero offset, but does otherwise', (WidgetTester tester) async { testWidgets('Horizontal fling does not trigger at zero offset, but does otherwise', (WidgetTester tester) async {
scrollDirection = Axis.vertical; await tester.pumpWidget(
dismissDirection = DismissDirection.horizontal; buildTest(
startToEndThreshold: 0.95,
await tester.pumpWidget(buildTest(startToEndThreshold: 0.95)); scrollDirection: Axis.vertical,
dismissDirection: DismissDirection.horizontal,
),
);
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, gestureDirection: AxisDirection.right, mechanism: flingElementFromZero); await dismissItem(tester, 0, gestureDirection: AxisDirection.right, mechanism: flingElementFromZero);
...@@ -300,10 +300,12 @@ void main() { ...@@ -300,10 +300,12 @@ void main() {
}); });
testWidgets('Vertical drag triggers dismiss scrollDirection=horizontal', (WidgetTester tester) async { testWidgets('Vertical drag triggers dismiss scrollDirection=horizontal', (WidgetTester tester) async {
scrollDirection = Axis.horizontal; await tester.pumpWidget(
dismissDirection = DismissDirection.vertical; buildTest(
scrollDirection: Axis.horizontal,
await tester.pumpWidget(buildTest()); dismissDirection: DismissDirection.vertical,
),
);
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, gestureDirection: AxisDirection.up); await dismissItem(tester, 0, gestureDirection: AxisDirection.up);
...@@ -318,10 +320,12 @@ void main() { ...@@ -318,10 +320,12 @@ void main() {
}); });
testWidgets('drag-left with DismissDirection.endToStart triggers dismiss (LTR)', (WidgetTester tester) async { testWidgets('drag-left with DismissDirection.endToStart triggers dismiss (LTR)', (WidgetTester tester) async {
scrollDirection = Axis.vertical; await tester.pumpWidget(
dismissDirection = DismissDirection.endToStart; buildTest(
scrollDirection: Axis.vertical,
await tester.pumpWidget(buildTest()); dismissDirection: DismissDirection.endToStart,
),
);
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, gestureDirection: AxisDirection.right); await dismissItem(tester, 0, gestureDirection: AxisDirection.right);
...@@ -336,10 +340,12 @@ void main() { ...@@ -336,10 +340,12 @@ void main() {
}); });
testWidgets('drag-right with DismissDirection.startToEnd triggers dismiss (LTR)', (WidgetTester tester) async { testWidgets('drag-right with DismissDirection.startToEnd triggers dismiss (LTR)', (WidgetTester tester) async {
scrollDirection = Axis.vertical; await tester.pumpWidget(
dismissDirection = DismissDirection.startToEnd; buildTest(
scrollDirection: Axis.vertical,
await tester.pumpWidget(buildTest()); dismissDirection: DismissDirection.startToEnd,
),
);
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, gestureDirection: AxisDirection.left); await dismissItem(tester, 0, gestureDirection: AxisDirection.left);
...@@ -352,10 +358,14 @@ void main() { ...@@ -352,10 +358,14 @@ void main() {
}); });
testWidgets('drag-right with DismissDirection.endToStart triggers dismiss (RTL)', (WidgetTester tester) async { testWidgets('drag-right with DismissDirection.endToStart triggers dismiss (RTL)', (WidgetTester tester) async {
scrollDirection = Axis.vertical; await tester.pumpWidget(
dismissDirection = DismissDirection.endToStart; buildTest(
textDirection: TextDirection.rtl,
scrollDirection: Axis.vertical,
dismissDirection: DismissDirection.endToStart,
),
);
await tester.pumpWidget(buildTest(textDirection: TextDirection.rtl));
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, gestureDirection: AxisDirection.left); await dismissItem(tester, 0, gestureDirection: AxisDirection.left);
...@@ -368,10 +378,13 @@ void main() { ...@@ -368,10 +378,13 @@ void main() {
}); });
testWidgets('drag-left with DismissDirection.startToEnd triggers dismiss (RTL)', (WidgetTester tester) async { testWidgets('drag-left with DismissDirection.startToEnd triggers dismiss (RTL)', (WidgetTester tester) async {
scrollDirection = Axis.vertical; await tester.pumpWidget(
dismissDirection = DismissDirection.startToEnd; buildTest(
textDirection: TextDirection.rtl,
await tester.pumpWidget(buildTest(textDirection: TextDirection.rtl)); scrollDirection: Axis.vertical,
dismissDirection: DismissDirection.startToEnd,
),
);
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, gestureDirection: AxisDirection.right); await dismissItem(tester, 0, gestureDirection: AxisDirection.right);
...@@ -386,10 +399,12 @@ void main() { ...@@ -386,10 +399,12 @@ void main() {
}); });
testWidgets('fling-left with DismissDirection.endToStart triggers dismiss (LTR)', (WidgetTester tester) async { testWidgets('fling-left with DismissDirection.endToStart triggers dismiss (LTR)', (WidgetTester tester) async {
scrollDirection = Axis.vertical; await tester.pumpWidget(
dismissDirection = DismissDirection.endToStart; buildTest(
scrollDirection: Axis.vertical,
await tester.pumpWidget(buildTest()); dismissDirection: DismissDirection.endToStart,
),
);
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, gestureDirection: AxisDirection.right); await dismissItem(tester, 0, gestureDirection: AxisDirection.right);
...@@ -404,10 +419,13 @@ void main() { ...@@ -404,10 +419,13 @@ void main() {
}); });
testWidgets('fling-right with DismissDirection.startToEnd triggers dismiss (LTR)', (WidgetTester tester) async { testWidgets('fling-right with DismissDirection.startToEnd triggers dismiss (LTR)', (WidgetTester tester) async {
scrollDirection = Axis.vertical; await tester.pumpWidget(
dismissDirection = DismissDirection.startToEnd; buildTest(
scrollDirection: Axis.vertical,
dismissDirection: DismissDirection.startToEnd,
),
);
await tester.pumpWidget(buildTest());
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, mechanism: flingElement, gestureDirection: AxisDirection.left); await dismissItem(tester, 0, mechanism: flingElement, gestureDirection: AxisDirection.left);
...@@ -420,10 +438,13 @@ void main() { ...@@ -420,10 +438,13 @@ void main() {
}); });
testWidgets('fling-right with DismissDirection.endToStart triggers dismiss (RTL)', (WidgetTester tester) async { testWidgets('fling-right with DismissDirection.endToStart triggers dismiss (RTL)', (WidgetTester tester) async {
scrollDirection = Axis.vertical; await tester.pumpWidget(
dismissDirection = DismissDirection.endToStart; buildTest(
textDirection: TextDirection.rtl,
await tester.pumpWidget(buildTest(textDirection: TextDirection.rtl)); scrollDirection: Axis.vertical,
dismissDirection: DismissDirection.endToStart,
),
);
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, mechanism: flingElement, gestureDirection: AxisDirection.left); await dismissItem(tester, 0, mechanism: flingElement, gestureDirection: AxisDirection.left);
...@@ -436,10 +457,13 @@ void main() { ...@@ -436,10 +457,13 @@ void main() {
}); });
testWidgets('fling-left with DismissDirection.startToEnd triggers dismiss (RTL)', (WidgetTester tester) async { testWidgets('fling-left with DismissDirection.startToEnd triggers dismiss (RTL)', (WidgetTester tester) async {
scrollDirection = Axis.vertical; await tester.pumpWidget(
dismissDirection = DismissDirection.startToEnd; buildTest(
textDirection: TextDirection.rtl,
await tester.pumpWidget(buildTest(textDirection: TextDirection.rtl)); scrollDirection: Axis.vertical,
dismissDirection: DismissDirection.startToEnd,
),
);
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, mechanism: flingElement, gestureDirection: AxisDirection.right); await dismissItem(tester, 0, mechanism: flingElement, gestureDirection: AxisDirection.right);
...@@ -454,10 +478,12 @@ void main() { ...@@ -454,10 +478,12 @@ void main() {
}); });
testWidgets('drag-up with DismissDirection.up triggers dismiss', (WidgetTester tester) async { testWidgets('drag-up with DismissDirection.up triggers dismiss', (WidgetTester tester) async {
scrollDirection = Axis.horizontal; await tester.pumpWidget(
dismissDirection = DismissDirection.up; buildTest(
scrollDirection: Axis.horizontal,
await tester.pumpWidget(buildTest()); dismissDirection: DismissDirection.up,
),
);
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, gestureDirection: AxisDirection.down); await dismissItem(tester, 0, gestureDirection: AxisDirection.down);
...@@ -470,10 +496,12 @@ void main() { ...@@ -470,10 +496,12 @@ void main() {
}); });
testWidgets('drag-down with DismissDirection.down triggers dismiss', (WidgetTester tester) async { testWidgets('drag-down with DismissDirection.down triggers dismiss', (WidgetTester tester) async {
scrollDirection = Axis.horizontal; await tester.pumpWidget(
dismissDirection = DismissDirection.down; buildTest(
scrollDirection: Axis.horizontal,
await tester.pumpWidget(buildTest()); dismissDirection: DismissDirection.down,
),
);
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, gestureDirection: AxisDirection.up); await dismissItem(tester, 0, gestureDirection: AxisDirection.up);
...@@ -486,10 +514,12 @@ void main() { ...@@ -486,10 +514,12 @@ void main() {
}); });
testWidgets('fling-up with DismissDirection.up triggers dismiss', (WidgetTester tester) async { testWidgets('fling-up with DismissDirection.up triggers dismiss', (WidgetTester tester) async {
scrollDirection = Axis.horizontal; await tester.pumpWidget(
dismissDirection = DismissDirection.up; buildTest(
scrollDirection: Axis.horizontal,
await tester.pumpWidget(buildTest()); dismissDirection: DismissDirection.up,
),
);
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, mechanism: flingElement, gestureDirection: AxisDirection.down); await dismissItem(tester, 0, mechanism: flingElement, gestureDirection: AxisDirection.down);
...@@ -502,10 +532,12 @@ void main() { ...@@ -502,10 +532,12 @@ void main() {
}); });
testWidgets('fling-down with DismissDirection.down triggers dismiss', (WidgetTester tester) async { testWidgets('fling-down with DismissDirection.down triggers dismiss', (WidgetTester tester) async {
scrollDirection = Axis.horizontal; await tester.pumpWidget(
dismissDirection = DismissDirection.down; buildTest(
scrollDirection: Axis.horizontal,
await tester.pumpWidget(buildTest()); dismissDirection: DismissDirection.down,
),
);
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, mechanism: flingElement, gestureDirection: AxisDirection.up); await dismissItem(tester, 0, mechanism: flingElement, gestureDirection: AxisDirection.up);
...@@ -518,10 +550,13 @@ void main() { ...@@ -518,10 +550,13 @@ void main() {
}); });
testWidgets('drag-left has no effect on dismissible with a high dismiss threshold', (WidgetTester tester) async { testWidgets('drag-left has no effect on dismissible with a high dismiss threshold', (WidgetTester tester) async {
scrollDirection = Axis.vertical; await tester.pumpWidget(
dismissDirection = DismissDirection.horizontal; buildTest(
startToEndThreshold: 1.0,
await tester.pumpWidget(buildTest(startToEndThreshold: 1.0)); scrollDirection: Axis.vertical,
dismissDirection: DismissDirection.horizontal,
),
);
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, gestureDirection: AxisDirection.right); await dismissItem(tester, 0, gestureDirection: AxisDirection.right);
...@@ -534,10 +569,13 @@ void main() { ...@@ -534,10 +569,13 @@ void main() {
}); });
testWidgets('fling-left has no effect on dismissible with a high dismiss threshold', (WidgetTester tester) async { testWidgets('fling-left has no effect on dismissible with a high dismiss threshold', (WidgetTester tester) async {
scrollDirection = Axis.vertical; await tester.pumpWidget(
dismissDirection = DismissDirection.horizontal; buildTest(
startToEndThreshold: 1.0,
await tester.pumpWidget(buildTest(startToEndThreshold: 1.0)); scrollDirection: Axis.vertical,
dismissDirection: DismissDirection.horizontal,
),
);
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, mechanism: flingElement, gestureDirection: AxisDirection.right); await dismissItem(tester, 0, mechanism: flingElement, gestureDirection: AxisDirection.right);
...@@ -556,10 +594,12 @@ void main() { ...@@ -556,10 +594,12 @@ void main() {
// https://github.com/flutter/engine/pull/1134 at the time, and later made // https://github.com/flutter/engine/pull/1134 at the time, and later made
// irrelevant by fn3, but just in case... // irrelevant by fn3, but just in case...
testWidgets('Verify that drag-move events do not assert', (WidgetTester tester) async { testWidgets('Verify that drag-move events do not assert', (WidgetTester tester) async {
scrollDirection = Axis.horizontal; await tester.pumpWidget(
dismissDirection = DismissDirection.down; buildTest(
scrollDirection: Axis.horizontal,
await tester.pumpWidget(buildTest()); dismissDirection: DismissDirection.down,
),
);
final Offset location = tester.getTopLeft(find.text('0')); final Offset location = tester.getTopLeft(find.text('0'));
const Offset offset = Offset(0.0, 5.0); const Offset offset = Offset(0.0, 5.0);
final TestGesture gesture = await tester.startGesture(location, pointer: 5); final TestGesture gesture = await tester.startGesture(location, pointer: 5);
...@@ -613,11 +653,13 @@ void main() { ...@@ -613,11 +653,13 @@ void main() {
}); });
testWidgets('Dismissible starts from the full size when collapsing', (WidgetTester tester) async { testWidgets('Dismissible starts from the full size when collapsing', (WidgetTester tester) async {
scrollDirection = Axis.vertical; await tester.pumpWidget(
dismissDirection = DismissDirection.horizontal; buildTest(
background = const Text('background'); background: const Text('background'),
scrollDirection: Axis.vertical,
await tester.pumpWidget(buildTest()); dismissDirection: DismissDirection.horizontal,
),
);
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
final Finder itemFinder = find.text('0'); final Finder itemFinder = find.text('0');
...@@ -653,8 +695,7 @@ void main() { ...@@ -653,8 +695,7 @@ void main() {
}); });
testWidgets('Horizontal fling less than threshold', (WidgetTester tester) async { testWidgets('Horizontal fling less than threshold', (WidgetTester tester) async {
scrollDirection = Axis.horizontal; await tester.pumpWidget(buildTest(scrollDirection: Axis.horizontal));
await tester.pumpWidget(buildTest());
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await checkFlingItemAfterMovement(tester, 0, gestureDirection: AxisDirection.left, mechanism: rollbackElement); await checkFlingItemAfterMovement(tester, 0, gestureDirection: AxisDirection.left, mechanism: rollbackElement);
...@@ -667,8 +708,7 @@ void main() { ...@@ -667,8 +708,7 @@ void main() {
}); });
testWidgets('Vertical fling less than threshold', (WidgetTester tester) async { testWidgets('Vertical fling less than threshold', (WidgetTester tester) async {
scrollDirection = Axis.vertical; await tester.pumpWidget(buildTest(scrollDirection: Axis.vertical));
await tester.pumpWidget(buildTest());
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await checkFlingItemAfterMovement(tester, 0, gestureDirection: AxisDirection.left, mechanism: rollbackElement); await checkFlingItemAfterMovement(tester, 0, gestureDirection: AxisDirection.left, mechanism: rollbackElement);
...@@ -681,13 +721,13 @@ void main() { ...@@ -681,13 +721,13 @@ void main() {
}); });
testWidgets('confirmDismiss returns values: true, false, null', (WidgetTester tester) async { testWidgets('confirmDismiss returns values: true, false, null', (WidgetTester tester) async {
scrollDirection = Axis.vertical;
dismissDirection = DismissDirection.horizontal;
late DismissDirection confirmDismissDirection; late DismissDirection confirmDismissDirection;
Widget buildFrame(bool? confirmDismissValue) { Widget buildFrame(bool? confirmDismissValue) {
return buildTest( return buildTest(
confirmDismiss: (BuildContext context, DismissDirection dismissDirection) { scrollDirection: Axis.vertical,
dismissDirection: DismissDirection.horizontal,
confirmDismiss: (BuildContext context, DismissDirection dismissDirection) {
confirmDismissDirection = dismissDirection; confirmDismissDirection = dismissDirection;
return Future<bool?>.value(confirmDismissValue); return Future<bool?>.value(confirmDismissValue);
}, },
...@@ -740,8 +780,8 @@ void main() { ...@@ -740,8 +780,8 @@ void main() {
}); });
testWidgets('setState that does not remove the Dismissible from tree should throws Error', (WidgetTester tester) async { testWidgets('setState that does not remove the Dismissible from tree should throws Error', (WidgetTester tester) async {
scrollDirection = Axis.vertical; const Axis scrollDirection = Axis.vertical;
dismissDirection = DismissDirection.horizontal; const DismissDirection dismissDirection = DismissDirection.horizontal;
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -750,7 +790,7 @@ void main() { ...@@ -750,7 +790,7 @@ void main() {
return ListView( return ListView(
dragStartBehavior: DragStartBehavior.down, dragStartBehavior: DragStartBehavior.down,
scrollDirection: scrollDirection, scrollDirection: scrollDirection,
itemExtent: itemExtent, itemExtent: 100.0,
children: <Widget>[ children: <Widget>[
Dismissible( Dismissible(
dragStartBehavior: DragStartBehavior.down, dragStartBehavior: DragStartBehavior.down,
...@@ -763,12 +803,11 @@ void main() { ...@@ -763,12 +803,11 @@ void main() {
dismissedItems.add(1); dismissedItems.add(1);
}); });
}, },
background: background,
dismissThresholds: const <DismissDirection, double>{}, dismissThresholds: const <DismissDirection, double>{},
crossAxisEndOffset: crossAxisEndOffset, crossAxisEndOffset: crossAxisEndOffset,
child: SizedBox( child: SizedBox(
width: itemExtent, width: 100.0,
height: itemExtent, height: 100.0,
child: Text(1.toString()), child: Text(1.toString()),
), ),
), ),
...@@ -873,9 +912,7 @@ void main() { ...@@ -873,9 +912,7 @@ void main() {
}); });
testWidgets('DismissDirection.none does not trigger dismiss', (WidgetTester tester) async { testWidgets('DismissDirection.none does not trigger dismiss', (WidgetTester tester) async {
dismissDirection = DismissDirection.none; await tester.pumpWidget(buildTest(dismissDirection: DismissDirection.none));
await tester.pumpWidget(buildTest());
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
await dismissItem(tester, 0, gestureDirection: AxisDirection.left); await dismissItem(tester, 0, gestureDirection: AxisDirection.left);
...@@ -886,10 +923,14 @@ void main() { ...@@ -886,10 +923,14 @@ void main() {
}); });
testWidgets('DismissDirection.none does not prevent scrolling', (WidgetTester tester) async { testWidgets('DismissDirection.none does not prevent scrolling', (WidgetTester tester) async {
dismissDirection = DismissDirection.none;
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
await tester.pumpWidget(buildTest(controller: controller)); await tester.pumpWidget(
buildTest(
controller: controller,
dismissDirection: DismissDirection.none,
),
);
expect(dismissedItems, isEmpty); expect(dismissedItems, isEmpty);
expect(controller.offset, 0.0); expect(controller.offset, 0.0);
...@@ -901,5 +942,6 @@ void main() { ...@@ -901,5 +942,6 @@ void main() {
expect(controller.offset, 0.0); expect(controller.offset, 0.0);
await dismissItem(tester, 0, gestureDirection: AxisDirection.up); await dismissItem(tester, 0, gestureDirection: AxisDirection.up);
expect(controller.offset, 99.9); expect(controller.offset, 99.9);
controller.dispose();
}); });
} }
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