import 'dart:async'; 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/app/i18n_controller.dart'; import 'package:jj_mkvmaker/platform/windows/desktop_storage_service.dart'; import 'package:jj_mkvmaker/platform/windows/process_media_tool.dart'; import 'package:jj_mkvmaker/services/platform_services.dart'; import 'package:jj_mkvmaker/ui/ai_settings.dart'; import 'package:jj_mkvmaker/ui/archive_ui.dart'; import 'package:jj_mkvmaker/ui/theme.dart'; import 'package:path/path.dart' as p; import 'support/temp_dir.dart'; /// F1 (관리자 지시 10/21, 15 찾음): 비밀번호 · 키 칸 이름은 짧게, 설명은 칸 아래 - ZIP 으로 묶기 창 · AI 인터넷 서비스 추가 창을 /// ko · en · ja × 412 · 960 으로 찍는다 (SFTP 추가 창은 windows_trunc_shot_test). 아무것도 만들지 않는다 (창만 열고 닫음). void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); final out = Platform.environment['JJ_SHOT_DIR'] ?? ''; for (final lang in ['ko', 'en', 'ja']) { for (final (w, h) in [(412, 900), (960, 600)]) { testWidgets('F1 칸 이름 $lang ${w}x$h', (t) async { t.view.physicalSize = Size(w.toDouble(), h.toDouble()); t.view.devicePixelRatio = 1; addTearDown(t.view.reset); await t.runAsync(() => i18n.apply(lang, save: false)); addTearDown(() => i18n.apply('ko', save: false)); final tmp = testTempDir('jj_f1shot_'); final file = File(p.join(tmp.path, 'a.txt'))..writeAsStringSync('a'); final c = AppController(PlatformServices(mediaTool: ProcessMediaTool('x', 'y'), storage: DesktopStorageService())); final navKey = GlobalKey(); final shotKey = GlobalKey(); await t.pumpWidget(RepaintBoundary( key: shotKey, child: MaterialApp( theme: buildTheme(), debugShowCheckedModeBanner: false, navigatorKey: navKey, home: const Scaffold(body: SizedBox.expand())), )); Future settle([int n = 8]) async { for (var i = 0; i < n; i++) { await t.runAsync(() => Future.delayed(const Duration(milliseconds: 60))); await t.pump(); } } Future shot(String name) async { await settle(3); expect(t.takeException(), isNull, reason: '$name 넘침'); if (out.isEmpty) return; final b = shotKey.currentContext!.findRenderObject()! as RenderRepaintBoundary; final img = await t.runAsync(() => b.toImage()); final bytes = await t.runAsync(() => img!.toByteData(format: ui.ImageByteFormat.png)); Directory(out).createSync(recursive: true); File(p.join(out, 'f1_${name}_${lang}_$w.png')).writeAsBytesSync(bytes!.buffer.asUint8List()); } Future closeAll() async { navKey.currentState!.popUntil((r) => r.isFirst); await settle(); } unawaited(createZipFlow(navKey.currentContext!, c, [file.path], dir: tmp.path)); await settle(12); await shot('zip'); await closeAll(); unawaited(editAiService(navKey.currentContext!, c)); await settle(12); await shot('ai'); // F2 (10/21): ComfyUI 로 바꾸면 주소 예시 · 모델 도움 글 - 3줄까지 (잘리지 않게) await t.tap(find.text('Automatic1111 · Forge').first); await settle(); await t.tap(find.text('ComfyUI').last); await settle(); await shot('ai_comfy'); await closeAll(); expect(Directory(tmp.path).listSync().map((e) => p.basename(e.path)), ['a.txt'], reason: '창만 열고 닫음 - 아무것도 만들지 않음'); }); } } }