Skip to content

Commit

Permalink
Test workflow with TextInputActionTest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethmurerwa committed Aug 20, 2024
1 parent f9106d9 commit 232190d
Showing 1 changed file with 0 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,84 +19,4 @@ import org.robolectric.annotation.LooperMode
@LooperMode(LooperMode.Mode.PAUSED)
class TextInputActionTest {

@get:Rule
var activityRule =
ActivityScenarioRule<TextInputActionTestActivity>(
TextInputActionTestActivity.createIntent(ApplicationProvider.getApplicationContext())
)

@Test
fun testTextExistsMatcher_errorMatchesExpectedText_matchesSafelyReturnsTrue() {
activityRule.scenario.onActivity { activity ->
val expectedErrorText = "Incorrect Administrator PIN. Please try again."
val textInputLayout = TextInputLayout(activity)

textInputLayout.error = "Incorrect Administrator PIN. Please try again."

val errorTextExisted = hasErrorText(expectedErrorText)
val result: Boolean = errorTextExisted.matches(textInputLayout)
assertThat(result).isTrue()
}
}

@Test
fun testTextExistsMatcher_errorDoesNotMatchesExpectedText_matchesSafelyReturnsFalse() {
activityRule.scenario.onActivity { activity ->
val expectedErrorText = "Incorrect Administrator PIN. Please try again."
val textInputLayout = TextInputLayout(activity)

textInputLayout.error = "This name is already in use by another profile."

val errorTextExisted = hasErrorText(expectedErrorText)
val result: Boolean = errorTextExisted.matches(textInputLayout)
assertThat(result).isFalse()
}
}

@Test
fun testTextExistsMatcher_descriptionMatchesExpectedDescription() {
val errorText = "Incorrect Administrator PIN. Please try again."
val expectedDescription =
"The expected error text is 'Incorrect Administrator PIN. Please try again.'"

val errorTextExisted = hasErrorText(errorText)
var description: Description = StringDescription()
errorTextExisted.describeTo(description)

assertThat(description.toString()).isEqualTo(expectedDescription)
}

@Test
fun testTextDoesNotExistMatcher_errorTextIsEmpty_matchesSafelyReturnsTrue() {
activityRule.scenario.onActivity { activity ->
val textInputLayout = TextInputLayout(activity)
val errorTextNotExisted = hasNoErrorText()

val result: Boolean = errorTextNotExisted.matches(textInputLayout)
assertThat(result).isTrue()
}
}

@Test
fun testTextDoesNotExistMatcher_errorTextIsNotEmpty_matchesSafelyReturnsFalse() {
activityRule.scenario.onActivity { activity ->
val textInputLayout = TextInputLayout(activity)
textInputLayout.error = "Error text is not empty"
val errorTextNotExisted = hasNoErrorText()

val result: Boolean = errorTextNotExisted.matches(textInputLayout)
assertThat(result).isFalse()
}
}

@Test
fun testTextDoesNotExistMatcher_descriptionMatchesExpectedDescription() {
val expectedDescription = "There is no error text."

val errorTextNotExisted = hasNoErrorText()
var description: Description = StringDescription()
errorTextNotExisted.describeTo(description)

assertThat(description.toString()).isEqualTo(expectedDescription)
}
}

0 comments on commit 232190d

Please sign in to comment.