JJ_MKVMaker/test/tail_text_test.dart

34 lines
1.6 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:jj_mkvmaker/ui/tail_text.dart';
/// 관리자 지시 (10/21, 28 지적): 경로 줄은 좁으면 앞을 "…" 로 - 지금 폴더 (끝) 가 늘 보이게
void main() {
double m(String t) => t.length * 10.0;
test('들어가면 그대로 · 모자라면 구분에서 앞을 줄임 (가장 긴 뒤쪽) · 마지막 조각도 길면 글자 단위', () {
const path = '보관함 › 가족 › 2026 › 여름 휴가 › 제주도 둘째 날';
expect(TailText.fit(path, 1000, m), path);
expect(TailText.fit(path, 200, m), '… › 여름 휴가 › 제주도 둘째 날');
expect(TailText.fit(path, 120, m), '… › 제주도 둘째 날');
expect(TailText.fit(path, 60, m), '… 둘째 날', reason: '마지막 조각도 길면 그 끝을');
expect(TailText.fit(r'C:\Users\haram\AppData\Local\Temp', 170, m), r'…\Local\Temp');
expect(TailText.fit('dav://nas/사진/2026', 80, m), '…/2026');
});
testWidgets('좁은 칸 (글자 1.3 배) 에서도 지금 폴더가 보임', (t) async {
await t.pumpWidget(MaterialApp(
home: MediaQuery(
data: const MediaQueryData(textScaler: TextScaler.linear(1.3)),
child: Scaffold(
body: Center(child: SizedBox(width: 220, child: TailText('보관함 › 가족 › 2026 › 여름 휴가 › 제주도 둘째 날'))),
),
),
));
final shown = t.widget<Text>(find.byType(Text)).data!;
expect(shown, startsWith('…'));
expect(shown, endsWith('제주도 둘째 날'));
expect(t.takeException(), isNull);
});
}