diff --git a/test/providers/gallery_provider_test.dart b/test/providers/gallery_provider_test.dart index dcc2a86..cfa1e64 100644 --- a/test/providers/gallery_provider_test.dart +++ b/test/providers/gallery_provider_test.dart @@ -126,14 +126,17 @@ }); test('ファイルが新しい順(更新日時降順)にソートされる', () async { - // 先に古いファイルを作成し,十分な時間差を設けてから新しいファイルを作成する - final olderPath = '${tempDir.path}/MiniTIAS_20260101_120000.png'; - final newerPath = - '${tempDir.path}/MiniTIAS_QM_20260101_120001.preview.jpg'; - await File(olderPath).create(); - // Windows NTFS の mtime 精度 (100ns) より十分大きい 1 秒以上待機 - await Future.delayed(const Duration(seconds: 2)); - await File(newerPath).create(); + // ソートキーは statSync().modified(更新日時).実スリープに頼らず + // 各ファイルの mtime を明示設定して決定的・即時に時間差を作る. + final olderFile = File('${tempDir.path}/MiniTIAS_20260101_120000.png'); + final newerFile = File( + '${tempDir.path}/MiniTIAS_QM_20260101_120001.preview.jpg', + ); + await olderFile.create(); + await newerFile.create(); + // NTFS 等の mtime 精度より十分大きい 1 秒差を明示的に与える + olderFile.setLastModifiedSync(DateTime(2026, 1, 1, 12, 0, 0)); + newerFile.setLastModifiedSync(DateTime(2026, 1, 1, 12, 0, 1)); await provider.loadImages();