From 670658f3aec2ad4823c110cb8e4dd73dda2244c7 Mon Sep 17 00:00:00 2001 From: claincly Date: Mon, 7 Aug 2023 13:07:11 +0000 Subject: [PATCH] Use a larger pixel difference on real devices PiperOrigin-RevId: 554452842 --- .../test/utils/BitmapPixelTestUtil.java | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/BitmapPixelTestUtil.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/BitmapPixelTestUtil.java index a2f10325bd..4c9950ca6f 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/BitmapPixelTestUtil.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/BitmapPixelTestUtil.java @@ -39,6 +39,7 @@ import androidx.media3.common.util.GlUtil; import androidx.media3.common.util.Log; import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; +import com.google.common.base.Ascii; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -56,21 +57,6 @@ public class BitmapPixelTestUtil { private static final String TAG = "BitmapPixelTestUtil"; - /** - * Maximum allowed average pixel difference between bitmaps generated using emulators. - * - *

This value is for for 8-bit primaries 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, but substantial distortions introduced by changes in tested - * components will cause the test to fail. - * - *

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 an issue in the tested component. - */ - public static final float MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE = 1f; - /** * Maximum allowed average pixel difference between bitmaps generated using devices. * @@ -91,6 +77,28 @@ public class BitmapPixelTestUtil { public static final float MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE_DIFFERENT_DEVICE = !Util.MODEL.equals("H8266") && !Util.MODEL.equals("H8416") ? 5f : 15f; + /** + * Maximum allowed average pixel difference between bitmaps generated. + * + *

This value is for for 8-bit primaries 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, but substantial distortions introduced by changes in tested + * components will cause the test to fail. + * + *

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 an issue in the tested component. + * + *

The value is the same as {@link #MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE_DIFFERENT_DEVICE} + * if running on physical devices. + */ + public static final float MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE = + Ascii.toLowerCase(Util.DEVICE).contains("emulator") + || Ascii.toLowerCase(Util.DEVICE).contains("generic") + ? MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE_DIFFERENT_DEVICE + : 1f; + /** * Maximum allowed average pixel difference between bitmaps with 16-bit primaries generated using * devices.