86 lines
3.8 KiB
Dart
86 lines
3.8 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/rendering.dart';
|
|
import 'package:flutter/services.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_page.dart';
|
|
import 'package:jj_mkvmaker/ui/home_page.dart';
|
|
import 'package:jj_mkvmaker/ui/monitor_page.dart';
|
|
import 'package:jj_mkvmaker/ui/settings_page.dart';
|
|
import 'package:path/path.dart' as p;
|
|
|
|
/// 241: TalkBack 이 읽는 이름이 없는 아이콘 버튼이 없다 (아이콘 크기의 누르는 곳 - 넓은 목록 줄은 안의 글을 읽는다).
|
|
/// 바깥 Tooltip 으로 감싼 IconButton · 이름 없는 InkResponse 는 Android 에 이름이 가지 않았다
|
|
void main() {
|
|
late Directory tmp;
|
|
setUp(() => tmp = Directory.systemTemp.createTempSync('jj_a11y_'));
|
|
tearDown(() => tmp.deleteSync(recursive: true));
|
|
|
|
Future<List<String>> unnamed(WidgetTester tester, Widget Function(AppController) page, double w) async {
|
|
final handle = tester.ensureSemantics();
|
|
// 설정 화면의 rsync 확인이 앱 폴더를 묻는다 (시험 환경에는 path_provider 가 없음)
|
|
const pp = MethodChannel('plugins.flutter.io/path_provider');
|
|
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(pp, (_) async => tmp.path);
|
|
addTearDown(() => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(pp, null));
|
|
tester.view.physicalSize = Size(w, 900);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
final c = AppController(PlatformServices(mediaTool: ProcessMediaTool('x', 'y'), storage: DesktopStorageService()));
|
|
File(p.join(tmp.path, 'a.txt')).writeAsStringSync('a');
|
|
Directory(p.join(tmp.path, 'sub')).createSync();
|
|
c.settings
|
|
..explorer.paths = [tmp.path, tmp.path]
|
|
..copy.rsyncPaths = [tmp.path, tmp.path]
|
|
..copy.tasks = [CopyTask(id: '1', sources: [tmp.path], dest: p.join(tmp.path, 'sub'), method: 'rsync', options: '-av')]
|
|
..copy.liveSyncPairs = [LiveSyncPair(tmp.path, p.join(tmp.path, 'x'))];
|
|
await tester.runAsync(() => tester.pumpWidget(MaterialApp(home: page(c))));
|
|
for (var i = 0; i < 20; i++) {
|
|
await tester.runAsync(() => Future<void>.delayed(const Duration(milliseconds: 30)));
|
|
await tester.pump();
|
|
}
|
|
final out = <String>[];
|
|
void walk(SemanticsNode n) {
|
|
final d = n.getSemanticsData();
|
|
final tappable = d.flagsCollection.isButton || d.hasAction(SemanticsAction.tap);
|
|
if (!n.isMergedIntoParent &&
|
|
tappable &&
|
|
n.rect.width <= 72 &&
|
|
n.rect.height >= 20 &&
|
|
d.label.trim().isEmpty &&
|
|
d.tooltip.trim().isEmpty &&
|
|
d.value.trim().isEmpty) {
|
|
out.add('${n.rect} (위: ${n.parent?.getSemanticsData().label})');
|
|
}
|
|
n.visitChildren((x) {
|
|
walk(x);
|
|
return true;
|
|
});
|
|
}
|
|
|
|
walk(tester.binding.renderViews.first.owner!.semanticsOwner!.rootSemanticsNode!);
|
|
handle.dispose();
|
|
return out;
|
|
}
|
|
|
|
final pages = <String, Widget Function(AppController)>{
|
|
'MKV': (c) => HomePage(c: c),
|
|
'파일 탐색기': (c) => ExplorerPage(c: c),
|
|
'Rsync': (c) => ExplorerPage(c: c, rsync: true),
|
|
'모니터링': (c) => MonitorPage(c: c),
|
|
'환경 설정': (c) => SettingsPage(c: c),
|
|
};
|
|
for (final MapEntry(key: name, value: page) in pages.entries) {
|
|
for (final w in [500.0, 800.0, 1600.0]) {
|
|
testWidgets('241: $name ($w) - 이름 없는 아이콘 버튼 없음', (tester) async {
|
|
expect(await unnamed(tester, page, w), isEmpty);
|
|
});
|
|
}
|
|
}
|
|
}
|