Open Lumen on a responsive bookshelf and land pending story work

- Start the app on a shelf of every installed book instead of the last
  book's home. Cards show the cover, translated metadata, available
  languages, restored patterns and either "Continue reading" or a way in.
- Keep each book's saved route: the shelf is never written to
  flutter_screen, so choosing a book resumes its own leaf.
- Lay the shelf out responsively: dense single-column cards on phones,
  a two-column grid from 720 logical pixels, a centred 860 px column on
  tablets and a chevron that exists in the bundled handwriting font.
- Keep Settings reachable from the shelf and let the home page's story
  library button open the shelf instead of a dialog.
- Add tool/shelf_screenshots_test.dart, which renders the shelf at phone
  and tablet metrics, checks that every card and Settings stay reachable
  without overflow, and writes artifacts/library/shelf-*.png.
- Commit the pending Midnight Invitation package (campaign, notebook,
  narration and artwork), cast drama and ambience tooling, region
  selection, phone/tablet integration coverage and related docs.

flutter analyze is clean and all 74 widget/domain tests pass.
This commit is contained in:
Hadrian Burkhardt
2026-11-05 14:29:50 +01:00
parent d45cd0698a
commit 0718e3f252
149 changed files with 16875 additions and 393 deletions
+179
View File
@@ -0,0 +1,179 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:lumen/domain/book.dart';
import 'package:lumen/domain/game.dart';
import 'package:lumen/domain/library.dart';
import 'package:lumen/main.dart';
import 'package:lumen/services/ambience.dart';
import 'package:lumen/services/narrator.dart';
import 'package:lumen/services/progress.dart';
import 'support/story_fixtures.dart';
class _Output implements AmbienceOutput {
Soundscape? scene;
bool playing = false;
double gain = 0;
final List<String> loads = [];
@override
Future<void> load(Soundscape value) async {
scene = value;
loads.add(value.asset);
}
@override
Future<void> volume(double value) async => gain = value;
@override
Future<void> play() async => playing = true;
@override
Future<void> stop() async => playing = false;
@override
Future<void> dispose() async {}
}
class _Voice extends Narrator {
_Voice(super.tracks);
Duration at = Duration.zero;
bool active = false;
@override
Duration get position => at;
@override
bool get playing => active;
void cue(String id, int milliseconds) {
cancelAutoplay();
page = id;
at = Duration(milliseconds: milliseconds);
active = true;
notifyListeners();
}
@override
Future<void> stop() async {
active = false;
await super.stop();
}
}
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
test(
'translated books share nonverbal atmosphere but never English speech',
() async {
final data = fixture();
data['fixture/atmosphere.json'] = {
'scenes': {
'room': {'asset': 'assets/room.wav'},
},
'pages': {'entry-0': 'room'},
};
final story = StoryDefinition({
'id': 'drama',
'title': 'Drama',
'campaignAsset': 'fixture/campaign.json',
'notebookAsset': 'fixture/notebook.json',
'tracksAsset': 'fixture/audio.json',
'atmosphereAsset': 'fixture/atmosphere.json',
'languages': {
'en': {},
'de': {'asset': 'fixture/de.json'},
},
});
final library = StoryLibrary([story], bundle: FixtureBundle(data));
final en = await library.open('drama');
final de = await library.open('drama', language: 'de');
expect(en.atmosphere['entry-0'], de.atmosphere['entry-0']);
expect(en.tracks, isNotEmpty);
expect(de.tracks, isEmpty);
expect(de.atmosphere['entry-1'], isNull);
data['fixture/atmosphere.json'] = {
'scenes': {
'room': {'asset': 'assets/room.wav'},
},
'pages': {'missing-page': 'room'},
};
await expectLater(
Book.loadDefinition(story, bundle: FixtureBundle(data)),
throwsFormatException,
);
},
);
testWidgets(
'cast labels follow cues; atmosphere ducks, changes and stops at home',
(tester) async {
final library = (await tester.runAsync(StoryLibrary.load))!;
final book = (await tester.runAsync(
() => library.open('midnight-invitation'),
))!;
final g = Game(
book,
Progress.memory({'story_access_level': 11}),
library: library,
);
final voice = _Voice(book.tracks);
final output = _Output();
final ambience = Ambience(output: output);
final doorIndex = book.pages.indexWhere(
(p) => p.id == 'midnight.feather.memory',
);
g.showStory(doorIndex);
await tester.pumpWidget(
MaterialApp(
home: Notebook(
game: g,
adsEnabled: false,
narrator: voice,
ambience: ambience,
),
),
);
Future<void> settleAudio() async {
for (var i = 0; i < 14; i++) {
await tester.pump(const Duration(milliseconds: 50));
}
await ambience.settled;
}
await settleAudio();
voice.cancelAutoplay();
expect(output.scene, book.atmosphere['midnight.feather.memory']);
expect(output.gain, closeTo(.28, .001));
for (final role in ['Iris', 'Elias']) {
final cue = (book.tracks['midnight.feather.memory']['cues'] as List)
.firstWhere((c) => c['speaker'] == role);
voice.cue('midnight.feather.memory', cue['startMs'] + 100);
await settleAudio();
expect(find.text('$role · recorded story'), findsOneWidget);
expect(voice.passage, cue['text']);
expect(output.gain, closeTo(.07, .001));
if (role == 'Iris') {
voice.cue('midnight.feather.memory', cue['endMs'] + 100);
await tester.pump();
expect(voice.speaker, 'Iris');
expect(voice.passage, isEmpty);
}
}
// Repeated position updates must not reload the same loop.
expect(output.loads.length, 1);
g.showStory(
book.pages.indexWhere((p) => p.id == 'midnight.candle.entry'),
);
await settleAudio();
voice.cancelAutoplay();
expect(output.scene, book.atmosphere['midnight.candle.entry']);
expect(output.loads.length, 2);
g.showStory(
book.pages.indexWhere((p) => p.id == 'midnight.candle.puzzle'),
);
await settleAudio();
expect(output.loads.length, 2);
g.home();
await settleAudio();
expect(output.playing, false);
expect(voice.page, isEmpty);
await tester.pumpWidget(const SizedBox());
await tester.pumpAndSettle();
},
);
}
+159
View File
@@ -0,0 +1,159 @@
import 'dart:convert';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:lumen/domain/book.dart';
import 'package:lumen/domain/game.dart';
import 'package:lumen/domain/library.dart';
import 'package:lumen/domain/puzzle.dart';
import 'package:lumen/domain/thinking.dart';
import 'package:lumen/services/progress.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
late StoryLibrary library;
late Book book;
setUpAll(() async {
library = await StoryLibrary.load();
book = await library.open('midnight-invitation');
});
test('Halloween is a complete three-chapter English story with an opening and ending', () {
expect(book.language, 'en');
expect(book.title, 'The Midnight Invitation');
expect(book.levels.length, 12);
expect(book.pages.length, 38);
expect(book.chapters.length, 3);
expect(book.chapterLevels(0), [0, 1, 2, 3]);
expect(book.chapterLevels(1), [4, 5, 6, 7]);
expect(book.chapterLevels(2), [8, 9, 10, 11]);
expect(book.pages.first.type, StoryPageType.dedication);
expect(book.pages.last.type, StoryPageType.closing);
expect(book.pages.last.text, contains('The end.'));
expect(book.continueAt, isNull);
expect(
book.pages
.where((p) => p.type != StoryPageType.puzzle)
.fold<int>(0, (n, p) => n + p.text.split(RegExp(r'\s+')).length),
greaterThan(3000),
);
});
test('all twelve authored silhouettes are unique and solvable by visible clues without guessing', () {
expect(book.levels.map((l) => l.picture.join()).toSet().length, 12);
for (var i = 0; i < book.levels.length; i++) {
final level = book.levels[i], p = level.puzzle();
expect(p.countSolutions(), 1, reason: level.id);
final solver = LogicSolver(49, p.constraints);
expect(solver.analyze(p.initial).cells, p.solution, reason: level.id);
final reasoning = ThinkingAnalyzer(
49,
p.constraints,
).analyze(p.initial, maxLookahead: 0);
expect(reasoning.status, ThinkingStatus.solved, reason: level.id);
expect(reasoning.assumptionSteps, 0, reason: level.id);
expect(reasoning.rounds.length, inInclusiveRange(4, 8));
if (i < 2) {
expect(p.regions, isEmpty);
expect(solver.analyze(p.initial, useAreas: false).solved, true);
} else {
expect(p.regions.length, i < 4 ? 2 : 3);
expect(solver.analyze(p.initial, useAreas: false).solved, false);
expect(reasoning.comparisonSteps, greaterThanOrEqualTo(2));
}
}
});
test('all prose has matching English narration and every discovery has an original image', () async {
final scripts = (jsonDecode(
await rootBundle.loadString(
'assets/stories/midnight-invitation/narration/scripts.json',
),
) as List).map((s) => MapEntry(s['pageId'] as String, s)).toList();
final byId = Map.fromEntries(scripts);
expect(book.tracks.length, 26);
for (final page in book.pages) {
if (page.type == StoryPageType.puzzle) {
expect(book.tracks.containsKey(page.id), false);
continue;
}
final track = book.tracks[page.id];
expect(track['text'], page.text, reason: page.id);
expect(byId[page.id]['text'], page.text);
expect(track['speaker'], 'Elias');
expect(track['production'], 'diary-drama-v2');
expect(
(track['cues'] as List)
.map((c) => c['text'])
.join(track['cueJoin'] ?? '\n\n'),
page.text,
);
final roles = (track['cues'] as List).map((c) => c['speaker']).toSet();
expect(roles, contains('Elias'));
if (page.id == 'midnight.feather.memory' ||
page.id == 'midnight.candle.entry') {
expect(roles, contains('Iris'));
expect(track['events'], isNotEmpty);
}
final bytes = await rootBundle.load(track['asset']);
expect(
ascii.decode(bytes.buffer.asUint8List(bytes.offsetInBytes, 4)),
'RIFF',
);
}
final illustrations = {
book.coverAsset!,
book.paperAsset!,
...book.levels.map((l) => l.illustrationAsset!),
};
expect(illustrations.length, 14);
for (final asset in illustrations) {
final data = await rootBundle.load(asset);
expect(data.getUint32(0), 0x89504e47, reason: asset);
}
});
test('all discoveries award once, survive read-ahead and restore independently of other books', () async {
final store = Progress.memory();
final g = Game(book, store, library: library);
g.openNotebook();
expect(g.storyPage.id, 'midnight.opening');
for (var i = 0; i < 12; i++) {
g.showStory(book.pageFor(i, StoryPageType.entry));
g.startCampaign(i);
final p = g.puzzle!;
final open = p.given.indexOf(false);
g.mark(open);
final marks = List<int>.of(g.cells);
g.showStory(book.pageFor(i, StoryPageType.memory));
expect(g.recovered(i), false);
g.startCampaign(i);
expect(g.cells, marks);
for (var c = 0; c < g.cells.length; c++) {
while (g.cells[c] != (p.solution[c] == 1 ? 1 : 2)) {
g.mark(c);
}
}
expect(g.storyPage.type, StoryPageType.memory);
expect(g.recoveredCount, i + 1);
expect(g.solved, i + 1);
g.startCampaign(i);
g.check();
expect(g.solved, i + 1);
}
g.showStory(book.pages.length - 1);
await g.progress.set('notebook_manual_bookmark', g.storyPage.id);
final restarted = Game(book, Progress.memory(store.snapshot));
await restarted.restore();
expect(restarted.storyPage.id, 'midnight.ending');
expect(restarted.recoveredCount, 12);
await g.selectStory('mara-island');
expect(g.recoveredCount, 0);
expect(g.progress.text('notebook_manual_bookmark'), isEmpty);
await g.selectStory('midnight-invitation');
expect(g.storyPage.id, 'midnight.ending');
expect(g.recoveredCount, 12);
g.leaveCottage();
expect(g.screen, Screen.contents);
});
}
+109
View File
@@ -0,0 +1,109 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:lumen/domain/book.dart';
import 'package:lumen/domain/game.dart';
import 'package:lumen/domain/library.dart';
import 'package:lumen/main.dart';
import 'package:lumen/services/progress.dart';
void main() {
testWidgets(
'all Halloween leaves fit larger text and keep navigation reachable in both orientations',
(tester) async {
addTearDown(tester.view.reset);
tester.platformDispatcher.textScaleFactorTestValue = 1.5;
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
final library = (await tester.runAsync(StoryLibrary.load))!;
final book = (await tester.runAsync(
() => library.open('midnight-invitation'),
))!;
await tester.runAsync(() async {
final font = FontLoader('MaraHand')
..addFont(rootBundle.load('assets/fonts/DancingScript.ttf'));
await font.load();
});
for (final size in [const Size(360, 640), const Size(960, 600)]) {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
final g = Game(book, Progress.memory(), library: library);
await tester.pumpWidget(LumenApp(game: g, adsEnabled: false));
await tester.pumpAndSettle();
for (var i = 0; i < book.pages.length; i++) {
g.showStory(i);
await tester.pumpAndSettle();
final page = book.pages[i];
expect(find.image(AssetImage(book.paperAsset!)), findsOneWidget);
expect(find.text('Undo a mark'), findsNothing);
expect(find.text(page.title), findsOneWidget, reason: page.id);
final next = i == book.pages.length - 1
? 'Back to contents'
: 'Next leaf →';
expect(
find.text(next).hitTestable(),
findsOneWidget,
reason: page.id,
);
if (page.type == StoryPageType.puzzle) {
for (final cell in [0, g.cells.length - 1]) {
final target = find.byKey(ValueKey('cell-$cell'));
expect(target.hitTestable(), findsOneWidget, reason: page.id);
final rect = tester.getRect(target);
expect(rect.top, greaterThanOrEqualTo(0), reason: page.id);
expect(
rect.bottom,
lessThan(tester.getRect(find.text(next)).top),
reason: page.id,
);
}
final hint = find.text('Hint · rewarded ad');
await tester.ensureVisible(hint);
await tester.pumpAndSettle();
expect(hint.hitTestable(), findsOneWidget, reason: page.id);
if (page.text.isNotEmpty) {
expect(find.text(page.text), findsOneWidget);
}
}
expect(tester.takeException(), isNull, reason: page.id);
}
await tester.pumpWidget(const SizedBox());
}
},
);
testWidgets(
'Halloween discovery artwork stays hidden until its own puzzle is restored',
(tester) async {
tester.view.physicalSize = const Size(600, 960);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final library = (await tester.runAsync(StoryLibrary.load))!;
final book = (await tester.runAsync(
() => library.open('midnight-invitation'),
))!;
final g = Game(book, Progress.memory());
await tester.pumpWidget(LumenApp(game: g, adsEnabled: false));
await tester.pumpAndSettle();
for (var i = 0; i < 12; i++) {
final page = book.pageFor(i, StoryPageType.memory);
final asset = AssetImage(book.levels[i].illustrationAsset!);
g.showStory(page);
await tester.pumpAndSettle();
expect(find.image(asset), findsNothing);
await g.progress.set('done_${book.puzzleKey(i)}', true);
g.showStory(page);
await tester.pumpAndSettle();
expect(find.image(asset), findsOneWidget, reason: book.levels[i].id);
expect(tester.takeException(), isNull);
g.showStory(book.pageFor(i, StoryPageType.entry));
await tester.pumpAndSettle();
expect(find.image(asset), findsNothing);
}
await g.progress.set('notebook_manual_bookmark', 'midnight.ending');
g.contents(2);
await tester.pumpAndSettle();
expect(find.text('Return to my ribbon bookmark'), findsOneWidget);
await tester.pumpWidget(const SizedBox());
},
);
}
+37 -1
View File
@@ -25,11 +25,47 @@ class DelayedTranslationBundle extends FixtureBundle {
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
test(
'each book has three persistent reading ad breaks with a shared legacy cap',
() async {
final library = await StoryLibrary.load();
final store = Progress.memory();
for (final story in library.stories) {
final book = await library.open(story.id);
final game = Game(book, store, library: library);
final total =
book.pages.length +
(book.continueAt == null
? 0
: (book.levels.length - book.continueAt!) * 3);
var placements = 0;
for (var position = 0; position <= total; position++) {
if (game.claimBookAd(position, total)) placements++;
expect(game.claimBookAd(position, total), false);
}
expect(placements, 3, reason: story.id);
final restarted = Game(book, Progress.memory(store.snapshot));
for (var position = total; position >= 0; position--) {
expect(restarted.claimBookAd(position, total), false);
}
}
final book = await library.open('mara-island');
final migrated = Game(book, Progress.memory({'storyAd_7': true}));
expect(migrated.claimBookAd(1, 3), true);
expect(migrated.claimBookAd(2, 3), true);
expect(migrated.claimBookAd(3, 3), false);
},
);
test(
'bundled library loads every language and keeps original Mara saves',
() async {
final library = await StoryLibrary.load();
expect(library.stories.map((s) => s.id), ['mara-island', 'paper-boat']);
expect(library.stories.map((s) => s.id), [
'mara-island',
'paper-boat',
'midnight-invitation',
]);
for (final story in library.stories) {
for (final language in story.languages.keys) {
final book = await library.open(story.id, language: language);
+68 -12
View File
@@ -47,6 +47,7 @@ void main() {
await tap('Story library');
await tap('The paper boat');
expect(g.book.id, 'paper-boat');
expect(find.text('The paper boat').hitTestable(), findsOneWidget);
await tap('Open The paper boat · 0 / 1');
expect(g.storyPage.id, 'boat.entry');
await tap('Next leaf →');
@@ -54,30 +55,85 @@ void main() {
await tester.tap(find.byKey(const ValueKey('cell-0')));
await tester.pumpAndSettle();
final marks = List<int>.of(g.cells);
await tap('Bookmark');
expect(find.text('Contents'), findsNothing);
expect(find.text('Bookmark'), findsNothing);
expect(find.text('Language'), findsNothing);
expect(find.text('Close book'), findsNothing);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
expect(g.screen, Screen.home);
await tap('Settings');
await tap('Language');
await tap('Deutsch');
expect(g.book.language, 'de');
expect(g.screen, Screen.home);
g.openNotebook();
await tester.pumpAndSettle();
expect(g.storyPage.id, 'boat.puzzle');
expect(g.cells, marks);
expect(g.canUndo, true);
expect(find.text('Eine kleine Überfahrt'), findsOneWidget);
expect(find.text('Nächste Seite →'), findsOneWidget);
expect(g.progress.text('notebook_manual_bookmark'), 'boat.puzzle');
await tap('Buch schließen');
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
expect(g.screen, Screen.home);
expect(find.text('Einstellungen'), findsOneWidget);
await tap('Geschichtenbibliothek');
expect(
find.descendant(
of: find.byType(AlertDialog),
matching: find.text('Das Papierboot'),
),
findsOneWidget,
);
expect(g.screen, Screen.library);
expect(find.text('Wähle ein Buch'), findsOneWidget);
expect(find.text('Das Papierboot'), findsOneWidget);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox());
},
);
testWidgets('the first window is the bookshelf and opens a chosen book', (
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) {
for (final language in story.languages.keys) {
await library.open(story.id, language: language);
}
}
});
final book = (await tester.runAsync(() => library.open('mara-island')))!;
final g = Game(book, Progress.memory({'language': 'en'}), library: library)
..showLibrary();
await tester.pumpWidget(LumenApp(game: g, adsEnabled: false));
// The shelf loads books through futures created outside the fake async
// zone, so give the real event loop a turn before checking the cards.
for (var i = 0; i < 3; i++) {
await tester.runAsync(
() => Future<void>.delayed(const Duration(milliseconds: 20)),
);
await tester.pump();
}
expect(g.screen, Screen.library);
expect(find.byKey(const ValueKey('library')), findsOneWidget);
for (final story in library.stories) {
expect(find.text(story.title), findsOneWidget);
}
expect(find.text('Open this book ›'), findsNWidgets(3));
final boat = find.text('The paper boat');
await tester.ensureVisible(boat);
await tester.pumpAndSettle();
await tester.tap(boat);
await tester.runAsync(
() => Future<void>.delayed(const Duration(milliseconds: 20)),
);
await tester.pumpAndSettle();
expect(g.book.id, 'paper-boat');
expect(g.screen, Screen.home);
expect(find.text('Open The paper boat · 0 / 1'), findsOneWidget);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox());
});
testWidgets(
'German story pages fit portrait and landscape with larger text',
(tester) async {
@@ -101,7 +157,7 @@ void main() {
for (var i = 0; i < book.pages.length; i++) {
g.showStory(i);
await tester.pumpAndSettle();
expect(find.text('Sprache').hitTestable(), findsOneWidget);
expect(find.text('Sprache'), findsNothing);
expect(
find
.text(i == 2 ? 'Zum Inhaltsverzeichnis' : 'Nächste Seite →')
@@ -151,7 +207,7 @@ void main() {
final heading = find.text('البداية');
expect(Directionality.of(tester.element(heading)), TextDirection.rtl);
expect(tester.widget<Text>(heading).style?.fontFamily, 'sans-serif');
expect(find.text('اللغة'), findsOneWidget);
expect(find.text('اللغة'), findsNothing);
g.startCampaign(0);
await tester.pumpAndSettle();
expect(
+109
View File
@@ -0,0 +1,109 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:lumen/domain/book.dart';
import 'package:lumen/domain/game.dart';
import 'package:lumen/domain/library.dart';
import 'package:lumen/main.dart';
import 'package:lumen/services/progress.dart';
import 'package:lumen/ui/board.dart';
void main() {
testWidgets(
'selected region follows its exact cells and never blocks marking',
(tester) async {
addTearDown(tester.view.reset);
final library = (await tester.runAsync(StoryLibrary.load))!;
final book = (await tester.runAsync(
() => library.open('midnight-invitation'),
))!;
for (final size in [const Size(360, 640), const Size(960, 600)]) {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
final game = Game(book, Progress.memory(), library: library);
game.showStory(book.pageFor(2, StoryPageType.puzzle));
await tester.pumpWidget(LumenApp(game: game, adsEnabled: false));
await tester.pumpAndSettle();
expect(find.text('Undo a mark'), findsNothing);
for (var index = 0; index < game.puzzle!.regions.length; index++) {
final button = find.byKey(ValueKey('area-$index'));
await tester.ensureVisible(button);
await tester.pumpAndSettle();
await tester.tap(button);
await tester.pumpAndSettle();
expect(game.selectedArea, index);
expect(tester.widget<RegionButton>(button).selected, true);
expect(
find.descendant(of: button, matching: find.byIcon(Icons.check)),
findsNothing,
);
final region = game.puzzle!.regions[index];
final n = game.puzzle!.size;
final first = find.byKey(
ValueKey('cell-${region.top * n + region.left}'),
);
final last = find.byKey(
ValueKey(
'cell-${(region.top + region.height - 1) * n + region.left + region.width - 1}',
),
);
final outline = tester.getRect(
find.byKey(const ValueKey('selected-region-outline')),
);
final cells = Rect.fromPoints(
tester.getTopLeft(first),
tester.getBottomRight(last),
);
expect(outline.left, closeTo(cells.left, .01));
expect(outline.top, closeTo(cells.top, .01));
expect(outline.width, closeTo(cells.width, .01));
expect(outline.height, closeTo(cells.height, .01));
final cell = List.generate(
n * n,
(i) => i,
).firstWhere((i) => region.contains(i, n) && !game.puzzle!.given[i]);
final target = find.byKey(ValueKey('cell-$cell'));
final original = game.cells[cell];
await tester.ensureVisible(target);
await tester.pumpAndSettle();
for (var count = 0; count < 3; count++) {
await tester.tap(target);
await tester.pumpAndSettle();
expect(game.cells[cell], (original + count + 1) % 3);
}
}
await tester.pumpWidget(const SizedBox());
}
},
);
testWidgets(
'Halloween paper follows reading and contents and switches back with the book',
(tester) async {
final library = (await tester.runAsync(StoryLibrary.load))!;
final book = (await tester.runAsync(
() => library.open('midnight-invitation'),
))!;
final game = Game(book, Progress.memory(), library: library);
await tester.pumpWidget(LumenApp(game: game, adsEnabled: false));
game.openNotebook();
await tester.pumpAndSettle();
expect(find.image(AssetImage(book.paperAsset!)), findsOneWidget);
expect(
find.image(const AssetImage('assets/artwork/mara-single-page-v2.png')),
findsNothing,
);
game.contents();
await tester.pumpAndSettle();
expect(find.image(AssetImage(book.paperAsset!)), findsOneWidget);
await tester.runAsync(() => game.selectStory('mara-island'));
game.openNotebook();
await tester.pumpAndSettle();
expect(
find.image(const AssetImage('assets/artwork/mara-single-page-v2.png')),
findsOneWidget,
);
expect(find.image(AssetImage(book.paperAsset!)), findsNothing);
await tester.pumpWidget(const SizedBox());
},
);
}
+25 -27
View File
@@ -206,37 +206,35 @@ void main() {
},
);
testWidgets(
'back from a discovery opens its completed grid and forward revisits the memory',
(tester) async {
final book = (await tester.runAsync(Book.load))!;
final g = Game(
book,
Progress.memory({
'story_access_level': 11,
'done_story_v1_4': true,
'solved': 1,
}),
);
g.reveal(4);
await tester.pumpWidget(LumenApp(game: g, adsEnabled: false));
testWidgets('system back closes the book from each reading screen', (
tester,
) async {
final book = (await tester.runAsync(Book.load))!;
final g = Game(
book,
Progress.memory({
'story_access_level': 11,
'done_story_v1_4': true,
'solved': 1,
}),
);
await tester.pumpWidget(LumenApp(game: g, adsEnabled: false));
for (final open in <VoidCallback>[
() => g.showStory(3),
() => g.reveal(4),
() => g.briefing(4),
() => g.startCampaign(4),
() => g.contents(),
]) {
open();
await tester.pumpAndSettle();
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
expect(g.screen, Screen.game);
expect(find.byType(Board), findsOneWidget);
expect(g.puzzle!.solved(g.cells), true);
final forward = find.text('Revisit the memory →');
await tester.ensureVisible(forward);
await tester.pumpAndSettle();
await tester.tap(forward);
await tester.pumpAndSettle();
expect(g.screen, Screen.reveal);
expect(g.campaignIndex, 4);
expect(g.screen, Screen.home);
expect(g.solved, 1);
await tester.pumpWidget(const SizedBox());
},
);
}
await tester.pumpWidget(const SizedBox());
});
testWidgets('every story hint needs a separate earned ad reward', (
tester,