diff --git a/features/dd-sdk-android-session-replay/src/test/kotlin/com/datadog/android/sessionreplay/internal/recorder/resources/ResourceResolverTest.kt b/features/dd-sdk-android-session-replay/src/test/kotlin/com/datadog/android/sessionreplay/internal/recorder/resources/ResourceResolverTest.kt index 8d9decb809..a9ef779f79 100644 --- a/features/dd-sdk-android-session-replay/src/test/kotlin/com/datadog/android/sessionreplay/internal/recorder/resources/ResourceResolverTest.kt +++ b/features/dd-sdk-android-session-replay/src/test/kotlin/com/datadog/android/sessionreplay/internal/recorder/resources/ResourceResolverTest.kt @@ -11,6 +11,7 @@ import android.content.res.Resources import android.graphics.Bitmap import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.Drawable +import android.graphics.drawable.Drawable.ConstantState import android.graphics.drawable.LayerDrawable import android.graphics.drawable.StateListDrawable import android.util.DisplayMetrics @@ -103,6 +104,12 @@ internal class ResourceResolverTest { @Mock lateinit var mockResources: Resources + @Mock + lateinit var mockConstantState: ConstantState + + @Mock + lateinit var mockBitmapConstantState: ConstantState + private var fakeBitmapWidth: Int = 1 private var fakeBitmapHeight: Int = 1 @@ -117,6 +124,11 @@ internal class ResourceResolverTest { @BeforeEach fun setup(forge: Forge) { + whenever(mockBitmapDrawable.constantState).thenReturn(mockBitmapConstantState) + whenever(mockBitmapConstantState.newDrawable()).thenReturn(mockBitmapDrawable) + + whenever(mockDrawable.constantState).thenReturn(mockConstantState) + whenever(mockConstantState.newDrawable()).thenReturn(mockDrawable) fakeImageCompressionByteArray = forge.aString().toByteArray() fakeBitmapWidth = forge.anInt(min = 1) @@ -619,6 +631,8 @@ internal class ResourceResolverTest { fun `M cache bitmap W resolveResourceId() { not a BitmapDrawable }`() { // Given val mockLayerDrawable = mock() + whenever(mockLayerDrawable.constantState).thenReturn(mockConstantState) + whenever(mockConstantState.newDrawable()).thenReturn(mockLayerDrawable) // When testedResourceResolver.resolveResourceId(