Skip to content

Instantly share code, notes, and snippets.

@BenHenning
Created October 15, 2019 06:14
Show Gist options
  • Save BenHenning/22fbd019fa2488a634a8eab2202c8616 to your computer and use it in GitHub Desktop.
Save BenHenning/22fbd019fa2488a634a8eab2202c8616 to your computer and use it in GitHub Desktop.
interface InteractionAnswerRetriever {
fun getPendingAnswer(): InteractionObject
}
class TextInputInteractionView: TextView, InteractionAnswerRetriever {
override fun getPendingAnswer(): InteractionObject {
return InteractionObject.newBuilder().setNormalizedAnswer(text).build()
}
}
... testing the view ...
@Test
fun testInputInteractionView_withInputtedText_hasCorrectPendingAnswer() {
onView(withId(R.id.test_text_input_interaction_view)).perform(text("Test value"))
activityScenario.onActivity { activity ->
val textAnswerRetriever = activity.findViewById(R.id.test_text_input_interaction_view) as InteractionAnswerRetriever
assertThat(textAnswerRetriever.objectTypeCase).isEqualTo(InteractionObject.ObjectTypeCase.NORMALIZED_STRING)
assertThat(textAnswerRetriever.normalizedString).isEqualTo("Test value")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment