Created
February 18, 2018 09:06
-
-
Save plnice/01f9c1a022c72ac72b6fd66bd6289d79 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
fun withDrawable(@DrawableRes id: Int) = object : TypeSafeMatcher<View>() { | |
override fun describeTo(description: Description) { | |
description.appendText("ImageView with drawable same as drawable with id $id") | |
} | |
override fun matchesSafely(view: View): Boolean { | |
val context = view.context | |
val expectedBitmap = context.getDrawable(id).toBitmap() | |
return view is ImageView && view.drawable.toBitmap().sameAs(expectedBitmap) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment