diff --git a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/ContrastPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/ContrastPixelTest.java index f5977f95ae..51b6860bda 100644 --- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/ContrastPixelTest.java +++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/ContrastPixelTest.java @@ -17,13 +17,13 @@ package com.google.android.exoplayer2.effect; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createArgb8888BitmapWithSolidColor; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createGlTextureFromBitmap; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.readBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createArgb8888BitmapWithSolidColor; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createGlTextureFromBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.readBitmap; import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.common.truth.Truth.assertThat; @@ -34,6 +34,7 @@ import android.opengl.EGLContext; import android.opengl.EGLDisplay; import android.opengl.EGLSurface; import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.google.android.exoplayer2.testutil.BitmapPixelTestUtil; import com.google.android.exoplayer2.util.FrameProcessingException; import com.google.android.exoplayer2.util.GlUtil; import com.google.android.exoplayer2.util.Size; @@ -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/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/CropPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/CropPixelTest.java index 94a6af9ad5..0c3545df34 100644 --- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/CropPixelTest.java +++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/CropPixelTest.java @@ -16,12 +16,12 @@ package com.google.android.exoplayer2.effect; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createGlTextureFromBitmap; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.readBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createGlTextureFromBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.readBitmap; import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.common.truth.Truth.assertThat; @@ -31,6 +31,7 @@ import android.opengl.EGLContext; import android.opengl.EGLDisplay; import android.opengl.EGLSurface; import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.google.android.exoplayer2.testutil.BitmapPixelTestUtil; import com.google.android.exoplayer2.util.FrameProcessingException; import com.google.android.exoplayer2.util.GlUtil; import com.google.android.exoplayer2.util.Size; @@ -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/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessorPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessorPixelTest.java index dee4a5239a..05af776bf0 100644 --- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessorPixelTest.java +++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessorPixelTest.java @@ -16,11 +16,11 @@ package com.google.android.exoplayer2.effect; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createArgb8888BitmapFromRgba8888Image; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.readBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createArgb8888BitmapFromRgba8888Image; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.readBitmap; import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull; import static com.google.common.truth.Truth.assertThat; @@ -35,6 +35,7 @@ import android.media.ImageReader; import android.media.MediaFormat; import androidx.test.ext.junit.runners.AndroidJUnit4; import com.google.android.exoplayer2.C; +import com.google.android.exoplayer2.testutil.BitmapPixelTestUtil; import com.google.android.exoplayer2.testutil.DecodeOneFrameUtil; import com.google.android.exoplayer2.util.DebugViewProvider; import com.google.android.exoplayer2.util.Effect; @@ -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/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/HslAdjustmentPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/HslAdjustmentPixelTest.java index 014db39508..0e50460f1b 100644 --- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/HslAdjustmentPixelTest.java +++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/HslAdjustmentPixelTest.java @@ -17,13 +17,13 @@ package com.google.android.exoplayer2.effect; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createArgb8888BitmapWithSolidColor; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createGlTextureFromBitmap; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.readBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createArgb8888BitmapWithSolidColor; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createGlTextureFromBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.readBitmap; import static com.google.common.truth.Truth.assertThat; import android.content.Context; @@ -33,6 +33,7 @@ import android.opengl.EGLContext; import android.opengl.EGLDisplay; import android.opengl.EGLSurface; import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.google.android.exoplayer2.testutil.BitmapPixelTestUtil; import com.google.android.exoplayer2.util.FrameProcessingException; import com.google.android.exoplayer2.util.GlUtil; import com.google.android.exoplayer2.util.Size; @@ -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/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/MatrixTextureProcessorPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/MatrixTextureProcessorPixelTest.java index 965fa67443..31126fae86 100644 --- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/MatrixTextureProcessorPixelTest.java +++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/MatrixTextureProcessorPixelTest.java @@ -16,12 +16,12 @@ package com.google.android.exoplayer2.effect; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createGlTextureFromBitmap; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.readBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createGlTextureFromBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.readBitmap; import static com.google.common.truth.Truth.assertThat; import android.content.Context; @@ -31,6 +31,7 @@ import android.opengl.EGLContext; import android.opengl.EGLDisplay; import android.opengl.EGLSurface; import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.google.android.exoplayer2.testutil.BitmapPixelTestUtil; import com.google.android.exoplayer2.util.FrameProcessingException; import com.google.android.exoplayer2.util.GlUtil; import java.io.IOException; @@ -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/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/OverlayTextureProcessorPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/OverlayTextureProcessorPixelTest.java index 6a9f4747ee..d6a1abb4b0 100644 --- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/OverlayTextureProcessorPixelTest.java +++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/OverlayTextureProcessorPixelTest.java @@ -16,12 +16,12 @@ package com.google.android.exoplayer2.effect; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createGlTextureFromBitmap; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.readBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createGlTextureFromBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.readBitmap; import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.common.truth.Truth.assertThat; @@ -36,6 +36,7 @@ import android.text.Spannable; import android.text.SpannableString; import android.text.style.ForegroundColorSpan; import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.google.android.exoplayer2.testutil.BitmapPixelTestUtil; import com.google.android.exoplayer2.util.FrameProcessingException; import com.google.android.exoplayer2.util.GlUtil; import com.google.android.exoplayer2.util.Size; @@ -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/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/PresentationPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/PresentationPixelTest.java index c3af1ffe93..ed965a606d 100644 --- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/PresentationPixelTest.java +++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/PresentationPixelTest.java @@ -16,12 +16,12 @@ package com.google.android.exoplayer2.effect; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createGlTextureFromBitmap; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.readBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createGlTextureFromBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.readBitmap; import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.common.truth.Truth.assertThat; @@ -32,6 +32,7 @@ import android.opengl.EGLDisplay; import android.opengl.EGLSurface; import androidx.test.ext.junit.runners.AndroidJUnit4; import com.google.android.exoplayer2.C; +import com.google.android.exoplayer2.testutil.BitmapPixelTestUtil; import com.google.android.exoplayer2.util.FrameProcessingException; import com.google.android.exoplayer2.util.GlUtil; import com.google.android.exoplayer2.util.Size; @@ -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/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/RgbAdjustmentPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/RgbAdjustmentPixelTest.java index ef4f53cf0b..3d40a61462 100644 --- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/RgbAdjustmentPixelTest.java +++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/RgbAdjustmentPixelTest.java @@ -17,13 +17,13 @@ package com.google.android.exoplayer2.effect; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createArgb8888BitmapWithSolidColor; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createGlTextureFromBitmap; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.readBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createArgb8888BitmapWithSolidColor; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createGlTextureFromBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.readBitmap; import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.common.truth.Truth.assertThat; @@ -34,6 +34,7 @@ import android.opengl.EGLContext; import android.opengl.EGLDisplay; import android.opengl.EGLSurface; import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.google.android.exoplayer2.testutil.BitmapPixelTestUtil; import com.google.android.exoplayer2.util.FrameProcessingException; import com.google.android.exoplayer2.util.GlUtil; import com.google.android.exoplayer2.util.Size; @@ -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/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/RgbFilterPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/RgbFilterPixelTest.java index 3165b26602..51282787b3 100644 --- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/RgbFilterPixelTest.java +++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/RgbFilterPixelTest.java @@ -17,12 +17,12 @@ package com.google.android.exoplayer2.effect; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createGlTextureFromBitmap; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.readBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createGlTextureFromBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.readBitmap; import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.common.truth.Truth.assertThat; @@ -32,6 +32,7 @@ import android.opengl.EGLContext; import android.opengl.EGLDisplay; import android.opengl.EGLSurface; import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.google.android.exoplayer2.testutil.BitmapPixelTestUtil; import com.google.android.exoplayer2.util.FrameProcessingException; import com.google.android.exoplayer2.util.GlUtil; import com.google.android.exoplayer2.util.Size; @@ -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/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/SingleColorLutPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/SingleColorLutPixelTest.java index fb160e6407..ab826ba561 100644 --- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/SingleColorLutPixelTest.java +++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/SingleColorLutPixelTest.java @@ -17,12 +17,12 @@ package com.google.android.exoplayer2.effect; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.createGlTextureFromBitmap; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; -import static com.google.android.exoplayer2.effect.BitmapTestUtil.readBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.createGlTextureFromBitmap; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.readBitmap; import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.common.truth.Truth.assertThat; @@ -33,6 +33,7 @@ import android.opengl.EGLContext; import android.opengl.EGLDisplay; import android.opengl.EGLSurface; import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.google.android.exoplayer2.testutil.BitmapPixelTestUtil; import com.google.android.exoplayer2.util.FrameProcessingException; import com.google.android.exoplayer2.util.GlUtil; import com.google.android.exoplayer2.util.Size; @@ -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/library/effect/src/main/java/com/google/android/exoplayer2/effect/BitmapUtil.java b/library/effect/src/main/java/com/google/android/exoplayer2/effect/BitmapUtil.java index 57d6c35aab..ce9e6cedbe 100644 --- a/library/effect/src/main/java/com/google/android/exoplayer2/effect/BitmapUtil.java +++ b/library/effect/src/main/java/com/google/android/exoplayer2/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/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/BitmapTestUtil.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/BitmapPixelTestUtil.java similarity index 90% rename from library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/BitmapTestUtil.java rename to testutils/src/main/java/com/google/android/exoplayer2/testutil/BitmapPixelTestUtil.java index 427fa0727f..f25ed403cd 100644 --- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/BitmapTestUtil.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/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 com.google.android.exoplayer2.effect; +package com.google.android.exoplayer2.testutil; 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; @@ -38,27 +39,25 @@ 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. +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 +209,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 +225,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() {} }