From 7aea39c38ec2c721368591a2b1c6c615bc8b375d Mon Sep 17 00:00:00 2001 From: jonathanmos <48201295+jonathanmos@users.noreply.github.com> Date: Mon, 28 Oct 2024 13:04:33 +0200 Subject: [PATCH] fix unit tests --- .../recorder/resources/ResourceResolverTest.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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(