diff --git a/coil-core/src/commonTest/kotlin/coil3/memory/StrongMemoryCacheTest.kt b/coil-core/src/commonTest/kotlin/coil3/memory/StrongMemoryCacheTest.kt index ba9aa3bf79..363a16a2e0 100644 --- a/coil-core/src/commonTest/kotlin/coil3/memory/StrongMemoryCacheTest.kt +++ b/coil-core/src/commonTest/kotlin/coil3/memory/StrongMemoryCacheTest.kt @@ -3,7 +3,6 @@ package coil3.memory import coil3.Image import coil3.memory.MemoryCache.Key import coil3.memory.MemoryCache.Value -import coil3.test.utils.DEFAULT_FAKE_IMAGE_SIZE import coil3.test.utils.FakeImage import kotlin.test.Test import kotlin.test.assertEquals @@ -15,7 +14,7 @@ class StrongMemoryCacheTest { @Test fun canRetrieveCachedValue() { val weakCache = FakeWeakMemoryCache() - val strongCache = RealStrongMemoryCache(2 * DEFAULT_FAKE_IMAGE_SIZE, weakCache) + val strongCache = RealStrongMemoryCache(2 * FakeImage().size, weakCache) val image = FakeImage() strongCache.set(Key("1"), image, emptyMap(), image.size) @@ -26,7 +25,7 @@ class StrongMemoryCacheTest { @Test fun leastRecentlyUsedValueIsEvicted() { val weakCache = FakeWeakMemoryCache() - val strongCache = RealStrongMemoryCache(2 * DEFAULT_FAKE_IMAGE_SIZE, weakCache) + val strongCache = RealStrongMemoryCache(2 * FakeImage().size, weakCache) val first = FakeImage() strongCache.set(Key("1"), first, emptyMap(), first.size) @@ -44,7 +43,7 @@ class StrongMemoryCacheTest { @Test fun valueCanBeRemoved() { val weakCache = FakeWeakMemoryCache() - val strongCache = RealStrongMemoryCache(2 * DEFAULT_FAKE_IMAGE_SIZE, weakCache) + val strongCache = RealStrongMemoryCache(2 * FakeImage().size, weakCache) val image = FakeImage() strongCache.set(Key("1"), image, emptyMap(), image.size) diff --git a/coil-test/src/commonTest/kotlin/coil3/test/FakeImageLoaderEngineTest.kt b/coil-test/src/commonTest/kotlin/coil3/test/FakeImageLoaderEngineTest.kt index aa0a1aa47c..4d7c97b558 100644 --- a/coil-test/src/commonTest/kotlin/coil3/test/FakeImageLoaderEngineTest.kt +++ b/coil-test/src/commonTest/kotlin/coil3/test/FakeImageLoaderEngineTest.kt @@ -6,7 +6,6 @@ import coil3.request.ErrorResult import coil3.request.ImageRequest import coil3.request.SuccessResult import coil3.test.FakeImageLoaderEngine.OptionalInterceptor -import coil3.test.utils.FakeImage import coil3.test.utils.RobolectricTest import coil3.test.utils.context import kotlin.test.Test diff --git a/internal/test-utils/build.gradle.kts b/internal/test-utils/build.gradle.kts index 528f3cdad1..bda7ddc94a 100644 --- a/internal/test-utils/build.gradle.kts +++ b/internal/test-utils/build.gradle.kts @@ -5,6 +5,7 @@ plugins { id("com.android.library") id("kotlin-multiplatform") id("org.jetbrains.kotlinx.atomicfu") + id("dev.drewhamilton.poko") } addAllMultiplatformTargets(libs.versions.skiko) diff --git a/internal/test-utils/src/androidMain/kotlin/coil3/test/utils/FakeImage.android.kt b/internal/test-utils/src/androidMain/kotlin/coil3/test/utils/FakeImage.android.kt deleted file mode 100644 index 43c7502aa6..0000000000 --- a/internal/test-utils/src/androidMain/kotlin/coil3/test/utils/FakeImage.android.kt +++ /dev/null @@ -1,17 +0,0 @@ -package coil3.test.utils - -import coil3.Canvas -import coil3.Image -import coil3.annotation.Poko - -@Poko -actual class FakeImage actual constructor( - actual override val width: Int, - actual override val height: Int, - actual override val size: Long, - actual override val shareable: Boolean, -) : Image { - actual override fun draw(canvas: Canvas) { - // Draw nothing. - } -} diff --git a/internal/test-utils/src/commonMain/kotlin/coil3/test/utils/FakeImage.kt b/internal/test-utils/src/commonMain/kotlin/coil3/test/utils/FakeImage.kt index ea335c9f36..00118fc90e 100644 --- a/internal/test-utils/src/commonMain/kotlin/coil3/test/utils/FakeImage.kt +++ b/internal/test-utils/src/commonMain/kotlin/coil3/test/utils/FakeImage.kt @@ -2,18 +2,17 @@ package coil3.test.utils import coil3.Canvas import coil3.Image +import coil3.annotation.Poko -expect class FakeImage( - width: Int = 100, - height: Int = 100, - size: Long = 4L * width * height, - shareable: Boolean = true, +/** An [Image] that renders nothing. */ +@Poko +class FakeImage( + override val width: Int = 100, + override val height: Int = 100, + override val size: Long = 4L * width * height, + override val shareable: Boolean = true, ) : Image { - override val size: Long - override val width: Int - override val height: Int - override val shareable: Boolean - override fun draw(canvas: Canvas) + override fun draw(canvas: Canvas) { + // Draw nothing. + } } - -const val DEFAULT_FAKE_IMAGE_SIZE = 4L * 100 * 100 diff --git a/internal/test-utils/src/nonAndroidMain/kotlin/coil3/test/utils/FakeImage.nonAndroid.kt b/internal/test-utils/src/nonAndroidMain/kotlin/coil3/test/utils/FakeImage.nonAndroid.kt deleted file mode 100644 index 43c7502aa6..0000000000 --- a/internal/test-utils/src/nonAndroidMain/kotlin/coil3/test/utils/FakeImage.nonAndroid.kt +++ /dev/null @@ -1,17 +0,0 @@ -package coil3.test.utils - -import coil3.Canvas -import coil3.Image -import coil3.annotation.Poko - -@Poko -actual class FakeImage actual constructor( - actual override val width: Int, - actual override val height: Int, - actual override val size: Long, - actual override val shareable: Boolean, -) : Image { - actual override fun draw(canvas: Canvas) { - // Draw nothing. - } -}