Prepare Android release and refine bookshelf

This commit is contained in:
Hadrian Burkhardt
2026-11-15 16:20:17 +01:00
parent fc71accb38
commit 062c798fcc
15 changed files with 530 additions and 193 deletions
+93 -42
View File
@@ -13,6 +13,7 @@ import 'package:lumen/main.dart';
import 'package:lumen/services/ads.dart';
import 'package:lumen/services/progress.dart';
import 'package:lumen/ui/postcards.dart';
import 'package:lumen/ui/licenses.dart';
import 'postcards_test.dart' show solve;
@@ -268,48 +269,98 @@ void main() {
},
);
testWidgets(
'shelf daily play preserves the book leaf and returns to the shelf',
(tester) async {
tester.view.physicalSize = const Size(600, 960);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final library = (await tester.runAsync(StoryLibrary.load))!;
await tester.runAsync(() async {
for (final story in library.stories) {
await library.open(story.id);
}
});
final book = (await tester.runAsync(() => library.open('mara-island')))!;
final store = Progress.memory({'language': 'en'});
final g = Game(book, store, library: library)
..showStory(2)
..showLibrary();
await tester.pumpWidget(
RepaintBoundary(
key: const ValueKey('capture'),
child: LumenApp(game: g, adsEnabled: false),
testWidgets('shelf activity buttons remain large on a small screen', (
tester,
) async {
tester.view.physicalSize = const Size(320, 700);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final book = (await tester.runAsync(Book.load))!;
final game = Game(book, Progress.memory());
await tester.pumpWidget(
MaterialApp(
home: MediaQuery(
data: const MediaQueryData(
size: Size(320, 700),
textScaler: TextScaler.linear(1.5),
),
child: Scaffold(
body: SingleChildScrollView(
child: ShelfActivities(game: game, onPostcards: () {}),
),
),
),
);
// Cached asset futures were loaded in the real event loop above.
for (var i = 0; i < 3; i++) {
await tester.runAsync(
() => Future<void>.delayed(const Duration(milliseconds: 20)),
);
await tester.pump();
),
);
await tester.pumpAndSettle();
for (final key in ['shelf-daily', 'shelf-postcards']) {
final size = tester.getSize(find.byKey(ValueKey(key)));
expect(size.width, greaterThan(250));
expect(size.height, greaterThanOrEqualTo(64));
}
expect(tester.takeException(), isNull);
});
testWidgets('daily play and postcards are on the shelf, not the book page', (
tester,
) async {
tester.view.physicalSize = const Size(600, 960);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final library = (await tester.runAsync(StoryLibrary.load))!;
await tester.runAsync(() async {
for (final story in library.stories) {
await library.open(story.id);
}
await tester.pumpAndSettle();
await capture(tester, 'shelf');
await tester.tap(find.byKey(const ValueKey('shelf-daily')));
await tester.pumpAndSettle();
expect(g.mode, Mode.daily);
expect(store.text('flutter_screen'), 'story');
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
expect(g.screen, Screen.library);
expect(store.text('notebook_last_page'), book.pages[2].id);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox());
},
);
});
final book = (await tester.runAsync(() => library.open('mara-island')))!;
final store = Progress.memory({'language': 'en'});
final g = Game(book, store, library: library)
..showStory(2)
..showLibrary();
await tester.pumpWidget(
RepaintBoundary(
key: const ValueKey('capture'),
child: LumenApp(game: g, adsEnabled: false),
),
);
// Cached asset futures were loaded in the real event loop above.
for (var i = 0; i < 3; i++) {
await tester.runAsync(
() => Future<void>.delayed(const Duration(milliseconds: 20)),
);
await tester.pump();
}
await tester.pumpAndSettle();
await capture(tester, 'shelf');
expect(find.text('Open-source licenses'), findsNothing);
await tester.tap(find.text('Settings'));
await tester.pumpAndSettle();
await tester.tap(find.text('Open-source licenses'));
await tester.pumpAndSettle();
expect(find.byType(OpenSourceLicenses), findsOneWidget);
await tester.pageBack();
await tester.pumpAndSettle();
expect(find.byKey(const ValueKey('shelf-activities')), findsOneWidget);
expect(find.byKey(const ValueKey('shelf-daily')), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('shelf-postcards')));
await tester.pumpAndSettle();
expect(g.screen, Screen.postcards);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('shelf-daily')));
await tester.pumpAndSettle();
expect(g.mode, Mode.daily);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
expect(g.screen, Screen.library);
g.home();
await tester.pumpAndSettle();
expect(find.text('Play today’s puzzle →'), findsNothing);
expect(find.text('Island postcards'), findsNothing);
expect(find.textContaining('Practice ·'), findsNothing);
expect(find.textContaining('Difficulty ·'), findsNothing);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox());
});
}