Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexZhukovich/b1d5bab130ca9df268fa3cf3c9bb467f to your computer and use it in GitHub Desktop.
Save AlexZhukovich/b1d5bab130ca9df268fa3cf3c9bb467f to your computer and use it in GitHub Desktop.
@LargeTest
@RunWith(AndroidJUnit4::class)
class SignInActivityTest123 {
@Rule
@JvmField
var mActivityTestRule = ActivityTestRule(SignInActivity::class.java)
@Test
fun signInActivityTest123() {
val appCompatEditText = onView(
allOf(withId(R.id.email),
childAtPosition(
allOf(withId(R.id.signInRoot),
childAtPosition(
withId(android.R.id.content),
0)),
4),
isDisplayed()))
appCompatEditText.perform(replaceText(" test"), closeSoftKeyboard())
val appCompatButton = onView(
allOf(withId(R.id.signIn), withText("Sign In"),
childAtPosition(
allOf(withId(R.id.signInRoot),
childAtPosition(
withId(android.R.id.content),
0)),
6),
isDisplayed()))
appCompatButton.perform(click())
}
private fun childAtPosition(
parentMatcher: Matcher<View>, position: Int): Matcher<View> {
return object : TypeSafeMatcher<View>() {
override fun describeTo(description: Description) {
description.appendText("Child at position $position in parent ")
parentMatcher.describeTo(description)
}
public override fun matchesSafely(view: View): Boolean {
val parent = view.parent
return parent is ViewGroup && parentMatcher.matches(parent)
&& view == parent.getChildAt(position)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment