66 lines
3.2 KiB
Dart
66 lines
3.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:jj_mkvmaker/ui/jj_header_row.dart';
|
|
|
|
/// W 공용 위젯 약속 (JjHeaderRow): 제목은 [titleLines] 줄까지 (넘치면 "…") · 단추는 늘 오른쪽 끝에 다 보임 ·
|
|
/// 좁으면 설명은 제목 아래 (숨기지 않음) 와 좁은 단추 · 300 · 360 폭 · 글자 배율 2 에서 넘치지 않음. 위젯 하나에 대해 한 번만 둔다 (설계 7-2)
|
|
void main() {
|
|
const long = 'アップロードされた とても長い 動画のタイトル - 第1話 高画質版 받는 중인 다운로드 12개';
|
|
const sub = 'MKV 만들기에 적용됩니다 (영상을 다시 인코딩)';
|
|
|
|
Future<void> show(WidgetTester t, Widget row, {double width = 360, double scale = 1}) async {
|
|
t.view.physicalSize = Size(width, 600);
|
|
t.view.devicePixelRatio = 1;
|
|
addTearDown(t.view.reset);
|
|
await t.pumpWidget(MaterialApp(
|
|
home: MediaQuery(
|
|
data: MediaQueryData(size: Size(width, 600), textScaler: TextScaler.linear(scale)),
|
|
child: Scaffold(body: Column(children: [row])),
|
|
),
|
|
));
|
|
}
|
|
|
|
Widget row({int lines = 1}) => JjHeaderRow(
|
|
icon: const Icon(Icons.tune, size: 20),
|
|
title: long,
|
|
titleLines: lines,
|
|
subtitle: sub,
|
|
narrowBelow: 560,
|
|
actions: [
|
|
TextButton.icon(onPressed: () {}, icon: const Icon(Icons.restart_alt), label: const Text('모두 초기화')),
|
|
IconButton(tooltip: '닫기', icon: const Icon(Icons.close), onPressed: () {}),
|
|
],
|
|
narrowActions: [
|
|
IconButton(tooltip: '모두 초기화', icon: const Icon(Icons.restart_alt), onPressed: () {}),
|
|
IconButton(tooltip: '닫기', icon: const Icon(Icons.close), onPressed: () {}),
|
|
],
|
|
);
|
|
|
|
for (final width in [300.0, 360.0]) {
|
|
for (final scale in [1.0, 2.0]) {
|
|
testWidgets('폭 $width · 배율 $scale: 좁은 꼴 - ✕ 화면 안 · 설명은 제목 아래 · 넘침 없음', (t) async {
|
|
await show(t, row(), width: width, scale: scale);
|
|
expect(t.takeException(), isNull);
|
|
expect(t.getRect(find.byTooltip('닫기')).right, lessThanOrEqualTo(width));
|
|
expect(find.byTooltip('모두 초기화'), findsOneWidget, reason: '좁으면 같은 이름의 아이콘 단추');
|
|
expect(t.getRect(find.text(sub)).top, greaterThanOrEqualTo(t.getRect(find.text(long)).bottom), reason: '설명은 제목 아래');
|
|
expect(t.widget<Text>(find.text(long)).maxLines, 1);
|
|
});
|
|
}
|
|
}
|
|
|
|
testWidgets('넓으면 한 줄 - 설명은 제목 옆 · 글 단추', (t) async {
|
|
await show(t, row(), width: 960);
|
|
expect(t.takeException(), isNull);
|
|
expect(find.text('모두 초기화'), findsOneWidget);
|
|
expect((t.getRect(find.text(sub)).center.dy - t.getRect(find.text(long)).center.dy).abs(), lessThan(4));
|
|
expect(t.getRect(find.byTooltip('닫기')).right, greaterThan(940), reason: '단추는 오른쪽 끝에 붙음 (가운데에 뜨지 않음)');
|
|
});
|
|
|
|
testWidgets('titleLines 2: 제목이 두 줄까지 (G1 다운로드 종료 창)', (t) async {
|
|
await show(t, row(lines: 2), width: 360);
|
|
expect(t.takeException(), isNull);
|
|
expect(t.widget<Text>(find.text(long)).maxLines, 2);
|
|
});
|
|
}
|