Commit d6056e50 authored by justin's avatar justin

test fix

parent c1e77230
...@@ -137,7 +137,7 @@ void main() { ...@@ -137,7 +137,7 @@ void main() {
expect(find.text('Y', skipOffstage: false), findsNothing); expect(find.text('Y', skipOffstage: false), findsNothing);
}); });
// //
testWidgets('Navigator.of fails gracefully when not found in context', testWidgets('Navigator.of gracefully when not found in context',
(WidgetTester tester) async { (WidgetTester tester) async {
const Key targetKey = Key('foo'); const Key targetKey = Key('foo');
dynamic exception; dynamic exception;
...@@ -148,7 +148,13 @@ void main() { ...@@ -148,7 +148,13 @@ void main() {
}, },
); );
await tester.pumpWidget(widget); await tester.pumpWidget(widget);
await tester.pump(Duration(seconds: 1));
await tester.tap(find.byKey(targetKey)); await tester.tap(find.byKey(targetKey));
await tester.pump(Duration(seconds: 1));
expect(exception, isInstanceOf<FlutterError>()); expect(exception, isInstanceOf<FlutterError>());
expect('$exception', expect('$exception',
startsWith('Navigator operation requested with a context')); startsWith('Navigator operation requested with a context'));
......
...@@ -47,7 +47,7 @@ void main() { ...@@ -47,7 +47,7 @@ void main() {
group('Try to get the BoostPageRoute in the ancestor node', () { group('Try to get the BoostPageRoute in the ancestor node', () {
testWidgets( testWidgets(
'obtain BoostPageRoute through the `BoostPageRoute.of(context)` method', 'obtain BoostPageRoute through the BoostPageRoute.of(context) method',
(WidgetTester tester) async { (WidgetTester tester) async {
dynamic boostPageRoute; dynamic boostPageRoute;
dynamic boostPageRouteFindByOfMethod; dynamic boostPageRouteFindByOfMethod;
...@@ -74,13 +74,15 @@ void main() { ...@@ -74,13 +74,15 @@ void main() {
await tester.tap(find.byType(FloatingActionButton)); await tester.tap(find.byType(FloatingActionButton));
await tester.pump(Duration(seconds: 1));
// The route obtained from the ancestor node through the `of` method should be the same BoostPageRoute // The route obtained from the ancestor node through the `of` method should be the same BoostPageRoute
// as the originally created BoostPageRoute // as the originally created BoostPageRoute
expect(boostPageRoute, boostPageRouteFindByOfMethod); expect(boostPageRoute, boostPageRouteFindByOfMethod);
}); });
testWidgets( testWidgets(
'try to find BoostPageRoute through the `BoostPageRoute.of(context)` method, ' 'try to find BoostPageRoute through the BoostPageRoute.of(context) method, '
'but it doesn\'t exist, the method should throw an Exception', 'but it doesn\'t exist, the method should throw an Exception',
(WidgetTester tester) async { (WidgetTester tester) async {
dynamic contextCache; dynamic contextCache;
...@@ -102,12 +104,13 @@ void main() { ...@@ -102,12 +104,13 @@ void main() {
), ),
); );
await tester.tap(find.byType(FloatingActionButton)); await tester.tap(find.byType(FloatingActionButton));
await tester.pump(Duration(seconds: 1));
expect(() => BoostPageRoute.of<dynamic>(contextCache), throwsException); expect(() => BoostPageRoute.of<dynamic>(contextCache), throwsException);
}); });
testWidgets( testWidgets(
'obtain BoostPageRoute through the `BoostPageRoute.tryOf(context)` method', 'obtain BoostPageRoute through the BoostPageRoute.tryOf(context) method',
(WidgetTester tester) async { (WidgetTester tester) async {
dynamic boostPageRoute; dynamic boostPageRoute;
dynamic boostPageRouteFindByOfMethod; dynamic boostPageRouteFindByOfMethod;
...@@ -134,6 +137,7 @@ void main() { ...@@ -134,6 +137,7 @@ void main() {
); );
await tester.tap(find.byType(FloatingActionButton)); await tester.tap(find.byType(FloatingActionButton));
await tester.pump(Duration(seconds: 1));
// The route obtained from the ancestor node through the `tryOf` method should be the same BoostPageRoute // The route obtained from the ancestor node through the `tryOf` method should be the same BoostPageRoute
// as the originally created BoostPageRoute // as the originally created BoostPageRoute
...@@ -142,7 +146,7 @@ void main() { ...@@ -142,7 +146,7 @@ void main() {
}); });
testWidgets( testWidgets(
'try to find BoostPageRoute through the `BoostPageRoute.tryOf(context)` method, ' 'try to find BoostPageRoute through the BoostPageRoute.tryOf(context) method, '
'but it doesn\'t exist, the method should return null', 'but it doesn\'t exist, the method should return null',
(WidgetTester tester) async { (WidgetTester tester) async {
dynamic boostPageRouteFindByOfMethod; dynamic boostPageRouteFindByOfMethod;
...@@ -168,6 +172,7 @@ void main() { ...@@ -168,6 +172,7 @@ void main() {
); );
await tester.tap(find.byType(FloatingActionButton)); await tester.tap(find.byType(FloatingActionButton));
await tester.pump(Duration(seconds: 1));
expect(boostPageRouteFindByOfMethod, null); expect(boostPageRouteFindByOfMethod, null);
}); });
......
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