0718e3f252
- 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.
127 lines
4.7 KiB
Dart
127 lines
4.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:integration_test/integration_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 'halloween_test.dart' as halloween;
|
|
import 'library_test.dart' as library_flow;
|
|
import 'region_test.dart' as regions;
|
|
|
|
void main() {
|
|
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
|
testWidgets('phone reading and puzzle controls fit default and larger text', (
|
|
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({'language': 'en', 'ambience_enabled': false}),
|
|
library: library,
|
|
);
|
|
var scale = 1.0;
|
|
Widget app() => MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
theme: ThemeData(fontFamily: 'MaraHand'),
|
|
builder: (context, child) => MediaQuery(
|
|
data: MediaQuery.of(context)
|
|
.copyWith(textScaler: TextScaler.linear(scale)),
|
|
child: child!,
|
|
),
|
|
home: Notebook(game: game, adsEnabled: false),
|
|
);
|
|
await tester.pumpWidget(app());
|
|
await tester.pumpAndSettle();
|
|
await binding.convertFlutterSurfaceToImage();
|
|
Future<void> orient(DeviceOrientation orientation) async {
|
|
await SystemChrome.setPreferredOrientations([orientation]);
|
|
for (var i = 0; i < 40; i++) {
|
|
await tester.pump(const Duration(milliseconds: 100));
|
|
final size = tester.view.physicalSize;
|
|
if ((size.height > size.width) ==
|
|
(orientation == DeviceOrientation.portraitUp)) {
|
|
await tester.pumpAndSettle();
|
|
return;
|
|
}
|
|
}
|
|
fail('Phone did not rotate to $orientation');
|
|
}
|
|
|
|
for (final textScale in [1.0, 1.3]) {
|
|
scale = textScale;
|
|
await tester.pumpWidget(app());
|
|
for (final orientation in [
|
|
DeviceOrientation.portraitUp,
|
|
DeviceOrientation.landscapeLeft,
|
|
]) {
|
|
await orient(orientation);
|
|
final layout = orientation == DeviceOrientation.portraitUp
|
|
? 'portrait'
|
|
: 'landscape';
|
|
final tag = 'phone-$layout-${(scale * 100).round()}';
|
|
game.home();
|
|
await tester.pumpAndSettle();
|
|
expect(find.text(book.title), findsOneWidget);
|
|
await binding.takeScreenshot('$tag-home');
|
|
for (final pageId in [
|
|
'midnight.opening',
|
|
'midnight.key.puzzle',
|
|
'midnight.candle.entry',
|
|
'midnight.mirror.puzzle',
|
|
'midnight.ending',
|
|
]) {
|
|
game.showStory(book.pages.indexWhere((p) => p.id == pageId));
|
|
await tester.pumpAndSettle();
|
|
final next = pageId == 'midnight.ending'
|
|
? 'Back to contents'
|
|
: 'Next leaf →';
|
|
expect(
|
|
find.text(next).hitTestable(),
|
|
findsOneWidget,
|
|
reason: '$tag $pageId',
|
|
);
|
|
expect(find.text('Contents'), findsNothing, reason: '$tag $pageId');
|
|
if (game.storyPage.type == StoryPageType.puzzle) {
|
|
for (final index in [0, game.cells.length - 1]) {
|
|
final cell = find.byKey(ValueKey('cell-$index'));
|
|
expect(
|
|
cell.hitTestable(),
|
|
findsOneWidget,
|
|
reason: '$tag $pageId',
|
|
);
|
|
expect(
|
|
tester.getRect(cell).bottom,
|
|
lessThan(tester.getRect(find.text(next)).top),
|
|
reason: '$tag $pageId',
|
|
);
|
|
}
|
|
final hint = find.text('Hint · rewarded ad');
|
|
await tester.ensureVisible(hint);
|
|
await tester.pumpAndSettle();
|
|
expect(hint.hitTestable(), findsOneWidget, reason: '$tag $pageId');
|
|
final cell = find.byKey(const ValueKey('cell-0'));
|
|
debugPrint('PHONE_GRID $tag $pageId cell=${tester.getSize(cell)}');
|
|
await tester.ensureVisible(find.byKey(const ValueKey('area-1')));
|
|
await tester.tap(find.byKey(const ValueKey('area-1')));
|
|
await tester.pumpAndSettle();
|
|
expect(game.selectedArea, 1);
|
|
}
|
|
await binding.takeScreenshot('$tag-${pageId.replaceAll('.', '-')}');
|
|
expect(tester.takeException(), isNull, reason: '$tag $pageId');
|
|
}
|
|
}
|
|
}
|
|
await tester.pumpWidget(const SizedBox());
|
|
await SystemChrome.setPreferredOrientations([]);
|
|
});
|
|
halloween.main();
|
|
regions.main();
|
|
library_flow.main();
|
|
}
|