76 lines
4.1 KiB
Dart
76 lines
4.1 KiB
Dart
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/app/settings.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/style_ask.dart';
|
|
|
|
/// E6 약속: 파일 탐색기 모양의 처음 값은 기기마다 (Windows = Total Commander) · 예전 판이 저장한 X-plore 는 한 번만 묻는다
|
|
void main() {
|
|
final win = Platform.isWindows;
|
|
|
|
test('처음 값: 새로 설치 (빈 설정) 는 기기의 처음 값 - Windows 는 Total Commander, 묻지 않음', () {
|
|
final s = AppSettings.fromJson({});
|
|
expect(s.explorer.style, win ? 'totalcmd' : 'xplore');
|
|
expect(s.explorer.styleAskPending, isFalse);
|
|
expect(AppSettings().explorer.style, ExplorerSettings.defaultStyle);
|
|
});
|
|
|
|
test('저장된 값: 예전 판의 xplore (또는 모양 키가 없던 예전 파일) 는 Windows 에서 한 번 묻고, 고른 windows · totalcmd 는 묻지 않음', () {
|
|
final old = AppSettings.fromJson({'explorerStyle': 'xplore', 'explorerLayout': 'dual'});
|
|
expect([old.explorer.style, old.explorer.styleAskPending], ['xplore', win]);
|
|
final noKey = AppSettings.fromJson({'explorerLayout': 'dual'});
|
|
expect([noKey.explorer.style, noKey.explorer.styleAskPending], ['xplore', win], reason: '그때의 처음 값 (X-plore) 을 덮지 않음');
|
|
for (final v in ['windows', 'totalcmd']) {
|
|
final s = AppSettings.fromJson({'explorerStyle': v, 'explorerLayout': 'dual'});
|
|
expect([s.explorer.style, s.explorer.styleAskPending], [v, false]);
|
|
}
|
|
final again = AppSettings.fromJson(old.toJson());
|
|
expect([again.explorer.style, again.explorer.styleAskPending], ['xplore', false], reason: '한 번 저장하면 (물었다는 표시) 다시 묻지 않음');
|
|
});
|
|
|
|
group('묻는 창 (askExplorerStyleOnce)', () {
|
|
AppController ctl(Map<String, dynamic> saved) =>
|
|
AppController(PlatformServices(mediaTool: ProcessMediaTool('x', 'y'), storage: DesktopStorageService()))
|
|
..settings = AppSettings.fromJson(saved);
|
|
|
|
Future<bool> ask(WidgetTester t, AppController c, {String? pick}) async {
|
|
final key = GlobalKey<NavigatorState>();
|
|
await t.pumpWidget(MaterialApp(navigatorKey: key, home: const Scaffold(body: SizedBox())));
|
|
final f = askExplorerStyleOnce(key.currentContext!, c);
|
|
await t.pumpAndSettle();
|
|
if (pick != null) {
|
|
expect(find.text('파일 탐색기 모양'), findsOneWidget);
|
|
await t.tapAt(const Offset(5, 5)); // 창 밖을 눌러도 닫히지 않음
|
|
await t.pumpAndSettle();
|
|
expect(find.text('파일 탐색기 모양'), findsOneWidget);
|
|
await t.tap(find.text(pick));
|
|
await t.pumpAndSettle();
|
|
}
|
|
return f;
|
|
}
|
|
|
|
testWidgets('[그대로] 면 X-plore 를 두고 다시 묻지 않음', (t) async {
|
|
final c = ctl({'explorerStyle': 'xplore', 'explorerLayout': 'dual'})..settings.explorer.styleAskPending = true;
|
|
expect(await ask(t, c, pick: '그대로'), isTrue);
|
|
expect([c.settings.explorer.style, c.settings.explorer.styleAskPending], ['xplore', false]);
|
|
expect(await ask(t, c), isFalse);
|
|
expect(find.text('파일 탐색기 모양'), findsNothing, reason: '두 번째는 창을 띄우지 않음');
|
|
expect(c.settings.toJson()['explorerStyleV2'], isTrue);
|
|
});
|
|
|
|
testWidgets('[바꾸기] 면 Total Commander · 물을 것이 없으면 창 없음', (t) async {
|
|
final c = ctl({'explorerStyle': 'xplore', 'explorerLayout': 'dual'})..settings.explorer.styleAskPending = true;
|
|
expect(await ask(t, c, pick: '바꾸기'), isTrue);
|
|
expect([c.settings.explorer.style, c.settings.explorer.styleAskPending], ['totalcmd', false]);
|
|
final picked = ctl({'explorerStyle': 'windows', 'explorerLayout': 'dual'});
|
|
expect(await ask(t, picked), isFalse);
|
|
expect(picked.settings.explorer.style, 'windows');
|
|
});
|
|
});
|
|
}
|