From 682cda1dea2ff1aec9c2106a8d5b4cc1a5d8ca2f Mon Sep 17 00:00:00 2001 From: Yu / Midori Date: Wed, 31 Jul 2024 21:22:17 +0900 Subject: [PATCH] refactor test --- .../integration_test/integration_test.dart | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/example/integration_test/integration_test.dart b/example/integration_test/integration_test.dart index ee552331..3ab81b3e 100644 --- a/example/integration_test/integration_test.dart +++ b/example/integration_test/integration_test.dart @@ -8,8 +8,12 @@ import 'package:gal/gal.dart'; /// Integration_test is required to test native code, /// but it is not necessary to build the widget. Future main() async { - for (var i = 0; i < TestCase.values.length; i++) { - final testCase = TestCase.values[i]; + final testCases = [ + for (final isSavedToAlbum in [true, false]) + TestCase(isSavedToAlbum: isSavedToAlbum), + ]; + + for (final testCase in testCases) { final toAlbum = testCase.toAlbum; final album = testCase.album; @@ -72,17 +76,10 @@ Future getBytesData(String path) async { return Uint8List.fromList(uint8List); } -enum TestCase { - saveToAlbum, - notSaveToAlbum; - - bool get toAlbum => switch (this) { - saveToAlbum => true, - notSaveToAlbum => false, - }; +class TestCase { + const TestCase({required this.isSavedToAlbum}); + final bool isSavedToAlbum; - String? get album => switch (this) { - saveToAlbum => 'toAlbum', - notSaveToAlbum => null, - }; + bool get toAlbum => isSavedToAlbum; + String? get album => isSavedToAlbum ? 'album' : null; }