import 'dart:async'; import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; import 'package:jj_mkvmaker/app/volumes.dart'; import 'package:path/path.dart' as p; /// E5a 약속 시험: lib/app/volumes.dart 맨 위 약속 (이 PC 의 실제 드라이브 · 시험 폴더). void main() { test('이 기기의 저장 장치는 비지 않고, 경로가 든 맨 위를 고른다 (가장 긴 장치 · 대소문자 무시)', () async { final v = await localVolumes(); expect(v, isNotEmpty); final tmp = Directory.systemTemp.createTempSync('jj_vol_'); addTearDown(() => tmp.deleteSync(recursive: true)); final local = [...v, (tmp.path, 'tmp')]; expect(volumeOf(p.join(tmp.path, 'a', 'b'), local), tmp.path); if (Platform.isWindows) { expect(volumeOf(p.join(tmp.path, 'A').toUpperCase(), local).toLowerCase(), tmp.path.toLowerCase()); expect(volumeOf(r'\\nas\share\x', local), r'\\nas\share'); } }); test('다시 열 수 있는지: 있는 폴더 true · 없는 폴더 false', () async { final tmp = Directory.systemTemp.createTempSync('jj_vol_'); addTearDown(() => tmp.deleteSync(recursive: true)); expect(await reachableAsync(tmp.path), isTrue); expect(await reachableAsync(p.join(tmp.path, 'none')), isFalse); }); test('드라이브 상태: 확인 중 null → 결과 · 예외는 false · 닫은 뒤 알리지 않음', () async { final s = DriveStatus(); final seen = []; s.addListener(() => seen.add(s.ok['X:'])); final gate = Completer(); final f = s.check('X:', (_) => gate.future); expect(s.ok['X:'], isNull); gate.complete(true); expect(await f, isTrue); expect(seen, [null, true]); expect(await s.check('Y:', (_) async => throw const FileSystemException('x')), isFalse); final late = Completer(); final g = s.check('Z:', (_) => late.future); s.dispose(); late.complete(true); expect(await g, isTrue, reason: '닫은 뒤 끝나도 던지지 않음'); }); }