Last active
October 25, 2019 10:35
-
-
Save veena14cs/f918bacca3396f489202f1c986afad1f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
fun testImageLoader_returnSuccess() { | |
val imageView = activityTestRule.activity.findViewById(R.id.test_url_parser_image_view) as ImageView | |
var drawable: Drawable? = null | |
val testBitmap: Bitmap? = null | |
val target = object : CustomTarget<Bitmap>() { | |
override fun onLoadCleared(placeholder: Drawable?) { | |
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. | |
} | |
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) { | |
drawable = BitmapDrawable(activityTestRule.activity.getResources(), resource); | |
imageView.setImageDrawable(drawable) | |
} | |
} | |
doAnswer(Answer() { | |
fun answer(invocation: InvocationOnMock) { | |
invocation.getArgument<CustomTarget<Bitmap>>(1).onResourceReady(testBitmap!!, null) | |
imageView.setImageBitmap(testBitmap) | |
} | |
}).`when`(imageLoader).load(OK_IMAGE_URL, target) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment