From 54b14b4cf89f98bab02307b77a678468a0d941da Mon Sep 17 00:00:00 2001 From: Midori Date: Wed, 9 Aug 2023 00:39:32 +0900 Subject: [PATCH] Add tests --- .../integration_test/integration_test.dart | 17 ++++++++---- example/integration_test/test_app.dart | 26 ++++++++++++------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/example/integration_test/integration_test.dart b/example/integration_test/integration_test.dart index 2cf49d95..eca734a2 100644 --- a/example/integration_test/integration_test.dart +++ b/example/integration_test/integration_test.dart @@ -15,11 +15,18 @@ void main() { Platform.isAndroid ? group('Android Test', () { - execute('hasAccess()'); - execute('requestAccess()'); - execute('putImage()'); - execute('putImageBytes()'); - execute('putVideo()'); + bool toAlbum = false; + for (var i = 0; i < 2; i++) { + if (i == 1) { + execute('Toggle toAlbum'); + toAlbum = true; + } + execute('hasAccess(toAlbum: $toAlbum)'); + execute('requestAccess(toAlbum: $toAlbum)'); + execute('putImage(toAlbum: $toAlbum)'); + execute('putImageBytes(toAlbum: $toAlbum)'); + execute('putVideo(toAlbum: $toAlbum)'); + } execute('open()'); }) : group('iOS Test', () { diff --git a/example/integration_test/test_app.dart b/example/integration_test/test_app.dart index 3a27133e..a61be3af 100644 --- a/example/integration_test/test_app.dart +++ b/example/integration_test/test_app.dart @@ -5,6 +5,7 @@ import 'package:flutter/services.dart'; import 'package:gal/gal.dart'; var logger = Logger(); +bool toAlbum = false; void main() => runApp(const App()); @@ -27,20 +28,26 @@ class _AppState extends State { : SingleChildScrollView( child: Column( children: [ + Text('toAlbum: $toAlbum'), + buildButton( + onPressed: () async => toAlbum = !toAlbum, + label: 'Toggle toAlbum', + ), buildButton( onPressed: () async => Gal.hasAccess(), - label: 'hasAccess()', + label: 'hasAccess(toAlbum: $toAlbum)', ), buildButton( onPressed: () async => Gal.requestAccess(), - label: 'requestAccess()', + label: 'requestAccess(toAlbum: $toAlbum)', ), buildButton( onPressed: () async { final path = await getFilePath('assets/done.jpg'); - await Gal.putImage(path); + await Gal.putImage(path, + album: toAlbum ? 'Album' : null); }, - label: 'putImage()', + label: 'putImage(toAlbum: $toAlbum)', ), buildButton( onPressed: () async { @@ -48,17 +55,18 @@ class _AppState extends State { await rootBundle.load('assets/done.jpg'); final uint8List = byteData.buffer.asUint8List( byteData.offsetInBytes, byteData.lengthInBytes); - await Gal.putImageBytes( - Uint8List.fromList(uint8List)); + await Gal.putImageBytes(Uint8List.fromList(uint8List), + album: toAlbum ? 'Album' : null); }, - label: 'putImageBytes()', + label: 'putImageBytes(toAlbum: $toAlbum)', ), buildButton( onPressed: () async { final path = await getFilePath('assets/done.mp4'); - await Gal.putVideo(path); + await Gal.putVideo(path, + album: toAlbum ? 'Album' : null); }, - label: 'putVideo()', + label: 'putVideo(toAlbum: $toAlbum)', ), buildButton( onPressed: () async => Gal.open(),