diff --git a/android_jni/avifandroidjni/src/androidTest/java/org/aomedia/avif/android/AvifDecoderTest.java b/android_jni/avifandroidjni/src/androidTest/java/org/aomedia/avif/android/AvifDecoderTest.java index 4b27fefe6a..14ff69bba0 100644 --- a/android_jni/avifandroidjni/src/androidTest/java/org/aomedia/avif/android/AvifDecoderTest.java +++ b/android_jni/avifandroidjni/src/androidTest/java/org/aomedia/avif/android/AvifDecoderTest.java @@ -95,7 +95,7 @@ public ByteBuffer getBuffer() throws IOException { private static final int AVIF_RESULT_OK = 0; - private static final float[] SCALE_FACTORS = {0.5f, 1.3f, 2.0f}; + private static final float[] SCALE_FACTORS = {0.5f, 1.3f}; private static final Image[] IMAGES = { // Parameter ordering for still images: directory, filename, width, height, depth, alphaPresent, @@ -160,24 +160,27 @@ public void testDecodeUtilityClass() throws IOException { assertThat(bitmap).isNotNull(); assertThat(AvifDecoder.decode(buffer, buffer.remaining(), bitmap)).isTrue(); - // Test scaling. - for (float scale_factor : SCALE_FACTORS) { - // Scale both width and height. - bitmap = - Bitmap.createBitmap( - (int) (info.width * scale_factor), (int) (info.height * scale_factor), config); - assertThat(bitmap).isNotNull(); - assertThat(AvifDecoder.decode(buffer, buffer.remaining(), bitmap)).isTrue(); + // Test scaling. These tests can be a bit slow on emulators, so only run them when config is + // ARGB_8888. + if (config == Config.ARGB_8888) { + for (float scale_factor : SCALE_FACTORS) { + // Scale both width and height. + bitmap = + Bitmap.createBitmap( + (int) (info.width * scale_factor), (int) (info.height * scale_factor), config); + assertThat(bitmap).isNotNull(); + assertThat(AvifDecoder.decode(buffer, buffer.remaining(), bitmap)).isTrue(); - // Scale width only. - bitmap = Bitmap.createBitmap((int) (info.width * scale_factor), info.height, config); - assertThat(bitmap).isNotNull(); - assertThat(AvifDecoder.decode(buffer, buffer.remaining(), bitmap)).isTrue(); + // Scale width only. + bitmap = Bitmap.createBitmap((int) (info.width * scale_factor), info.height, config); + assertThat(bitmap).isNotNull(); + assertThat(AvifDecoder.decode(buffer, buffer.remaining(), bitmap)).isTrue(); - // Scale height only. - bitmap = Bitmap.createBitmap(info.width, (int) (info.height * scale_factor), config); - assertThat(bitmap).isNotNull(); - assertThat(AvifDecoder.decode(buffer, buffer.remaining(), bitmap)).isTrue(); + // Scale height only. + bitmap = Bitmap.createBitmap(info.width, (int) (info.height * scale_factor), config); + assertThat(bitmap).isNotNull(); + assertThat(AvifDecoder.decode(buffer, buffer.remaining(), bitmap)).isTrue(); + } } } @@ -225,8 +228,9 @@ public void testDecodeRegularClass() throws IOException { assertThat(decoder.nthFrame(image.frameCount, bitmap)).isNotEqualTo(AVIF_RESULT_OK); // The following block of code that tests scaling assumes that the animated image under test - // has at least 10 frames. - if (image.frameCount >= 10) { + // has at least 7 frames. These tests can be a bit slow on emulators, so only run them when + // config is ARGB_8888. + if (image.frameCount >= 7 && config == Config.ARGB_8888) { // Reset the decoder to the first frame. assertThat(decoder.nthFrame(0, bitmap)).isEqualTo(AVIF_RESULT_OK); for (float scale_factor : SCALE_FACTORS) {