glide icon indicating copy to clipboard operation
glide copied to clipboard

[Question/Solution] How to test the downloaded image?

Open airatmeister opened this issue 2 years ago • 2 comments

Glide-compose testing question/solution.

Question: How can I test the downloaded image if DisplayedDrawableKey is internal? https://github.com/bumptech/glide/blob/ed5b09affc97e93d991df52a474369b9d0b47081/integration/compose/src/main/java/com/bumptech/glide/integration/compose/GlideModifier.kt#L521C14-L521C34 Is it so designed that it's not testable? Solution: internal DisplayedDrawableKey to public

airatmeister avatar Aug 21 '23 10:08 airatmeister

How would you test this with a normal Image?

For a testing API for Glide's compose integration, you'd also need an idling resource. I have written that, but I don't think I've exposed it.

sjudd avatar Aug 24 '23 02:08 sjudd

I need to check that first I have a placeholder displayed, and only then the loaded image. For the placeholder case, I can make my semantics on my composable, but I can’t check the loaded image like that because it is at the core library(with internal). My case(for testing glideNode is my Node with custom asserts):

lockConnection() // Blocking internet connection to check placeholder
glideNode.assertHasPreviewDrawable(previewDrawable) // checking preview drawable
unLockConnection() // Unblocking internet connection
glideNode.assertHasSuccessDrawable(successDrawable) // I know in advance which image will be loaded and already substitute it in the tests

But for such a check, I need access to the semantics that is responsible for the loaded image.

airatmeister avatar Aug 29 '23 19:08 airatmeister