48 lines
1.5 KiB
Dart
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);
|
||
|
|
});
|
||
|
|
}
|