Created
September 4, 2019 06:56
-
-
Save rakib10rr3/d544eb0494a6009d900d2d28389ec00c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//This method will work on a checkbox. It will set the state of checkbox either checked or unchecked | |
private fun setChecked(checked: Boolean): ViewAction { | |
return object : ViewAction { | |
override fun getDescription(): String? { | |
return null | |
} | |
override fun getConstraints(): Matcher<View> { | |
return object : BaseMatcher<View>() { | |
override fun matches(item: Any): Boolean { | |
return isA(Checkable::class.java).matches(item) | |
} | |
override fun describeMismatch(item: Any, mismatchDescription: Description) {} | |
override fun describeTo(description: Description) {} | |
} | |
} | |
override | |
fun perform(uiController: UiController, view: View) { | |
val checkableView = view as Checkable | |
checkableView.isChecked = checked | |
} | |
} | |
} | |
//Call it like this | |
onView(withId(R.id.addressCheckbox)).perform(setChecked(false)) //It will uncheck the box |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment