JJ_MKVMaker/integration_test/settings_sections_shot_test...

46 lines
2.5 KiB
Dart
Raw Permalink 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 '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' show i18n;
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/settings_page.dart';
import 'package:jj_mkvmaker/ui/theme.dart';
/// 설정 B: 환경 설정 화면 전체 (모든 분야) 를 실제 글꼴로 3개 언어 × 412 · 960 폭으로 그려 PNG 로 (JJ_SHOT_DIR).
/// 나누기 전후 같은지 픽셀로 견준다. 넘침 (RenderFlex overflow) 이 있으면 시험이 실패한다. 설정은 메모리에만 (저장소 없음)
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets('환경 설정 전체: ko · en · ja × 412 · 960', (tester) async {
final out = Platform.environment['JJ_SHOT_DIR'] ?? Directory.systemTemp.path;
final c = AppController(PlatformServices(mediaTool: ProcessMediaTool('x', 'y'), storage: DesktopStorageService()));
final key = GlobalKey();
for (final lang in ['ko', 'en', 'ja']) {
await tester.runAsync(() => i18n.apply(lang, save: false));
for (final w in [412.0, 960.0]) {
tester.view.devicePixelRatio = 1;
tester.view.physicalSize = Size(w, 900);
await tester.pumpWidget(MaterialApp(theme: buildTheme(), home: RepaintBoundary(key: key, child: SettingsPage(c: c))));
await tester.pumpAndSettle();
// 모든 분야가 한 장에 들어오게 화면을 늘린다
final scroll = tester.state<ScrollableState>(find.byType(Scrollable).last).position;
tester.view.physicalSize = Size(w, (900 + scroll.maxScrollExtent).clamp(900, 30000).toDouble());
await tester.pumpAndSettle();
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/settings_${lang}_${w.toInt()}.png').writeAsBytesSync(bytes!.buffer.asUint8List());
}
}
await tester.runAsync(() => i18n.apply('ko', save: false));
tester.view.reset();
});
}