64 lines
2.7 KiB
Dart
64 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:jj_mkvmaker/ui/bottom_inset_hold.dart';
|
|
|
|
/// 204: 아래 시스템 막대 (제스처 · 작업 표시줄) 가 잠깐 커져도 웹 뷰 자리의 크기는 그대로 (검은 띠가 올라오지 않게)
|
|
void main() {
|
|
const box = Key('web');
|
|
Future<void> app(WidgetTester t) async {
|
|
t.view.physicalSize = const Size(800, 1000);
|
|
t.view.devicePixelRatio = 1;
|
|
t.view.padding = const FakeViewPadding(bottom: 20);
|
|
t.view.viewPadding = const FakeViewPadding(bottom: 20);
|
|
addTearDown(t.view.reset);
|
|
// 앱처럼: 맨 위 SafeArea (아래 막대만큼 앱을 줄임) 안에 웹 뷰 자리
|
|
await t.pumpWidget(const MaterialApp(
|
|
home: SafeArea(
|
|
child: Column(children: [
|
|
SizedBox(height: 100),
|
|
Expanded(child: BottomInsetHold(child: ColoredBox(key: box, color: Colors.white))),
|
|
]),
|
|
),
|
|
));
|
|
}
|
|
|
|
double h(WidgetTester t) => t.getSize(find.byKey(box)).height;
|
|
|
|
testWidgets('아래 막대가 잠깐 커지면 크기 그대로 (넘쳐서 그 띠 위에) · 들어가면 그대로 원래', (t) async {
|
|
await app(t);
|
|
expect(h(t), 1000 - 20 - 100);
|
|
// 작업 표시줄이 나타남 (아래 막대 20 → 76)
|
|
t.view.padding = const FakeViewPadding(bottom: 76);
|
|
t.view.viewPadding = const FakeViewPadding(bottom: 76);
|
|
await t.pump();
|
|
expect(h(t), 880, reason: '웹 뷰 크기를 바꾸지 않음');
|
|
expect(t.getRect(find.byKey(box)).bottom, 980, reason: '줄어든 자리 아래로 넘쳐 그 띠 위에 그림');
|
|
// 들어감
|
|
t.view.padding = const FakeViewPadding(bottom: 20);
|
|
t.view.viewPadding = const FakeViewPadding(bottom: 20);
|
|
await t.pump(const Duration(seconds: 5));
|
|
expect(h(t), 880);
|
|
});
|
|
|
|
testWidgets('커진 막대가 3초 넘게 그대로면 (작업 표시줄 고정 등) 새 크기로', (t) async {
|
|
await app(t);
|
|
t.view.padding = const FakeViewPadding(bottom: 76);
|
|
t.view.viewPadding = const FakeViewPadding(bottom: 76);
|
|
await t.pump();
|
|
expect(h(t), 880);
|
|
await t.pump(const Duration(seconds: 3));
|
|
await t.pump();
|
|
expect(h(t), 1000 - 76 - 100);
|
|
});
|
|
|
|
testWidgets('키보드가 열리면 지금처럼 줄인다 (입력 칸이 가리지 않게)', (t) async {
|
|
await app(t);
|
|
t.view.padding = const FakeViewPadding(bottom: 0);
|
|
t.view.viewInsets = const FakeViewPadding(bottom: 300);
|
|
await t.pump();
|
|
// SafeArea 는 키보드만큼 줄이지 않으므로 (Scaffold 가 한다) 여기서는 아래 여백이 0 이 된 만큼만 - 넘치지 않음
|
|
expect(h(t), 1000 - 100);
|
|
expect(t.getRect(find.byKey(box)).bottom, 1000);
|
|
});
|
|
}
|