Skip to content

Commit

Permalink
added test and fixed a typo
Browse files Browse the repository at this point in the history
  • Loading branch information
shibakar committed Feb 12, 2022
1 parent 3c7d484 commit daa362f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package/lib/src/beam_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
60 changes: 51 additions & 9 deletions package/test/beam_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
),
Expand Down Expand Up @@ -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);
});

Expand Down

0 comments on commit daa362f

Please sign in to comment.