FakeImageLoaderEngine

An ImageLoader interceptor that intercepts all incoming requests before they're fetched and decoded by the image loader's real image engine. This class is useful for overriding an image loader's responses in tests:

val engine = FakeImageLoaderEngine.Builder()
.intercept("https://www.example.com/image.jpg", FakeImage())
.intercept({ it is String && it.endsWith("test.png") }, FakeImage())
.default(FakeImage(color = 0x0000FF))
.build()
val imageLoader = ImageLoader.Builder(context)
.components { add(engine) }
.build()

Types

Link copied to clipboard
class Builder
Link copied to clipboard
fun interface OptionalInterceptor

An Interceptor that can either:

Link copied to clipboard
fun interface RequestTransformer

A callback to support modifying an ImageRequest before it's handled by the OptionalInterceptors.

Link copied to clipboard
class RequestValue(val request: ImageRequest, val size: Size)
Link copied to clipboard

Properties

Link copied to clipboard
Link copied to clipboard

Returns a Flow that emits when a request starts.

Link copied to clipboard

Returns a Flow that emits when a request completes.

Functions

Link copied to clipboard
open suspend override fun intercept(chain: Interceptor.Chain): ImageResult
Link copied to clipboard

Create a new FakeImageLoaderEngine.Builder with the same configuration.