Commit c23a8f3f authored by Vadaski's avatar Vadaski

add container manager test

- add ContainerManagerState test group
- containerCounts should change based on the number of pages
parent 54d0c22e
......@@ -153,6 +153,34 @@ void main() {
},
);
// testWidgets(
// 'through the `BoostContainerManager.of(context)` method',
// (WidgetTester tester) async {
// var builderContext;
//
// await tester.pumpWidget(
// MaterialApp(
// home: Builder(
// builder: (context) {
// return FloatingActionButton(
// onPressed: () {
// builderContext = context;
// },
// );
// },
// ),
// ),
// );
//
// expect(find.byType(FloatingActionButton), findsOneWidget);
//
// //get the context of the Builder
// await tester.tap(find.byType(FloatingActionButton));
//
// expect(BoostContainerManager.of(builderContext), isAssertionError);
// },
// );
testWidgets(
'through the `BoostContainerManager.tryOf(context)` method',
(WidgetTester tester) async {
......@@ -197,4 +225,71 @@ void main() {
);
},
);
group('ContainerManagerState', () {
testWidgets(
'containerCounts should change based on the number of pages',
(WidgetTester tester) async {
var builderContext;
FlutterBoost.singleton.registerPageBuilders({
'context': (pageName, params, _) => Builder(
builder: (context) {
return FloatingActionButton(
onPressed: () {
builderContext = context;
},
);
},
),
});
await tester.pumpWidget(
MaterialApp(
builder: FlutterBoost.init(),
home: Container(),
),
);
//open first context page
ContainerCoordinator.singleton
.nativeContainerDidShow("context", {}, "1000000");
await tester.pump(Duration(seconds: 1));
//get the context of the Builder
await tester.tap(find.byType(FloatingActionButton));
final containerManagerState = BoostContainerManager.of(builderContext);
expect(containerManagerState.containerCounts, 1,
reason: '1 page shown');
//open second context page
ContainerCoordinator.singleton
.nativeContainerDidShow("context", {}, "2000000");
await tester.pump(Duration(seconds: 1));
expect(containerManagerState.containerCounts, 2,
reason: '2 page shown');
//pop second context page
containerManagerState.pop();
await tester.pump(Duration(seconds: 1));
expect(containerManagerState.containerCounts, 1,
reason: 'second context page closed, Only one page left');
//pop last context page
containerManagerState.pop();
await tester.pump(Duration(seconds: 1));
expect(containerManagerState.containerCounts, 0,
reason: 'last context page closed, no page left');
},
);
});
}
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