Commit a08e481b authored by Vadaski's avatar Vadaski

add container_manager test

- test `of` method, try to get the ContainerManagerState in the ancestor node
- test `tryOf` method, try to get the ContainerManagerState in the ancestor node
parent fc3307b7
...@@ -94,9 +94,6 @@ class _MyAppState extends State<MyApp> { ...@@ -94,9 +94,6 @@ class _MyAppState extends State<MyApp> {
}, },
home: Container()); home: Container());
} }
void _onRoutePushed(
String pageName, String uniqueId, Map params, Route route, Future _) {}
} }
void main() { void main() {
...@@ -108,4 +105,75 @@ void main() { ...@@ -108,4 +105,75 @@ void main() {
expect(find.text('First'), findsNothing); expect(find.text('First'), findsNothing);
}); });
group(
'Try to get the ContainerManagerState in the ancestor node',
() {
testWidgets(
'through the `BoostContainerManager.of(context)` method',
(WidgetTester tester) async {
var findBoostContainerManagerByOfMethod;
await tester.pumpWidget(
MaterialApp(
builder: (BuildContext context, Widget child) {
final BoostContainerManager manager = BoostContainerManager(
initNavigator: child,
);
return manager;
},
home: Builder(
builder: (BuildContext context) {
return FloatingActionButton(onPressed: () {
findBoostContainerManagerByOfMethod = context;
});
},
),
),
);
await tester.tap(find.byType(FloatingActionButton));
expect(
BoostContainerManager.of(findBoostContainerManagerByOfMethod),
const TypeMatcher<ContainerManagerState>(),
);
},
);
testWidgets(
'through the `BoostContainerManager.tryOf(context)` method',
(WidgetTester tester) async {
var findBoostContainerManagerByOfMethod;
await tester.pumpWidget(
MaterialApp(
builder: (BuildContext context, Widget child) {
final BoostContainerManager manager = BoostContainerManager(
initNavigator: child,
);
return manager;
},
home: Builder(
builder: (BuildContext context) {
return FloatingActionButton(onPressed: () {
findBoostContainerManagerByOfMethod = context;
});
},
),
),
);
await tester.tap(find.byType(FloatingActionButton));
expect(
BoostContainerManager.tryOf(findBoostContainerManagerByOfMethod),
const TypeMatcher<ContainerManagerState>(),
);
},
);
},
);
} }
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