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:
@@ -0,0 +1,120 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.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';
|
||||
|
||||
void main() {
|
||||
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
testWidgets(
|
||||
'two drama scenes play with atmosphere and live character labels',
|
||||
(tester) async {
|
||||
expect(const bool.fromEnvironment('QA_TEST'), true);
|
||||
final library = await StoryLibrary.load();
|
||||
final book = await library.open('midnight-invitation');
|
||||
final game = Game(
|
||||
book,
|
||||
Progress.memory({'story_access_level': 11, 'language': 'en'}),
|
||||
library: library,
|
||||
);
|
||||
final voice = Narrator(book.tracks);
|
||||
final ambience = Ambience();
|
||||
game.showStory(
|
||||
book.pages.indexWhere((p) => p.id == 'midnight.feather.memory'),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: Notebook(
|
||||
game: game,
|
||||
adsEnabled: false,
|
||||
narrator: voice,
|
||||
ambience: ambience,
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await voice.stop();
|
||||
await ambience.settled;
|
||||
expect(ambience.error, isEmpty);
|
||||
await binding.convertFlutterSurfaceToImage();
|
||||
|
||||
Future<void> tap(String label) async {
|
||||
await tester.ensureVisible(find.text(label));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text(label));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Future<void> reach(int ms) async {
|
||||
final deadline = DateTime.now().add(const Duration(seconds: 65));
|
||||
while (voice.position.inMilliseconds < ms &&
|
||||
DateTime.now().isBefore(deadline)) {
|
||||
await Future<void>.delayed(const Duration(milliseconds: 180));
|
||||
await tester.pump();
|
||||
expect(voice.error, isEmpty);
|
||||
}
|
||||
expect(voice.position.inMilliseconds, greaterThanOrEqualTo(ms));
|
||||
}
|
||||
|
||||
await tap('Play this reading');
|
||||
debugPrint('DRAMA_MIX_READY: threshold atmosphere and cast reading');
|
||||
final doorCues = book.tracks['midnight.feather.memory']['cues'] as List;
|
||||
final firstIris =
|
||||
doorCues.firstWhere((c) => c['speaker'] == 'Iris')['startMs'] as int;
|
||||
for (final role in ['Iris', 'Elias']) {
|
||||
final cue = (book.tracks['midnight.feather.memory']['cues'] as List)
|
||||
.firstWhere(
|
||||
(c) =>
|
||||
c['speaker'] == role &&
|
||||
c['startMs'] > (role == 'Elias' ? firstIris : 0),
|
||||
);
|
||||
await reach(cue['startMs'] + 150);
|
||||
expect(voice.speaker, role);
|
||||
expect(find.text('$role · recorded story'), findsOneWidget);
|
||||
expect(ambience.error, isEmpty);
|
||||
}
|
||||
await tap('Pause recording');
|
||||
final paused = voice.position;
|
||||
await Future<void>.delayed(const Duration(milliseconds: 700));
|
||||
expect((voice.position - paused).inMilliseconds.abs(), lessThan(150));
|
||||
await tap('Resume recording');
|
||||
await reach(paused.inMilliseconds + 500);
|
||||
await binding.takeScreenshot('drama-threshold-playing');
|
||||
|
||||
game.showStory(
|
||||
book.pages.indexWhere((p) => p.id == 'midnight.candle.entry'),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await voice.stop();
|
||||
await ambience.settled;
|
||||
expect(ambience.error, isEmpty);
|
||||
expect(voice.page, isEmpty);
|
||||
await tap('Play this reading');
|
||||
final iris = (book.tracks['midnight.candle.entry']['cues'] as List)
|
||||
.firstWhere((c) => c['speaker'] == 'Iris');
|
||||
await reach(iris['startMs'] + 150);
|
||||
expect(find.text('Iris · recorded story'), findsOneWidget);
|
||||
await tap('Pause recording');
|
||||
await tap('Sound & atmosphere');
|
||||
await tester.tap(find.byType(SwitchListTile));
|
||||
await tester.pumpAndSettle();
|
||||
await ambience.settled;
|
||||
expect(game.progress.flag('ambience_enabled'), false);
|
||||
await tap('Keep going');
|
||||
await binding.takeScreenshot('drama-kitchen-paused');
|
||||
game.home();
|
||||
await tester.pumpAndSettle();
|
||||
await ambience.settled;
|
||||
expect(voice.page, isEmpty);
|
||||
expect(ambience.error, isEmpty);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
await tester.pumpAndSettle();
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user