Finished updating the tour
This commit is contained in:
parent
606106e5ec
commit
2fcc6dcab7
7 changed files with 288 additions and 83 deletions
|
|
@ -14,7 +14,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(wrap(
|
||||
OnboardingTourOverlay(
|
||||
targetKey: targetKey,
|
||||
targetKeys: [targetKey],
|
||||
title: 'Example Title',
|
||||
description: 'Example description text.',
|
||||
stepNumber: 2,
|
||||
|
|
@ -34,7 +34,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(wrap(
|
||||
OnboardingTourOverlay(
|
||||
targetKey: targetKey,
|
||||
targetKeys: [targetKey],
|
||||
title: 'T',
|
||||
description: 'D',
|
||||
stepNumber: 1,
|
||||
|
|
@ -48,7 +48,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(wrap(
|
||||
OnboardingTourOverlay(
|
||||
targetKey: targetKey,
|
||||
targetKeys: [targetKey],
|
||||
title: 'T',
|
||||
description: 'D',
|
||||
stepNumber: 3,
|
||||
|
|
@ -68,7 +68,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(wrap(
|
||||
OnboardingTourOverlay(
|
||||
targetKey: targetKey,
|
||||
targetKeys: [targetKey],
|
||||
title: 'T',
|
||||
description: 'D',
|
||||
stepNumber: 1,
|
||||
|
|
@ -92,7 +92,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(wrap(
|
||||
OnboardingTourOverlay(
|
||||
targetKey: targetKey,
|
||||
targetKeys: [targetKey],
|
||||
title: 'T',
|
||||
description: 'D',
|
||||
stepNumber: 1,
|
||||
|
|
@ -112,7 +112,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(wrap(
|
||||
OnboardingTourOverlay(
|
||||
targetKey: targetKey,
|
||||
targetKeys: [targetKey],
|
||||
title: 'T',
|
||||
description: 'D',
|
||||
stepNumber: 1,
|
||||
|
|
@ -129,4 +129,75 @@ void main() {
|
|||
expect(nextTapped, isFalse);
|
||||
expect(skipTapped, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('highlights every key in targetKeys, not just the first', (tester) async {
|
||||
final topKey = GlobalKey();
|
||||
final bottomKey = GlobalKey();
|
||||
|
||||
Widget buildTree({required bool showOverlay}) => MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
Positioned(top: 0, left: 0, child: SizedBox(key: topKey, width: 40, height: 40)),
|
||||
Positioned(
|
||||
bottom: 0, left: 0, child: SizedBox(key: bottomKey, width: 40, height: 40)),
|
||||
if (showOverlay)
|
||||
OnboardingTourOverlay(
|
||||
targetKeys: [topKey, bottomKey],
|
||||
title: 'Both Highlighted',
|
||||
description: 'D',
|
||||
stepNumber: 1,
|
||||
totalSteps: 1,
|
||||
onNext: () {},
|
||||
onSkip: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Two frames, matching how MainShell actually uses this: the target
|
||||
// keys' RenderBoxes need to already exist and be laid out (from a
|
||||
// prior frame) before the overlay's own build() can find their real
|
||||
// position — querying them in the very same frame they're first
|
||||
// mounted finds nothing yet (layout hasn't run for that frame at
|
||||
// build time).
|
||||
await tester.pumpWidget(buildTree(showOverlay: false));
|
||||
await tester.pumpWidget(buildTree(showOverlay: true));
|
||||
|
||||
// One highlight border per resolved key.
|
||||
expect(find.byType(DecoratedBox), findsNWidgets(2));
|
||||
expect(find.text('Both Highlighted'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('still renders correctly when only some of targetKeys resolve', (tester) async {
|
||||
final resolvedKey = GlobalKey();
|
||||
final unresolvedKey = GlobalKey(); // never attached to anything
|
||||
|
||||
Widget buildTree({required bool showOverlay}) => MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
SizedBox(key: resolvedKey, width: 40, height: 40),
|
||||
if (showOverlay)
|
||||
OnboardingTourOverlay(
|
||||
targetKeys: [resolvedKey, unresolvedKey],
|
||||
title: 'T',
|
||||
description: 'D',
|
||||
stepNumber: 1,
|
||||
totalSteps: 1,
|
||||
onNext: () {},
|
||||
onSkip: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(buildTree(showOverlay: false));
|
||||
await tester.pumpWidget(buildTree(showOverlay: true));
|
||||
|
||||
expect(find.byType(DecoratedBox), findsNWidgets(1), reason: 'only the resolved key gets a border');
|
||||
expect(find.text('T'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue