Fix home heading clipping and reset notebook page scrolling

This commit is contained in:
Hadrian Burkhardt
2026-11-03 05:05:39 +01:00
parent c6168f46ac
commit 5b9a76fb53
4 changed files with 200 additions and 84 deletions
+91
View File
@@ -28,6 +28,97 @@ class _RewardAds extends Ads {
}
void main() {
testWidgets('home lettering stays fully above the scrolling content', (
tester,
) async {
addTearDown(tester.view.reset);
await tester.runAsync(() async {
final font = FontLoader('MaraHand')
..addFont(rootBundle.load('assets/fonts/DancingScript.ttf'));
await font.load();
});
final book = (await tester.runAsync(Book.load))!;
for (final size in [const Size(360, 640), const Size(960, 600)]) {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
await tester.pumpWidget(
LumenApp(game: Game(book, Progress.memory()), adsEnabled: false),
);
await tester.pumpAndSettle();
final heading = find.text('L U M E N / AN ISLAND STORY');
final scroll = find.byKey(const ValueKey('home-scroll'));
final headingRect = tester.getRect(heading);
expect(headingRect.bottom, lessThan(tester.getRect(scroll).top));
for (final dy in [-40.0, -300.0, 500.0]) {
await tester.drag(scroll, Offset(0, dy));
await tester.pumpAndSettle();
expect(tester.getRect(heading), headingRect);
expect(heading.hitTestable(), findsOneWidget);
expect(tester.takeException(), isNull);
}
await tester.pumpWidget(const SizedBox());
}
});
testWidgets(
'opening and revisiting leaves starts at the top in both layouts',
(tester) async {
addTearDown(tester.view.reset);
final book = (await tester.runAsync(Book.load))!;
for (final size in [const Size(360, 640), const Size(960, 600)]) {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
final wide = size.width > size.height;
final g = Game(book, Progress.memory({'story_access_level': 11}));
final first = wide ? 2 : 1;
final second = wide ? 7 : 3;
g.showStory(first);
await tester.pumpWidget(
MaterialApp(
home: MediaQuery(
data: MediaQueryData(
size: size,
textScaler: const TextScaler.linear(1.5),
),
child: Notebook(game: g, adsEnabled: false),
),
),
);
await tester.pumpAndSettle();
final pane = find.byKey(
ValueKey(wide ? 'leaf-side-scroll' : 'leaf-scroll'),
);
ScrollPosition position() => tester
.state<ScrollableState>(
find
.descendant(of: pane, matching: find.byType(Scrollable))
.first,
)
.position;
expect(position().pixels, 0);
await tester.drag(pane, const Offset(0, -220));
await tester.pumpAndSettle();
expect(position().pixels, greaterThan(0));
// Updates within a page should still preserve its reading position.
final offset = position().pixels;
g.showStory(first);
await tester.pumpAndSettle();
expect(position().pixels, offset);
g.showStory(second);
await tester.pumpAndSettle();
expect(position().pixels, 0);
await tester.drag(pane, const Offset(0, -180));
await tester.pumpAndSettle();
expect(position().pixels, greaterThan(0));
g.showStory(first);
await tester.pumpAndSettle();
expect(position().pixels, 0);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox());
}
},
);
testWidgets('atmosphere controls fit large text and remember mute', (
tester,
) async {