From e29183fd2b0bf98a4c861f892e62dfac49f9eeb0 Mon Sep 17 00:00:00 2001 From: Santo Shakil Date: Thu, 23 Jul 2026 03:41:34 +0600 Subject: [PATCH] test(mobile): seed jni fixtures lazily and note the api 28 storage grant --- mobile/integration_test/native_jni_test.dart | 21 ++++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/mobile/integration_test/native_jni_test.dart b/mobile/integration_test/native_jni_test.dart index 73fdbc8c30..d7072261c9 100644 --- a/mobile/integration_test/native_jni_test.dart +++ b/mobile/integration_test/native_jni_test.dart @@ -62,10 +62,15 @@ void main() { String? assetId; String? orientedAssetId; + // Seeding writes to MediaStore; on API < 29 the harness must grant + // WRITE_EXTERNAL_STORAGE first (adb shell pm grant), or saveImage throws. + // Seeded lazily so tests that need no fixture run regardless. + Future seededAssetId() async { + return assetId ??= (await PhotoManager.editor.saveImage(fixture, filename: 'immich_jni_fixture.avif')).id; + } + setUpAll(() async { await PhotoManager.setIgnorePermissionCheck(true); - final entity = await PhotoManager.editor.saveImage(fixture, filename: 'immich_jni_fixture.avif'); - assetId = entity.id; }); tearDownAll(() async { @@ -96,7 +101,7 @@ void main() { test('encoded image buffer roundtrip', () async { final res = await api.requestImage( - assetId!, + await seededAssetId(), requestId: 900001, width: 0, height: 0, @@ -111,16 +116,10 @@ void main() { }); test('10-bit decode runs NativeImage.convert1010102', () async { + final id = await seededAssetId(); final Map? res; try { - res = await api.requestImage( - assetId!, - requestId: 900002, - width: 0, - height: 0, - isVideo: false, - preferEncoded: false, - ); + res = await api.requestImage(id, requestId: 900002, width: 0, height: 0, isVideo: false, preferEncoded: false); } on PlatformException catch (e) { markTestSkipped('device cannot decode the 10-bit AVIF fixture: ${e.message}'); return;