halkyon/packages/halkyon_ui/test/widget/tinted_frame_test.dart
Tizian 「ティツィアーン」 80fa7b9628
Halkyon's shared packages
A pub workspace of the Dart packages Halkyon's apps share: halkyon_ui,
Halkyon's look (the theme, fonts, layout and shared widgets, with texts
in English and German), halkyon_core's low-level primitives and
halkyon_interop's cross-app contracts. Dart 3.13 with LeanCode's lints,
configured once at the root; apps take a package by git, pinned to a
signed commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-10-18 21:50:15 +02:00

48 lines
1.5 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:halkyon_ui/halkyon_ui.dart';
import 'package:material_ui/material_ui.dart';
void main() {
/// A screen with something typed into it, as a study session or a card
/// being written holds what was done.
Future<void> typeIn(
WidgetTester tester,
Widget Function(Widget) around,
) async {
tester.view.physicalSize = const Size(1200, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(
MaterialApp(
theme: appTheme(Brightness.light),
home: around(const Scaffold(body: TextField())),
),
);
await tester.enterText(find.byType(TextField), 'kept');
}
/// Crosses every line where the frame or the snack bars change: medium,
/// compact, medium again.
Future<void> resize(WidgetTester tester) async {
for (final width in const [700.0, 400.0, 1200.0]) {
tester.view.physicalSize = Size(width, 800);
await tester.pumpAndSettle();
}
}
testWidgets('a framed screen keeps what it holds when the window crosses '
'from medium to compact and back', (tester) async {
await typeIn(tester, (screen) => FramedScreen(child: screen));
await resize(tester);
expect(find.text('kept'), findsOneWidget);
});
testWidgets('so does every screen under the snack bars fitted to the '
'window', (tester) async {
await typeIn(tester, (screen) => FittedSnackBars(child: screen));
await resize(tester);
expect(find.text('kept'), findsOneWidget);
});
}