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 232190d commit 264b579
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,34 @@ import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.android.material.textfield.TextInputLayout
import com.google.common.truth.Truth.assertThat
import org.hamcrest.Description
import org.hamcrest.StringDescription
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.android.testing.TextInputActionTestActivity
import org.oppia.android.testing.espresso.TextInputAction.Companion.hasErrorText
import org.oppia.android.testing.espresso.TextInputAction.Companion.hasNoErrorText
import org.robolectric.annotation.LooperMode

@RunWith(AndroidJUnit4::class)
@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()
}
}
}

0 comments on commit 264b579

Please sign in to comment.