Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanmos committed Oct 28, 2024
1 parent a803ecb commit 7aea39c
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -619,6 +631,8 @@ internal class ResourceResolverTest {
fun `M cache bitmap W resolveResourceId() { not a BitmapDrawable }`() {
// Given
val mockLayerDrawable = mock<LayerDrawable>()
whenever(mockLayerDrawable.constantState).thenReturn(mockConstantState)
whenever(mockConstantState.newDrawable()).thenReturn(mockLayerDrawable)

// When
testedResourceResolver.resolveResourceId(
Expand Down

0 comments on commit 7aea39c

Please sign in to comment.