From d66f13b27650fd46f7e6a14898bf7ebc01f9a1f3 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Sat, 22 Aug 2020 16:59:52 +0800 Subject: [PATCH] rename collection to album --- test/photo_gallery_test.dart | 16 +++++++--------- test/utils/generator.dart | 18 +++++++++--------- test/utils/mock_handler.dart | 8 +++----- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/test/photo_gallery_test.dart b/test/photo_gallery_test.dart index 2fd5027..ac2164a 100644 --- a/test/photo_gallery_test.dart +++ b/test/photo_gallery_test.dart @@ -23,7 +23,7 @@ void main() { test('list albums', () async { MediumType mediumType = MediumType.image; var result = await PhotoGallery.listAlbums(mediumType: mediumType); - var expected = Generator.generateCollections(mediumType: mediumType); + var expected = Generator.generateAlbums(mediumType: mediumType); expect(result, expected); }); @@ -31,13 +31,11 @@ void main() { MediumType mediumType = MediumType.image; int skip = 0; int take = 1; - List collections = - await PhotoGallery.listAlbums(mediumType: mediumType); - Album allCollection = - collections.firstWhere((element) => element.isAllAlbum); - MediaPage result = await allCollection.listMedia(skip: skip, take: take); + List albums = await PhotoGallery.listAlbums(mediumType: mediumType); + Album allAlbum = albums.firstWhere((element) => element.isAllAlbum); + MediaPage result = await allAlbum.listMedia(skip: skip, take: take); MediaPage expected = Generator.generateMediaPage( - collection: allCollection, + album: allAlbum, mediumType: mediumType, skip: skip, take: take, @@ -67,10 +65,10 @@ void main() { expect(result, expected); }); - test('get collection thumbnail', () async { + test('get album thumbnail', () async { String albumId = "__ALL__"; List result = await PhotoGallery.getAlbumThumbnail(albumId: albumId); - List expected = Generator.generateMockCollectionThumbnail(albumId: albumId); + List expected = Generator.generateMockAlbumThumbnail(albumId: albumId); expect(result, expected); }); diff --git a/test/utils/generator.dart b/test/utils/generator.dart index 7f2c261..cfe1024 100644 --- a/test/utils/generator.dart +++ b/test/utils/generator.dart @@ -3,7 +3,7 @@ import 'dart:io'; import 'package:photo_gallery/photo_gallery.dart'; class Generator { - static dynamic generateCollectionsJson({MediumType mediumType}) { + static dynamic generateAlbumsJson({MediumType mediumType}) { mediumType = mediumType ?? MediumType.image; return [ { @@ -15,14 +15,14 @@ class Generator { { "id": "AlbumId", "mediumType": mediumTypeToJson(mediumType), - "name": "CollectionName", + "name": "AlbumName", "count": 5, } ]; } - static List generateCollections({MediumType mediumType}) { - return Generator.generateCollectionsJson(mediumType: mediumType) + static List generateAlbums({MediumType mediumType}) { + return Generator.generateAlbumsJson(mediumType: mediumType) .map((x) => Album.fromJson(x)) .toList(); } @@ -66,19 +66,19 @@ class Generator { } static MediaPage generateMediaPage({ - Album collection, + Album album, MediumType mediumType, int skip, int take, }) { dynamic json = generateMediaPageJson( - albumId: collection.id, + albumId: album.id, mediumType: mediumType, - total: collection.count, + total: album.count, skip: skip, take: take, ); - return MediaPage.fromJson(collection, mediumType, json); + return MediaPage.fromJson(album, json); } static Medium generateMedia({ @@ -97,7 +97,7 @@ class Generator { return [1, 2, 3, 4, 5, 6, 7, 8, 9]; } - static List generateMockCollectionThumbnail({ + static List generateMockAlbumThumbnail({ String albumId, }) { return [1, 2, 3, 4, 5, 6, 7, 8, 9]; diff --git a/test/utils/mock_handler.dart b/test/utils/mock_handler.dart index fc5ddb2..f6ff959 100644 --- a/test/utils/mock_handler.dart +++ b/test/utils/mock_handler.dart @@ -7,9 +7,8 @@ import 'generator.dart'; Future mockMethodCallHandler(MethodCall call) async { if (call.method == "listAlbums") { MediumType mediumType = jsonToMediumType(call.arguments['mediumType']); - dynamic collections = - Generator.generateCollectionsJson(mediumType: mediumType); - return collections; + dynamic albums = Generator.generateAlbumsJson(mediumType: mediumType); + return albums; } else if (call.method == "listMedia") { String albumId = call.arguments['albumId']; MediumType mediumType = jsonToMediumType(call.arguments['mediumType']); @@ -38,8 +37,7 @@ Future mockMethodCallHandler(MethodCall call) async { return thumbnail; } else if (call.method == "getAlbumThumbnail") { String albumId = call.arguments['albumId']; - dynamic thumbnail = - Generator.generateMockCollectionThumbnail(albumId: albumId); + dynamic thumbnail = Generator.generateMockAlbumThumbnail(albumId: albumId); return thumbnail; } else if (call.method == "getFile") { String mediumId = call.arguments['mediumId'];