Skip to content

Commit

Permalink
add: swipe gesture test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurogoma4D committed Jun 17, 2021
1 parent fb0dc6c commit d3281de
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions test/in_app_notification_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void main() {
child: Center(child: Text('foo')),
context: context,
onTap: () {},
duration: Duration(seconds: 2),
duration: Duration.zero,
notificationCreatedCallback: () async => await tester.pumpAndSettle(),
);
expect(find.text('foo'), findsOneWidget);
Expand All @@ -72,11 +72,10 @@ void main() {
child: Center(child: Text('foo')),
context: context,
onTap: () => tapped = true,
duration: Duration(seconds: 2),
duration: Duration.zero,
notificationCreatedCallback: () async => await tester.pumpAndSettle(),
);

await tester.pumpAndSettle();
await tester.tap(find.text('foo'));

await tester.pumpAndSettle();
Expand All @@ -86,4 +85,38 @@ void main() {
});
},
);

testWidgets(
'InAppNotification should dismiss on swipe up notification.',
(tester) async {
await tester.runAsync(() async {
final key = GlobalKey();
await tester.pumpWidget(base(key));

final context = key.currentContext!;

await InAppNotification.show(
child: Container(
height: 300,
color: Colors.green,
child: Text('test'),
),
context: context,
onTap: () {},
duration: Duration.zero,
notificationCreatedCallback: () async => await tester.pumpAndSettle(),
);

expect(find.text('test'), findsOneWidget);

await tester.dragFrom(Offset(400, 250), Offset(400, 200));
await tester.pumpAndSettle();
expect(find.text('test'), findsOneWidget);

await tester.fling(find.text('test'), Offset(0, -1), 1.0);
await tester.pumpAndSettle();
expect(find.text('test'), findsNothing);
});
},
);
}

0 comments on commit d3281de

Please sign in to comment.