glide
glide copied to clipboard
[Question/Solution] How to test the downloaded image?
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
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.
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.