Skip to content

Commit

Permalink
ANDROID-13796 extract repeated code to private method
Browse files Browse the repository at this point in the history
  • Loading branch information
jeprubio committed Oct 13, 2023
1 parent af15dd0 commit 601dca0
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions library/src/test/java/com/telefonica/mistica/input/TextInputTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,30 @@ internal class TextInputTest: ScreenshotsTest() {

@Test
fun `check TextInput`() {
rule.scenario.onActivity { activity ->
val wrapper: FrameLayout = activity.findViewById(R.id.dummy_activity_wrapper)
val textInput = TextInput(activity)
wrapper.addView(textInput)
textInput.text = "Hello android devs!"

compareScreenshot(onView(ViewMatchers.withId(R.id.dummy_activity_wrapper)))
}
checkTextInput()
}

@Test
fun `check TextInputWithError`() {
rule.scenario.onActivity { activity ->
val wrapper: FrameLayout = activity.findViewById(R.id.dummy_activity_wrapper)
val textInput = TextInput(activity)
wrapper.addView(textInput)
textInput.text = "Hello android devs!"
textInput.error = "Whatever error"

compareScreenshot(onView(ViewMatchers.withId(R.id.dummy_activity_wrapper)))
checkTextInput {
error = "Whatever error"
}
}

@Test
fun `check TextInputDisabled`() {
checkTextInput {
isEnabled = false
}
}

private fun checkTextInput(onTextInput: TextInput.() -> Unit = {}) {
rule.scenario.onActivity { activity ->
val wrapper: FrameLayout = activity.findViewById(R.id.dummy_activity_wrapper)
val textInput = TextInput(activity)
wrapper.addView(textInput)
textInput.text = "Hello android devs!"
textInput.isEnabled = false
textInput.onTextInput()

compareScreenshot(onView(ViewMatchers.withId(R.id.dummy_activity_wrapper)))
}
Expand Down

0 comments on commit 601dca0

Please sign in to comment.