diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/ContrastPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/ContrastPixelTest.java index 45747428b6..d54cb2209a 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/ContrastPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/ContrastPixelTest.java @@ -17,13 +17,13 @@ package androidx.media3.effect; import static androidx.media3.common.util.Assertions.checkNotNull; -import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; -import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapWithSolidColor; -import static androidx.media3.effect.BitmapTestUtil.createGlTextureFromBitmap; -import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static androidx.media3.effect.BitmapTestUtil.readBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createArgb8888BitmapWithSolidColor; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createGlTextureFromBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.test.utils.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.common.truth.Truth.assertThat; @@ -36,6 +36,7 @@ import android.opengl.EGLSurface; import androidx.media3.common.FrameProcessingException; import androidx.media3.common.util.GlUtil; import androidx.media3.common.util.Size; +import androidx.media3.test.utils.BitmapPixelTestUtil; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.junit.After; @@ -48,8 +49,8 @@ import org.junit.runner.RunWith; * *

Expected images are taken from an emulator, so tests on different emulators or physical * devices may fail. To test on other devices, please increase the {@link - * BitmapTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output bitmaps - * as recommended in {@link GlEffectsFrameProcessorPixelTest}. + * BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output + * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}. */ @RunWith(AndroidJUnit4.class) public class ContrastPixelTest { diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/CropPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/CropPixelTest.java index dd9ab5becd..61b6830892 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/CropPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/CropPixelTest.java @@ -16,12 +16,12 @@ package androidx.media3.effect; import static androidx.media3.common.util.Assertions.checkNotNull; -import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; -import static androidx.media3.effect.BitmapTestUtil.createGlTextureFromBitmap; -import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static androidx.media3.effect.BitmapTestUtil.readBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createGlTextureFromBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.test.utils.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.common.truth.Truth.assertThat; @@ -33,6 +33,7 @@ import android.opengl.EGLSurface; import androidx.media3.common.FrameProcessingException; import androidx.media3.common.util.GlUtil; import androidx.media3.common.util.Size; +import androidx.media3.test.utils.BitmapPixelTestUtil; import androidx.test.ext.junit.runners.AndroidJUnit4; import java.io.IOException; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; @@ -46,8 +47,8 @@ import org.junit.runner.RunWith; * *

Expected images are taken from an emulator, so tests on different emulators or physical * devices may fail. To test on other devices, please increase the {@link - * BitmapTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output bitmaps - * as recommended in {@link GlEffectsFrameProcessorPixelTest}. + * BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output + * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}. */ @RunWith(AndroidJUnit4.class) public final class CropPixelTest { diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorPixelTest.java index 276ee2f608..c323e0c86b 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorPixelTest.java @@ -17,11 +17,11 @@ package androidx.media3.effect; import static androidx.media3.common.util.Assertions.checkNotNull; import static androidx.media3.common.util.Assertions.checkStateNotNull; -import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromRgba8888Image; -import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static androidx.media3.effect.BitmapTestUtil.readBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createArgb8888BitmapFromRgba8888Image; +import static androidx.media3.test.utils.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.test.utils.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.common.truth.Truth.assertThat; import static java.util.Arrays.asList; @@ -42,6 +42,7 @@ import androidx.media3.common.FrameProcessingException; import androidx.media3.common.FrameProcessor; import androidx.media3.common.SurfaceInfo; import androidx.media3.common.util.Size; +import androidx.media3.test.utils.BitmapPixelTestUtil; import androidx.media3.test.utils.DecodeOneFrameUtil; import androidx.test.ext.junit.runners.AndroidJUnit4; import com.google.common.collect.ImmutableList; @@ -59,7 +60,7 @@ import org.junit.runner.RunWith; * *

Expected images are taken from an emulator, so tests on different emulators or physical * devices may fail. To test on other devices, please increase the {@link - * BitmapTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output + * BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output * bitmaps. */ @RunWith(AndroidJUnit4.class) @@ -468,8 +469,8 @@ public final class GlEffectsFrameProcessorPixelTest { assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } - // TODO(b/227624622): Add a test for HDR input after BitmapTestUtil can read HDR bitmaps, using - // GlEffectWrapper to ensure usage of intermediate textures. + // TODO(b/227624622): Add a test for HDR input after BitmapPixelTestUtil can read HDR bitmaps, + // using GlEffectWrapper to ensure usage of intermediate textures. /** * Sets up and prepares the first frame from an input video, as well as the relevant test diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/HslAdjustmentPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/HslAdjustmentPixelTest.java index 1416c7f333..22d4824e48 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/HslAdjustmentPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/HslAdjustmentPixelTest.java @@ -16,13 +16,13 @@ package androidx.media3.effect; -import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; -import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapWithSolidColor; -import static androidx.media3.effect.BitmapTestUtil.createGlTextureFromBitmap; -import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static androidx.media3.effect.BitmapTestUtil.readBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createArgb8888BitmapWithSolidColor; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createGlTextureFromBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.test.utils.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.common.truth.Truth.assertThat; @@ -35,6 +35,7 @@ import android.opengl.EGLSurface; import androidx.media3.common.FrameProcessingException; import androidx.media3.common.util.GlUtil; import androidx.media3.common.util.Size; +import androidx.media3.test.utils.BitmapPixelTestUtil; import androidx.test.ext.junit.runners.AndroidJUnit4; import java.io.IOException; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; @@ -48,8 +49,8 @@ import org.junit.runner.RunWith; * *

Expected images are taken from an emulator, so tests on different emulators or physical * devices may fail. To test on other devices, please increase the {@link - * BitmapTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output bitmaps - * as recommended in {@link GlEffectsFrameProcessorPixelTest}. + * BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output + * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}. */ @RunWith(AndroidJUnit4.class) public final class HslAdjustmentPixelTest { diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixTextureProcessorPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixTextureProcessorPixelTest.java index d6e32d5699..161121ea94 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixTextureProcessorPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixTextureProcessorPixelTest.java @@ -15,12 +15,12 @@ */ package androidx.media3.effect; -import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; -import static androidx.media3.effect.BitmapTestUtil.createGlTextureFromBitmap; -import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static androidx.media3.effect.BitmapTestUtil.readBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createGlTextureFromBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.test.utils.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.common.truth.Truth.assertThat; @@ -32,6 +32,7 @@ import android.opengl.EGLDisplay; import android.opengl.EGLSurface; import androidx.media3.common.FrameProcessingException; import androidx.media3.common.util.GlUtil; +import androidx.media3.test.utils.BitmapPixelTestUtil; import androidx.test.ext.junit.runners.AndroidJUnit4; import java.io.IOException; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; @@ -45,8 +46,8 @@ import org.junit.runner.RunWith; * *

Expected images are taken from an emulator, so tests on different emulators or physical * devices may fail. To test on other devices, please increase the {@link - * BitmapTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output bitmaps - * as recommended in {@link GlEffectsFrameProcessorPixelTest}. + * BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output + * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}. */ @RunWith(AndroidJUnit4.class) public final class MatrixTextureProcessorPixelTest { @@ -179,5 +180,5 @@ public final class MatrixTextureProcessorPixelTest { assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } - // TODO(b/227624622): Add a test for HDR input after BitmapTestUtil can read HDR bitmaps. + // TODO(b/227624622): Add a test for HDR input after BitmapPixelTestUtil can read HDR bitmaps. } diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/OverlayTextureProcessorPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/OverlayTextureProcessorPixelTest.java index 8d337301b9..fff97b745f 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/OverlayTextureProcessorPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/OverlayTextureProcessorPixelTest.java @@ -16,12 +16,12 @@ package androidx.media3.effect; import static androidx.media3.common.util.Assertions.checkNotNull; -import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; -import static androidx.media3.effect.BitmapTestUtil.createGlTextureFromBitmap; -import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static androidx.media3.effect.BitmapTestUtil.readBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createGlTextureFromBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.test.utils.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.common.truth.Truth.assertThat; @@ -38,6 +38,7 @@ import android.text.style.ForegroundColorSpan; import androidx.media3.common.FrameProcessingException; import androidx.media3.common.util.GlUtil; import androidx.media3.common.util.Size; +import androidx.media3.test.utils.BitmapPixelTestUtil; import androidx.test.ext.junit.runners.AndroidJUnit4; import com.google.common.collect.ImmutableList; import java.io.IOException; @@ -52,8 +53,8 @@ import org.junit.runner.RunWith; * *

Expected bitmaps are taken from an emulator, so tests on different emulators or physical * devices may fail. To test on other devices, please increase the {@link - * BitmapTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output bitmaps - * as recommended in {@link GlEffectsFrameProcessorPixelTest}. + * BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output + * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}. */ @RunWith(AndroidJUnit4.class) public class OverlayTextureProcessorPixelTest { diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/PresentationPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/PresentationPixelTest.java index 31aceb71fc..86d593749d 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/PresentationPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/PresentationPixelTest.java @@ -16,12 +16,12 @@ package androidx.media3.effect; import static androidx.media3.common.util.Assertions.checkNotNull; -import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; -import static androidx.media3.effect.BitmapTestUtil.createGlTextureFromBitmap; -import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static androidx.media3.effect.BitmapTestUtil.readBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createGlTextureFromBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.test.utils.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.common.truth.Truth.assertThat; @@ -34,6 +34,7 @@ import androidx.media3.common.C; import androidx.media3.common.FrameProcessingException; import androidx.media3.common.util.GlUtil; import androidx.media3.common.util.Size; +import androidx.media3.test.utils.BitmapPixelTestUtil; import androidx.test.ext.junit.runners.AndroidJUnit4; import java.io.IOException; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; @@ -47,8 +48,8 @@ import org.junit.runner.RunWith; * *

Expected images are taken from an emulator, so tests on different emulators or physical * devices may fail. To test on other devices, please increase the {@link - * BitmapTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output bitmaps - * as recommended in {@link GlEffectsFrameProcessorPixelTest}. + * BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output + * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}. */ @RunWith(AndroidJUnit4.class) public final class PresentationPixelTest { diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbAdjustmentPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbAdjustmentPixelTest.java index ca2ccd23cf..16bebb9374 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbAdjustmentPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbAdjustmentPixelTest.java @@ -17,13 +17,13 @@ package androidx.media3.effect; import static androidx.media3.common.util.Assertions.checkNotNull; -import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; -import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapWithSolidColor; -import static androidx.media3.effect.BitmapTestUtil.createGlTextureFromBitmap; -import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static androidx.media3.effect.BitmapTestUtil.readBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createArgb8888BitmapWithSolidColor; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createGlTextureFromBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.test.utils.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.common.truth.Truth.assertThat; @@ -36,6 +36,7 @@ import android.opengl.EGLSurface; import androidx.media3.common.FrameProcessingException; import androidx.media3.common.util.GlUtil; import androidx.media3.common.util.Size; +import androidx.media3.test.utils.BitmapPixelTestUtil; import androidx.test.ext.junit.runners.AndroidJUnit4; import com.google.common.collect.ImmutableList; import java.io.IOException; @@ -50,8 +51,8 @@ import org.junit.runner.RunWith; * *

Expected images are taken from an emulator, so tests on different emulators or physical * devices may fail. To test on other devices, please increase the {@link - * BitmapTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output bitmaps - * as recommended in {@link GlEffectsFrameProcessorPixelTest}. + * BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output + * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}. */ @RunWith(AndroidJUnit4.class) public final class RgbAdjustmentPixelTest { diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbFilterPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbFilterPixelTest.java index 693c999784..6a174515b6 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbFilterPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbFilterPixelTest.java @@ -17,12 +17,12 @@ package androidx.media3.effect; import static androidx.media3.common.util.Assertions.checkNotNull; -import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; -import static androidx.media3.effect.BitmapTestUtil.createGlTextureFromBitmap; -import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static androidx.media3.effect.BitmapTestUtil.readBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createGlTextureFromBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.test.utils.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.common.truth.Truth.assertThat; @@ -34,6 +34,7 @@ import android.opengl.EGLSurface; import androidx.media3.common.FrameProcessingException; import androidx.media3.common.util.GlUtil; import androidx.media3.common.util.Size; +import androidx.media3.test.utils.BitmapPixelTestUtil; import androidx.test.ext.junit.runners.AndroidJUnit4; import java.io.IOException; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; @@ -47,8 +48,8 @@ import org.junit.runner.RunWith; * *

Expected images are taken from an emulator, so tests on different emulators or physical * devices may fail. To test on other devices, please increase the {@link - * BitmapTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output bitmaps - * as recommended in {@link GlEffectsFrameProcessorPixelTest}. + * BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output + * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}. */ @RunWith(AndroidJUnit4.class) public final class RgbFilterPixelTest { diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/SingleColorLutPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/SingleColorLutPixelTest.java index 6e2d1d2527..be7ea88149 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/SingleColorLutPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/SingleColorLutPixelTest.java @@ -17,12 +17,12 @@ package androidx.media3.effect; import static androidx.media3.common.util.Assertions.checkNotNull; -import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; -import static androidx.media3.effect.BitmapTestUtil.createGlTextureFromBitmap; -import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static androidx.media3.effect.BitmapTestUtil.readBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static androidx.media3.test.utils.BitmapPixelTestUtil.createGlTextureFromBitmap; +import static androidx.media3.test.utils.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.test.utils.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.common.truth.Truth.assertThat; @@ -35,6 +35,7 @@ import android.opengl.EGLSurface; import androidx.media3.common.FrameProcessingException; import androidx.media3.common.util.GlUtil; import androidx.media3.common.util.Size; +import androidx.media3.test.utils.BitmapPixelTestUtil; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.junit.After; @@ -47,8 +48,8 @@ import org.junit.runner.RunWith; * *

Expected images are taken from an emulator, so tests on different emulators or physical * devices may fail. To test on other devices, please increase the {@link - * BitmapTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output bitmaps - * as recommended in {@link GlEffectsFrameProcessorPixelTest}. + * BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output + * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}. */ @RunWith(AndroidJUnit4.class) public class SingleColorLutPixelTest { diff --git a/libraries/effect/src/main/java/androidx/media3/effect/BitmapUtil.java b/libraries/effect/src/main/java/androidx/media3/effect/BitmapUtil.java index 4e793b7ded..5375c20684 100644 --- a/libraries/effect/src/main/java/androidx/media3/effect/BitmapUtil.java +++ b/libraries/effect/src/main/java/androidx/media3/effect/BitmapUtil.java @@ -20,7 +20,7 @@ import android.graphics.Matrix; /** Utility functions for working with {@link Bitmap}. */ /* package */ final class BitmapUtil { - static Bitmap flipBitmapVertically(Bitmap bitmap) { + public static Bitmap flipBitmapVertically(Bitmap bitmap) { Matrix flip = new Matrix(); flip.postScale(1f, -1f); return Bitmap.createBitmap( diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/BitmapTestUtil.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/BitmapPixelTestUtil.java similarity index 90% rename from libraries/effect/src/androidTest/java/androidx/media3/effect/BitmapTestUtil.java rename to libraries/test_utils/src/main/java/androidx/media3/test/utils/BitmapPixelTestUtil.java index f1e10010b7..849ad52b4c 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/BitmapTestUtil.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/BitmapPixelTestUtil.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package androidx.media3.effect; +package androidx.media3.test.utils; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.common.truth.Truth.assertThat; @@ -24,6 +24,7 @@ import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; +import android.graphics.Matrix; import android.graphics.PixelFormat; import android.media.Image; import android.opengl.GLES20; @@ -31,6 +32,7 @@ import android.opengl.GLUtils; import androidx.annotation.Nullable; import androidx.media3.common.util.GlUtil; import androidx.media3.common.util.Log; +import androidx.media3.common.util.UnstableApi; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -38,27 +40,26 @@ import java.io.InputStream; import java.nio.ByteBuffer; import java.util.Arrays; -/** - * Utilities for instrumentation tests for the {@link GlEffectsFrameProcessor} and {@link - * SingleFrameGlTextureProcessor SingleFrameGlTextureProcessors}. - */ -public class BitmapTestUtil { +/** Utilities for pixel tests. */ +// TODO(b/263395272): After the bug is fixed and dependent tests are moved back to media3.effect, +// move this back to the effect tests directory. +@UnstableApi +public class BitmapPixelTestUtil { - private static final String TAG = "BitmapTestUtil"; + private static final String TAG = "BitmapPixelTestUtil"; /** * Maximum allowed average pixel difference between the expected and actual edited images in pixel * difference-based tests. The value is chosen so that differences in decoder behavior across * emulator versions don't affect whether the test passes for most emulators, but substantial - * distortions introduced by changes in the behavior of the {@link SingleFrameGlTextureProcessor - * SingleFrameGlTextureProcessors} will cause the test to fail. + * distortions introduced by changes in tested components will cause the test to fail. * *

To run pixel difference-based tests on physical devices, please use a value of 5f, rather * than 0.5f. This higher value will ignore some very small errors, but will allow for some * differences caused by graphics implementations to be ignored. When the difference is close to * the threshold, manually inspect expected/actual bitmaps to confirm failure, as it's possible - * this is caused by a difference in the codec or graphics implementation as opposed to a {@link - * SingleFrameGlTextureProcessor} issue. + * this is caused by a difference in the codec or graphics implementation as opposed to an issue + * in the tested component. */ public static final float MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE = 0.5f; @@ -210,7 +211,7 @@ public class BitmapTestUtil { // https://developer.android.com/reference/android/graphics/Bitmap.Config#ARGB_8888. bitmap.copyPixelsFromBuffer(rgba8888Buffer); // Flip the bitmap as its positive y-axis points down while OpenGL's positive y-axis points up. - return BitmapUtil.flipBitmapVertically(bitmap); + return flipBitmapVertically(bitmap); } /** @@ -226,10 +227,23 @@ public class BitmapTestUtil { bitmap.getWidth(), bitmap.getHeight(), /* useHighPrecisionColorComponents= */ false); // Put the flipped bitmap in the OpenGL texture as the bitmap's positive y-axis points down // while OpenGL's positive y-axis points up. - GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, BitmapUtil.flipBitmapVertically(bitmap), 0); + GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, flipBitmapVertically(bitmap), 0); GlUtil.checkGlError(); return texId; } - private BitmapTestUtil() {} + public static Bitmap flipBitmapVertically(Bitmap bitmap) { + Matrix flip = new Matrix(); + flip.postScale(1f, -1f); + return Bitmap.createBitmap( + bitmap, + /* x= */ 0, + /* y= */ 0, + bitmap.getWidth(), + bitmap.getHeight(), + flip, + /* filter= */ true); + } + + private BitmapPixelTestUtil() {} }