60 lines
3.0 KiB
Dart
60 lines
3.0 KiB
Dart
import 'dart:convert';
|
||
import 'dart:io';
|
||
|
||
import 'package:flutter/material.dart';
|
||
import 'package:flutter_test/flutter_test.dart';
|
||
import 'package:jj_mkvmaker/app/app_controller.dart';
|
||
import 'package:jj_mkvmaker/l10n/tr.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/explorer_page.dart';
|
||
|
||
/// 188: 탐색기 가운데 버튼 줄의 글이 두 줄로 꺾여도 버튼 아래로 잘리지 않는다 (일본어 "新しいフォルダー" · 세로 화면)
|
||
void main() {
|
||
late Directory tmp;
|
||
setUp(() => tmp = Directory.systemTemp.createTempSync('jj_labels_'));
|
||
tearDown(() {
|
||
setTranslations('ko', const {});
|
||
tmp.deleteSync(recursive: true);
|
||
});
|
||
|
||
Map<String, String> dict(String code) =>
|
||
Map<String, String>.from(jsonDecode(File('assets/l10n/$code.json').readAsStringSync()) as Map);
|
||
|
||
for (final lang in ['ko', 'en', 'ja', 'zh-Hans']) {
|
||
for (final size in [const Size(800, 1280), const Size(1280, 800), const Size(412, 900)]) {
|
||
for (final scale in [1.0, 1.6]) {
|
||
testWidgets('188: 버튼 글이 버튼 안에 다 보인다 ($lang, ${size.width.round()}×${size.height.round()}, 글자 $scale배)', (tester) async {
|
||
setTranslations(lang, lang == 'ko' ? const {} : dict(lang), lang == 'ko' ? const {} : dict('en'));
|
||
tester.view.physicalSize = size;
|
||
tester.view.devicePixelRatio = 1;
|
||
addTearDown(tester.view.reset);
|
||
final c = AppController(PlatformServices(mediaTool: ProcessMediaTool('x', 'y'), storage: DesktopStorageService()));
|
||
c.settings.explorerPaths = [tmp.path, tmp.path];
|
||
// 기기 글꼴 · 글자 크기가 시험 글꼴보다 크다 (S10 일본어에서 잘림) - 글자 크기를 키운 경우도
|
||
await tester.runAsync(() => tester.pumpWidget(MaterialApp(
|
||
builder: (ctx, child) => MediaQuery(data: MediaQuery.of(ctx).copyWith(textScaler: TextScaler.linear(scale)), child: child!),
|
||
home: ExplorerPage(c: c))));
|
||
for (var i = 0; i < 10; i++) {
|
||
await tester.runAsync(() => Future<void>.delayed(const Duration(milliseconds: 30)));
|
||
await tester.pump();
|
||
}
|
||
// 1.6배에서는 목록 줄 (높이 고정) 이 넘친다 - 따로 알림 (이 시험은 버튼 줄만 본다)
|
||
if (scale == 1.0) {
|
||
expect(tester.takeException(), isNull);
|
||
} else {
|
||
tester.takeException();
|
||
}
|
||
final label = find.text(tr('새 폴더'));
|
||
if (label.evaluate().isEmpty) return; // 좁아서 [더 보기] 메뉴로 들어감
|
||
final text = tester.getRect(label.first);
|
||
final button = tester.getRect(find.ancestor(of: label.first, matching: find.byType(InkWell)).first);
|
||
expect(text.bottom, lessThanOrEqualTo(button.bottom + 0.5), reason: '글 $text · 버튼 $button');
|
||
expect(text.top, greaterThanOrEqualTo(button.top - 0.5));
|
||
});
|
||
}
|
||
}
|
||
}
|
||
}
|