import 'dart:io'; import 'dart:ui' as ui; import 'package:flutter/foundation.dart'; 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/ui/explorer_page.dart'; import 'package:jj_mkvmaker/ui/theme.dart'; import 'package:path/path.dart' as p; import 'support/shot_services.dart'; import 'support/temp_dir.dart'; /// X-plore 비교 40 (관리자 지시 10/20): 412 폭 · 목록 글자 150% · 넓게 (그리고 처음 값) 를 실제 글꼴로 그려 PNG 로 (JJ_SHOT_DIR). /// 세 스타일 모두. 넘치면 (RenderFlex overflow) 시험이 실패한다 void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); // ⑦ 밝은 화면 캡처: JJ_SHOT_THEME=light (JJ_SHOT_DIR 를 따로 두어 어두운 것과 견줌) if (Platform.environment['JJ_SHOT_THEME'] == 'light') JjColors.use(Brightness.light); testWidgets('40: 목록 글자 크기 · 줄 간격 화면 그림 (412 폭)', (tester) async { final out = Platform.environment['JJ_SHOT_DIR'] ?? Directory.systemTemp.path; // 관리자 지시 (10/24): 실행마다 다른 값 (폴더 이름 · 시각 · CPU · 메모리) 을 정한 값으로 (캡처가 흔들리지 않게 - 시험 쪽에서만) // 트리에 둘레 폴더도 보여 JJ_SHOT_TMP (캡처용으로 따로 둔 폴더) 아래에 둔다 final base = Platform.environment['JJ_SHOT_TMP'] ?? ''; final tmp = testFixedTempDir('jj_textshot_fixed', base: base); 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(); // 캡처용 폴더가 따로 있으면 그 폴더의 시각까지 (트리에 보인다). 시스템 임시 폴더면 시험 폴더만 pinTestTimes(base.isEmpty ? tmp : Directory(base)); final c = AppController(shotServices()); c.settings.explorer.paths = [tmp.path, tmp.path]; final key = GlobalKey(); // 폰처럼 (Android 는 트리 펼치기 화살표가 44 로 넓다 - Windows 로 그리면 폰보다 넉넉해 보인다) debugDefaultTargetPlatformOverride = TargetPlatform.android; for (final (layout, width, device) in [('single', 412.0, 1.0), ('split', 412.0, 1.0), ('split', 360.0, 1.0), ('split', 412.0, 1.3)]) { for (final style in ['xplore', 'windows', 'totalcmd']) { for (final (scale, spacing) in [(100, 'normal'), (150, 'wide'), (80, 'compact')]) { c.settings ..explorer.layout = layout ..explorer.style = style ..explorer.textScale = scale ..explorer.rowSpacing = spacing; tester.view.physicalSize = Size(width, 900); tester.view.devicePixelRatio = 1; await tester.runAsync(() => tester.pumpWidget(MaterialApp( theme: buildTheme(), // 기기 글자 크기 (관리자 지시 10/20: 1.3 × 150% 에서 두 창이 모자라면 한 창) builder: (ctx, child) => MediaQuery(data: MediaQuery.of(ctx).copyWith(textScaler: TextScaler.linear(device)), child: child!), home: RepaintBoundary(key: key, child: ExplorerPage(c: c, device: shotDevice())), ))); for (var i = 0; i < 12; i++) { await tester.runAsync(() => Future.delayed(const Duration(milliseconds: 250))); await tester.pump(); } expect(tester.takeException(), isNull, reason: '$layout $width ×$device $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${width.round()}${device == 1 ? '' : '_dev${(device * 10).round()}'}_${style}_${scale}_$spacing.png').writeAsBytesSync(bytes!.buffer.asUint8List()); await tester.pumpWidget(const SizedBox()); await tester.runAsync(() => Future.delayed(const Duration(milliseconds: 300))); } } } debugDefaultTargetPlatformOverride = null; tester.view.reset(); }); }