JJ_MKVMaker/integration_test/explorer_text_shot_test.dart

62 lines
3.2 KiB
Dart

import 'dart:io';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:jj_mkvmaker/app/app_controller.dart';
import 'package:jj_mkvmaker/services/platform_services.dart';
import 'package:jj_mkvmaker/ui/explorer_page.dart';
import 'package:jj_mkvmaker/ui/theme.dart';
import 'package:path/path.dart' as p;
/// X-plore 비교 40 (관리자 지시 10/20): 412 폭 · 목록 글자 150% · 넓게 (그리고 처음 값) 를 실제 글꼴로 그려 PNG 로 (JJ_SHOT_DIR).
/// 세 스타일 모두. 넘치면 (RenderFlex overflow) 시험이 실패한다
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets('40: 목록 글자 크기 · 줄 간격 화면 그림 (412 폭)', (tester) async {
final out = Platform.environment['JJ_SHOT_DIR'] ?? Directory.systemTemp.path;
final tmp = Directory.systemTemp.createTempSync('jj_textshot_');
addTearDown(() => tmp.deleteSync(recursive: true));
File(p.join(tmp.path, '아주 긴 이름의 동영상 파일 - 글자 크기 시험용 2026 최종본.mp4')).writeAsStringSync('v' * 123456);
File(p.join(tmp.path, 'Very long English file name for the text size check.txt')).writeAsStringSync('t' * 4321);
File(p.join(tmp.path, 'a.jpg')).writeAsStringSync('x');
Directory(p.join(tmp.path, '폴더 하나')).createSync();
Directory(p.join(tmp.path, 'Another folder with a long name')).createSync();
final c = AppController(PlatformServices.create());
c.settings.explorerPaths = [tmp.path, tmp.path];
final key = GlobalKey();
for (final layout in ['single', 'split']) {
for (final style in ['xplore', 'windows', 'totalcmd']) {
for (final (scale, spacing) in [(100, 'normal'), (150, 'wide'), (80, 'compact')]) {
c.settings
..explorerLayout = layout
..explorerStyle = style
..explorerTextScale = scale
..explorerRowSpacing = spacing;
tester.view.physicalSize = const Size(412, 900);
tester.view.devicePixelRatio = 1;
await tester.runAsync(() => tester.pumpWidget(MaterialApp(
theme: buildTheme(),
home: RepaintBoundary(key: key, child: ExplorerPage(c: c)),
)));
for (var i = 0; i < 12; i++) {
await tester.runAsync(() => Future<void>.delayed(const Duration(milliseconds: 250)));
await tester.pump();
}
expect(tester.takeException(), isNull, reason: '$layout $style $scale% $spacing 넘치지 않음');
final boundary = key.currentContext!.findRenderObject()! as RenderRepaintBoundary;
final image = await tester.runAsync(() => boundary.toImage());
final bytes = await tester.runAsync(() => image!.toByteData(format: ui.ImageByteFormat.png));
File('$out/explorer_text_${layout}_${style}_${scale}_$spacing.png').writeAsBytesSync(bytes!.buffer.asUint8List());
await tester.pumpWidget(const SizedBox());
await tester.runAsync(() => Future<void>.delayed(const Duration(milliseconds: 300)));
}
}
}
tester.view.reset();
});
}