From daa362f123d0c4f2962acfa687aa5471f50b6b82 Mon Sep 17 00:00:00 2001 From: Shiba-Kar Date: Sun, 13 Feb 2022 01:24:38 +0530 Subject: [PATCH] added test and fixed a typo --- package/lib/src/beam_page.dart | 2 +- package/test/beam_page_test.dart | 60 +++++++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/package/lib/src/beam_page.dart b/package/lib/src/beam_page.dart index ad0fd8e9..b0845f98 100644 --- a/package/lib/src/beam_page.dart +++ b/package/lib/src/beam_page.dart @@ -25,7 +25,7 @@ enum BeamPageType { /// An enum for a page type with slide left transition. slideLeftTransition, - /// An enum for a page type with slide left transition. + /// An enum for a page type with slide top transition. slideTopTransition, /// An enum for a page type with scale transition. diff --git a/package/test/beam_page_test.dart b/package/test/beam_page_test.dart index 7f7ca950..fa9d9793 100644 --- a/package/test/beam_page_test.dart +++ b/package/test/beam_page_test.dart @@ -506,20 +506,35 @@ void main() { ), '/1/2/3/4': (context, state, data) => const BeamPage( key: ValueKey('/1/2/3/4'), - type: BeamPageType.scaleTransition, + type: BeamPageType.slideRightTransition, child: Scaffold(body: Text('4')), ), '/1/2/3/4/5': (context, state, data) => const BeamPage( key: ValueKey('/1/2/3/4/5'), - type: BeamPageType.noTransition, + type: BeamPageType.slideLeftTransition, child: Scaffold(body: Text('5')), ), - '/1/2/3/4/5/6': (context, state, data) => BeamPage( - key: const ValueKey('/1/2/3/4/5/6'), + '/1/2/3/4/5/6': (context, state, data) => const BeamPage( + key: ValueKey('/1/2/3/4/5/6'), + type: BeamPageType.slideTopTransition, + child: Scaffold(body: Text('6')), + ), + '/1/2/3/4/5/6/7': (context, state, data) => const BeamPage( + key: ValueKey('/1/2/3/4/5/6/7'), + type: BeamPageType.scaleTransition, + child: Scaffold(body: Text('7')), + ), + '/1/2/3/4/5/6/7/8': (context, state, data) => const BeamPage( + key: ValueKey('/1/2/3/4/5/6/7/8'), + type: BeamPageType.noTransition, + child: Scaffold(body: Text('8')), + ), + '/1/2/3/4/5/6/7/8/9': (context, state, data) => BeamPage( + key: const ValueKey('/1/2/3/4/5/6/7/8/9'), routeBuilder: (context, settings, child) => PageRouteBuilder( settings: settings, pageBuilder: (context, animation, secondaryAnimation) => - Scaffold(body: Row(children: [const Text('6'), child])), + Scaffold(body: Row(children: [const Text('9'), child])), ), child: const Text('Child'), ), @@ -564,18 +579,45 @@ void main() { offset = tester.getTopLeft(find.text('4')); expect(offset.dx, greaterThan(0.0)); expect(offset.dx, lessThan(800.0)); + expect(offset.dy, equals(0.0)); + expect(offset.dy, equals(0.0)); + + delegate.beamToNamed('/1/2/3/4/5'); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 8)); + offset = tester.getTopLeft(find.text('5')); + expect(offset.dx, greaterThan(-800.0)); + expect(offset.dx, lessThan(0.0)); + expect(offset.dy, equals(0.0)); + expect(offset.dy, equals(0.0)); + + delegate.beamToNamed('/1/2/3/4/5/6'); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 8)); + offset = tester.getTopLeft(find.text('6')); + expect(offset.dx, equals(0.0)); + expect(offset.dx, equals(0.0)); + expect(offset.dy, greaterThan(-600.0)); + expect(offset.dy, lessThan(0.0)); + + delegate.beamToNamed('/1/2/3/4/5/6/7'); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 8)); + offset = tester.getTopLeft(find.text('7')); + expect(offset.dx, greaterThan(0.0)); + expect(offset.dx, lessThan(800.0)); expect(offset.dy, greaterThan(0.0)); expect(offset.dy, lessThan(600.0)); - delegate.beamToNamed('/1/2/3/4/5'); + delegate.beamToNamed('/1/2/3/4/5/6/7/8'); await tester.pump(); await tester.pump(); - expect(find.text('5'), findsOneWidget); + expect(find.text('8'), findsOneWidget); - delegate.beamToNamed('/1/2/3/4/5/6'); + delegate.beamToNamed('/1/2/3/4/5/6/7/8/9'); await tester.pump(); await tester.pump(); - expect(find.text('6'), findsOneWidget); + expect(find.text('9'), findsOneWidget); expect(find.text('Child'), findsOneWidget); });