Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
natsuk4ze committed Aug 8, 2023
1 parent 232b7cc commit 54b14b4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
17 changes: 12 additions & 5 deletions example/integration_test/integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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', () {
Expand Down
26 changes: 17 additions & 9 deletions example/integration_test/test_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -27,38 +28,45 @@ class _AppState extends State<App> {
: 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 {
final byteData =
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(),
Expand Down

0 comments on commit 54b14b4

Please sign in to comment.