diff --git a/test/file_tools_test.dart b/test/file_tools_test.dart index 2c70bec..87d54cb 100644 --- a/test/file_tools_test.dart +++ b/test/file_tools_test.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; import 'package:jj_mkvmaker/ui/file_tools.dart'; import 'package:path/path.dart' as p; +import 'package:flutter/material.dart'; /// X-plore 비교 P3: 해시 · 16진 보기 · 폴더 속성 void main() { @@ -27,4 +28,26 @@ void main() { final s = await folderStats(p.join(tmp.path, 'd')); expect((s.files, s.folders, s.bytes), (2, 1, 15)); }); + + testWidgets('위키 974 3절 (10/20): 16진 보기 - 폰 세로 (412) 는 한 줄 8바이트 · 넓으면 16바이트', (tester) async { + final dir = Directory.systemTemp.createTempSync('jj_hex_'); + addTearDown(() => dir.deleteSync(recursive: true)); + final f = File(p.join(dir.path, 'a.bin'))..writeAsBytesSync([for (var i = 0; i < 40; i++) 0x41 + i % 26]); + for (final (w, per) in [(412.0, 8), (960.0, 16)]) { + tester.view.physicalSize = Size(w, 800); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + await tester.pumpWidget(MaterialApp(key: ValueKey(w), home: HexViewerPage(path: f.path))); + // 파일은 진짜 입출력으로 읽는다 - 다 읽어 그릴 때까지 + for (var i = 0; i < 20 && find.textContaining(RegExp('^00000000 ')).evaluate().isEmpty; i++) { + await tester.runAsync(() => Future.delayed(const Duration(milliseconds: 50))); + await tester.pump(); + } + // 둘째 줄의 시작 자리 = per + final second = per.toRadixString(16).padLeft(8, '0'); + expect(find.textContaining(RegExp('^$second ')), findsOneWidget, reason: '$w 폭: 한 줄 $per 바이트'); + expect(tester.takeException(), isNull); + // 글자 칸까지 화면 안인지는 실제 글꼴로 - Windows 캡처 (15, 412 폭) 가 본다 (시험 글꼴은 모든 글자가 정사각형) + } + }); } diff --git a/test/wifi_share_test.dart b/test/wifi_share_test.dart index 286042e..bf5b886 100644 --- a/test/wifi_share_test.dart +++ b/test/wifi_share_test.dart @@ -201,4 +201,24 @@ void main() { expect(WifiShare.isLocalNetwork(ip), isFalse, reason: ip); } }); + + test('위키 974 2절 (10/20): [끄기] · 저절로 꺼진 뒤에는 그 주소 · 포트로 더는 열리지 않는다 (다른 기기에서 안 열림)', () async { + final port = s.port; + final ok = await Socket.connect('127.0.0.1', port); + ok.destroy(); + await s.stop(); + expect(s.running, isFalse); + await expectLater(Socket.connect('127.0.0.1', port, timeout: const Duration(seconds: 1)), throwsA(isA()), + reason: '[끄기] 뒤'); + final t = await WifiShare.start(shared.path, port: 0, autoOff: const Duration(milliseconds: 200), loopbackOnly: true); + s = t; + final port2 = t.port; + (await Socket.connect('127.0.0.1', port2)).destroy(); + for (var i = 0; i < 50 && t.running; i++) { + await Future.delayed(const Duration(milliseconds: 20)); + } + expect(t.running, isFalse); + await expectLater(Socket.connect('127.0.0.1', port2, timeout: const Duration(seconds: 1)), throwsA(isA()), + reason: '저절로 꺼진 뒤'); + }); }