Skip to content

Commit 9284a6e

Browse files
committed
nav test: Make TestNavigatorObserver extend TransitionDurationObserver
This way, we can use the instance of TestNavigatorObserver to wait for the route transition to complete, instead of creating a different object of TransitionDurationObserver for the same purpose.
1 parent dd44f46 commit 9284a6e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/test_navigation.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import 'package:flutter/widgets.dart';
2+
import 'package:flutter_test/flutter_test.dart';
23

34
// Inspired by test code in the Flutter tree:
45
// https://github.com/flutter/flutter/blob/53082f65b/packages/flutter/test/widgets/observer_tester.dart
56
// https://github.com/flutter/flutter/blob/53082f65b/packages/flutter/test/widgets/navigator_test.dart
67

78
/// A trivial observer for testing the navigator.
8-
class TestNavigatorObserver extends NavigatorObserver {
9+
class TestNavigatorObserver extends TransitionDurationObserver{
910
void Function(Route<dynamic> topRoute, Route<dynamic>? previousTopRoute)? onChangedTop;
1011
void Function(Route<dynamic> route, Route<dynamic>? previousRoute)? onPushed;
1112
void Function(Route<dynamic> route, Route<dynamic>? previousRoute)? onPopped;
@@ -21,11 +22,13 @@ class TestNavigatorObserver extends NavigatorObserver {
2122

2223
@override
2324
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
25+
super.didPush(route, previousRoute);
2426
onPushed?.call(route, previousRoute);
2527
}
2628

2729
@override
2830
void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
31+
super.didPop(route, previousRoute);
2932
onPopped?.call(route, previousRoute);
3033
}
3134

@@ -36,6 +39,7 @@ class TestNavigatorObserver extends NavigatorObserver {
3639

3740
@override
3841
void didReplace({ Route<dynamic>? oldRoute, Route<dynamic>? newRoute }) {
42+
super.didReplace();
3943
onReplaced?.call(newRoute, oldRoute);
4044
}
4145

0 commit comments

Comments
 (0)