@@ -63,14 +63,14 @@ void main() {
|
|||||||
expect(albums.first.name, 'vacation');
|
expect(albums.first.name, 'vacation');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should generate consistent id from directory name', () async {
|
test('should generate consistent id from directory path', () async {
|
||||||
await Directory(p.join(tempDir.path, 'test_album')).create();
|
await Directory(p.join(tempDir.path, 'test_album')).create();
|
||||||
|
|
||||||
final albums1 = await repository.getAllAlbums();
|
final albums1 = await repository.getAllAlbums();
|
||||||
final albums2 = await repository.getAllAlbums();
|
final albums2 = await repository.getAllAlbums();
|
||||||
|
|
||||||
expect(albums1.first.id, albums2.first.id);
|
expect(albums1.first.id, albums2.first.id);
|
||||||
expect(albums1.first.id, 'test_album'.hashCode);
|
expect(albums1.first.id, p.join(tempDir.path, 'test_album').hashCode);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should set createdAt and updatedAt from directory stat', () async {
|
test('should set createdAt and updatedAt from directory stat', () async {
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ void main() {
|
|||||||
'should return empty list when album directory does not exist',
|
'should return empty list when album directory does not exist',
|
||||||
() async {
|
() async {
|
||||||
final photos = await repository.getPhotosByAlbumId(
|
final photos = await repository.getPhotosByAlbumId(
|
||||||
'nonexistent'.hashCode,
|
p.join(tempDir.path, 'nonexistent').hashCode,
|
||||||
);
|
);
|
||||||
expect(photos, isEmpty);
|
expect(photos, isEmpty);
|
||||||
},
|
},
|
||||||
@@ -296,7 +296,7 @@ void main() {
|
|||||||
_createTestPng(albumDir, 'photo1.png', width: 100, height: 200);
|
_createTestPng(albumDir, 'photo1.png', width: 100, height: 200);
|
||||||
_createTestGif(albumDir, 'photo2.gif', width: 150, height: 250);
|
_createTestGif(albumDir, 'photo2.gif', width: 150, height: 250);
|
||||||
|
|
||||||
final albumId = 'my_album'.hashCode;
|
final albumId = p.join(tempDir.path, 'my_album').hashCode;
|
||||||
final photos = await repository.getPhotosByAlbumId(albumId);
|
final photos = await repository.getPhotosByAlbumId(albumId);
|
||||||
|
|
||||||
expect(photos.length, 2);
|
expect(photos.length, 2);
|
||||||
@@ -312,7 +312,7 @@ void main() {
|
|||||||
File(p.join(albumDir.path, 'document.txt')).writeAsString('not an image');
|
File(p.join(albumDir.path, 'document.txt')).writeAsString('not an image');
|
||||||
File(p.join(albumDir.path, 'readme.md')).writeAsString('# Readme');
|
File(p.join(albumDir.path, 'readme.md')).writeAsString('# Readme');
|
||||||
|
|
||||||
final albumId = 'mixed'.hashCode;
|
final albumId = p.join(tempDir.path, 'mixed').hashCode;
|
||||||
final photos = await repository.getPhotosByAlbumId(albumId);
|
final photos = await repository.getPhotosByAlbumId(albumId);
|
||||||
|
|
||||||
expect(photos.length, 1);
|
expect(photos.length, 1);
|
||||||
@@ -325,7 +325,7 @@ void main() {
|
|||||||
).create();
|
).create();
|
||||||
_createTestPng(albumDir, 'test.png', width: 640, height: 480);
|
_createTestPng(albumDir, 'test.png', width: 640, height: 480);
|
||||||
|
|
||||||
final albumId = 'png_test'.hashCode;
|
final albumId = p.join(tempDir.path, 'png_test').hashCode;
|
||||||
final photos = await repository.getPhotosByAlbumId(albumId);
|
final photos = await repository.getPhotosByAlbumId(albumId);
|
||||||
|
|
||||||
expect(photos.length, 1);
|
expect(photos.length, 1);
|
||||||
@@ -340,7 +340,7 @@ void main() {
|
|||||||
).create();
|
).create();
|
||||||
_createTestGif(albumDir, 'test.gif', width: 320, height: 240);
|
_createTestGif(albumDir, 'test.gif', width: 320, height: 240);
|
||||||
|
|
||||||
final albumId = 'gif_test'.hashCode;
|
final albumId = p.join(tempDir.path, 'gif_test').hashCode;
|
||||||
final photos = await repository.getPhotosByAlbumId(albumId);
|
final photos = await repository.getPhotosByAlbumId(albumId);
|
||||||
|
|
||||||
expect(photos.length, 1);
|
expect(photos.length, 1);
|
||||||
@@ -355,7 +355,7 @@ void main() {
|
|||||||
).create();
|
).create();
|
||||||
_createTestBmp(albumDir, 'test.bmp', width: 800, height: 600);
|
_createTestBmp(albumDir, 'test.bmp', width: 800, height: 600);
|
||||||
|
|
||||||
final albumId = 'bmp_test'.hashCode;
|
final albumId = p.join(tempDir.path, 'bmp_test').hashCode;
|
||||||
final photos = await repository.getPhotosByAlbumId(albumId);
|
final photos = await repository.getPhotosByAlbumId(albumId);
|
||||||
|
|
||||||
expect(photos.length, 1);
|
expect(photos.length, 1);
|
||||||
@@ -370,7 +370,7 @@ void main() {
|
|||||||
).create();
|
).create();
|
||||||
_createTestWebpVp8(albumDir, 'test.webp', width: 1920, height: 1080);
|
_createTestWebpVp8(albumDir, 'test.webp', width: 1920, height: 1080);
|
||||||
|
|
||||||
final albumId = 'webp_test'.hashCode;
|
final albumId = p.join(tempDir.path, 'webp_test').hashCode;
|
||||||
final photos = await repository.getPhotosByAlbumId(albumId);
|
final photos = await repository.getPhotosByAlbumId(albumId);
|
||||||
|
|
||||||
expect(photos.length, 1);
|
expect(photos.length, 1);
|
||||||
@@ -387,7 +387,7 @@ void main() {
|
|||||||
p.join(albumDir.path, 'clip.mp4'),
|
p.join(albumDir.path, 'clip.mp4'),
|
||||||
).writeAsBytesSync(List.filled(100, 0));
|
).writeAsBytesSync(List.filled(100, 0));
|
||||||
|
|
||||||
final albumId = 'video_test'.hashCode;
|
final albumId = p.join(tempDir.path, 'video_test').hashCode;
|
||||||
final photos = await repository.getPhotosByAlbumId(albumId);
|
final photos = await repository.getPhotosByAlbumId(albumId);
|
||||||
|
|
||||||
expect(photos.length, 1);
|
expect(photos.length, 1);
|
||||||
@@ -404,7 +404,7 @@ void main() {
|
|||||||
p.join(albumDir.path, 'movie.mp4'),
|
p.join(albumDir.path, 'movie.mp4'),
|
||||||
).writeAsBytesSync(List.filled(100, 0));
|
).writeAsBytesSync(List.filled(100, 0));
|
||||||
|
|
||||||
final albumId = 'video_album'.hashCode;
|
final albumId = p.join(tempDir.path, 'video_album').hashCode;
|
||||||
final photos = await repository.getPhotosByAlbumId(albumId);
|
final photos = await repository.getPhotosByAlbumId(albumId);
|
||||||
|
|
||||||
expect(photos.length, 1);
|
expect(photos.length, 1);
|
||||||
@@ -417,7 +417,7 @@ void main() {
|
|||||||
).create();
|
).create();
|
||||||
_createTestPng(albumDir, 'test.png', width: 100, height: 100);
|
_createTestPng(albumDir, 'test.png', width: 100, height: 100);
|
||||||
|
|
||||||
final albumId = 'meta_test'.hashCode;
|
final albumId = p.join(tempDir.path, 'meta_test').hashCode;
|
||||||
final photos = await repository.getPhotosByAlbumId(albumId);
|
final photos = await repository.getPhotosByAlbumId(albumId);
|
||||||
|
|
||||||
expect(photos.first.albumId, albumId);
|
expect(photos.first.albumId, albumId);
|
||||||
@@ -446,7 +446,7 @@ void main() {
|
|||||||
_createTestPng(albumDir, 'unique.png', width: 50, height: 50);
|
_createTestPng(albumDir, 'unique.png', width: 50, height: 50);
|
||||||
|
|
||||||
final allPhotos = await repository.getPhotosByAlbumId(
|
final allPhotos = await repository.getPhotosByAlbumId(
|
||||||
'find_album'.hashCode,
|
p.join(tempDir.path, 'find_album').hashCode,
|
||||||
);
|
);
|
||||||
final targetId = allPhotos.first.id;
|
final targetId = allPhotos.first.id;
|
||||||
|
|
||||||
@@ -465,7 +465,7 @@ void main() {
|
|||||||
_createTestBmp(albumDir, 'dims.bmp', width: 1024, height: 768);
|
_createTestBmp(albumDir, 'dims.bmp', width: 1024, height: 768);
|
||||||
|
|
||||||
final allPhotos = await repository.getPhotosByAlbumId(
|
final allPhotos = await repository.getPhotosByAlbumId(
|
||||||
'dims_album'.hashCode,
|
p.join(tempDir.path, 'dims_album').hashCode,
|
||||||
);
|
);
|
||||||
final targetId = allPhotos.first.id;
|
final targetId = allPhotos.first.id;
|
||||||
|
|
||||||
@@ -485,7 +485,7 @@ void main() {
|
|||||||
File(p.join(albumDir.path, 'test.jpg')).writeAsBytesSync([0xFF, 0xD8]);
|
File(p.join(albumDir.path, 'test.jpg')).writeAsBytesSync([0xFF, 0xD8]);
|
||||||
File(p.join(albumDir.path, 'test2.jpeg')).writeAsBytesSync([0xFF, 0xD8]);
|
File(p.join(albumDir.path, 'test2.jpeg')).writeAsBytesSync([0xFF, 0xD8]);
|
||||||
|
|
||||||
final photos = await repository.getPhotosByAlbumId('mime_jpg'.hashCode);
|
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'mime_jpg').hashCode);
|
||||||
expect(photos.length, 2);
|
expect(photos.length, 2);
|
||||||
expect(photos.every((p) => p.mimeType == 'image/jpeg'), isTrue);
|
expect(photos.every((p) => p.mimeType == 'image/jpeg'), isTrue);
|
||||||
});
|
});
|
||||||
@@ -498,7 +498,7 @@ void main() {
|
|||||||
p.join(albumDir.path, 'test.png'),
|
p.join(albumDir.path, 'test.png'),
|
||||||
).writeAsBytesSync(List.filled(100, 0));
|
).writeAsBytesSync(List.filled(100, 0));
|
||||||
|
|
||||||
final photos = await repository.getPhotosByAlbumId('mime_png'.hashCode);
|
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'mime_png').hashCode);
|
||||||
expect(photos.first.mimeType, 'image/png');
|
expect(photos.first.mimeType, 'image/png');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -510,7 +510,7 @@ void main() {
|
|||||||
p.join(albumDir.path, 'test.webp'),
|
p.join(albumDir.path, 'test.webp'),
|
||||||
).writeAsBytesSync(List.filled(100, 0));
|
).writeAsBytesSync(List.filled(100, 0));
|
||||||
|
|
||||||
final photos = await repository.getPhotosByAlbumId('mime_webp'.hashCode);
|
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'mime_webp').hashCode);
|
||||||
expect(photos.first.mimeType, 'image/webp');
|
expect(photos.first.mimeType, 'image/webp');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -522,7 +522,7 @@ void main() {
|
|||||||
p.join(albumDir.path, 'test.mp4'),
|
p.join(albumDir.path, 'test.mp4'),
|
||||||
).writeAsBytesSync(List.filled(100, 0));
|
).writeAsBytesSync(List.filled(100, 0));
|
||||||
|
|
||||||
final photos = await repository.getPhotosByAlbumId('mime_mp4'.hashCode);
|
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'mime_mp4').hashCode);
|
||||||
expect(photos.first.mimeType, 'video/mp4');
|
expect(photos.first.mimeType, 'video/mp4');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -534,7 +534,7 @@ void main() {
|
|||||||
p.join(albumDir.path, 'test.avi'),
|
p.join(albumDir.path, 'test.avi'),
|
||||||
).writeAsBytesSync(List.filled(100, 0));
|
).writeAsBytesSync(List.filled(100, 0));
|
||||||
|
|
||||||
final photos = await repository.getPhotosByAlbumId('mime_avi'.hashCode);
|
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'mime_avi').hashCode);
|
||||||
expect(photos.first.mimeType, 'video/avi');
|
expect(photos.first.mimeType, 'video/avi');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -546,7 +546,7 @@ void main() {
|
|||||||
p.join(albumDir.path, 'test.mov'),
|
p.join(albumDir.path, 'test.mov'),
|
||||||
).writeAsBytesSync(List.filled(100, 0));
|
).writeAsBytesSync(List.filled(100, 0));
|
||||||
|
|
||||||
final photos = await repository.getPhotosByAlbumId('mime_mov'.hashCode);
|
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'mime_mov').hashCode);
|
||||||
expect(photos.first.mimeType, 'video/quicktime');
|
expect(photos.first.mimeType, 'video/quicktime');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -558,7 +558,7 @@ void main() {
|
|||||||
p.join(albumDir.path, 'test.mkv'),
|
p.join(albumDir.path, 'test.mkv'),
|
||||||
).writeAsBytesSync(List.filled(100, 0));
|
).writeAsBytesSync(List.filled(100, 0));
|
||||||
|
|
||||||
final photos = await repository.getPhotosByAlbumId('mime_mkv'.hashCode);
|
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'mime_mkv').hashCode);
|
||||||
expect(photos.first.mimeType, 'video/x-matroska');
|
expect(photos.first.mimeType, 'video/x-matroska');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -576,7 +576,7 @@ void main() {
|
|||||||
).writeAsBytesSync(List.filled(10, 0));
|
).writeAsBytesSync(List.filled(10, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
final photos = await repository.getPhotosByAlbumId('ext_test'.hashCode);
|
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'ext_test').hashCode);
|
||||||
expect(photos.length, extensions.length);
|
expect(photos.length, extensions.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -592,7 +592,7 @@ void main() {
|
|||||||
).writeAsBytesSync(List.filled(10, 0));
|
).writeAsBytesSync(List.filled(10, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
final photos = await repository.getPhotosByAlbumId('ext_video'.hashCode);
|
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'ext_video').hashCode);
|
||||||
expect(photos.length, extensions.length);
|
expect(photos.length, extensions.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -605,7 +605,7 @@ void main() {
|
|||||||
File(p.join(albumDir.path, 'skip.pdf')).writeAsBytesSync([]);
|
File(p.join(albumDir.path, 'skip.pdf')).writeAsBytesSync([]);
|
||||||
File(p.join(albumDir.path, 'skip.exe')).writeAsBytesSync([]);
|
File(p.join(albumDir.path, 'skip.exe')).writeAsBytesSync([]);
|
||||||
|
|
||||||
final photos = await repository.getPhotosByAlbumId('ext_ignore'.hashCode);
|
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'ext_ignore').hashCode);
|
||||||
expect(photos.length, 1);
|
expect(photos.length, 1);
|
||||||
expect(photos.first.fileName, 'valid.png');
|
expect(photos.first.fileName, 'valid.png');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ void main() {
|
|||||||
sourceFile.writeAsBytesSync(List.filled(100, 0));
|
sourceFile.writeAsBytesSync(List.filled(100, 0));
|
||||||
|
|
||||||
// Pre-create the expected cached file
|
// Pre-create the expected cached file
|
||||||
final baseName = p.basename(sourceFile.path).hashCode.toString();
|
final baseName =sourceFile.path.hashCode.toString();
|
||||||
final cachedFile = File(
|
final cachedFile = File(
|
||||||
p.join(cacheDir.path, 'preview', '${baseName}_100x100.webp'),
|
p.join(cacheDir.path, 'preview', '${baseName}_100x100.webp'),
|
||||||
);
|
);
|
||||||
@@ -117,7 +117,7 @@ void main() {
|
|||||||
sourceFile.writeAsBytesSync(List.filled(100, 0));
|
sourceFile.writeAsBytesSync(List.filled(100, 0));
|
||||||
|
|
||||||
// Create the expected cached file
|
// Create the expected cached file
|
||||||
final baseName = p.basename(sourceFile.path).hashCode.toString();
|
final baseName = sourceFile.path.hashCode.toString();
|
||||||
final cachedFile = File(
|
final cachedFile = File(
|
||||||
p.join(cacheDir.path, 'preview', '${baseName}_200x100.webp'),
|
p.join(cacheDir.path, 'preview', '${baseName}_200x100.webp'),
|
||||||
);
|
);
|
||||||
@@ -141,7 +141,7 @@ void main() {
|
|||||||
sourceFile.writeAsBytesSync(List.filled(100, 0));
|
sourceFile.writeAsBytesSync(List.filled(100, 0));
|
||||||
|
|
||||||
// Create cached file for 400x300
|
// Create cached file for 400x300
|
||||||
final baseName = p.basename(sourceFile.path).hashCode.toString();
|
final baseName = sourceFile.path.hashCode.toString();
|
||||||
final cachedFile = File(
|
final cachedFile = File(
|
||||||
p.join(cacheDir.path, 'preview', '${baseName}_400x300.webp'),
|
p.join(cacheDir.path, 'preview', '${baseName}_400x300.webp'),
|
||||||
);
|
);
|
||||||
@@ -159,7 +159,7 @@ void main() {
|
|||||||
final sourceFile = File(p.join(tempDir.path, 'width_only.jpg'));
|
final sourceFile = File(p.join(tempDir.path, 'width_only.jpg'));
|
||||||
sourceFile.writeAsBytesSync(List.filled(100, 0));
|
sourceFile.writeAsBytesSync(List.filled(100, 0));
|
||||||
|
|
||||||
final baseName = p.basename(sourceFile.path).hashCode.toString();
|
final baseName = sourceFile.path.hashCode.toString();
|
||||||
final cachedFile = File(
|
final cachedFile = File(
|
||||||
p.join(cacheDir.path, 'preview', '${baseName}_500x0.webp'),
|
p.join(cacheDir.path, 'preview', '${baseName}_500x0.webp'),
|
||||||
);
|
);
|
||||||
@@ -176,7 +176,7 @@ void main() {
|
|||||||
final sourceFile = File(p.join(tempDir.path, 'height_only.jpg'));
|
final sourceFile = File(p.join(tempDir.path, 'height_only.jpg'));
|
||||||
sourceFile.writeAsBytesSync(List.filled(100, 0));
|
sourceFile.writeAsBytesSync(List.filled(100, 0));
|
||||||
|
|
||||||
final baseName = p.basename(sourceFile.path).hashCode.toString();
|
final baseName = sourceFile.path.hashCode.toString();
|
||||||
final cachedFile = File(
|
final cachedFile = File(
|
||||||
p.join(cacheDir.path, 'preview', '${baseName}_0x600.webp'),
|
p.join(cacheDir.path, 'preview', '${baseName}_0x600.webp'),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user