Update: So I left out that this view is inside a ViewPager. It turns out my issue was the interpretation of "swipeLeft" and "swipeRight". The reason I missed this for so long is because I would manually run through the steps by hand, and what I thought of as "swipeRight" didn't match what Espresso thinks of as swiping right. So I didn't see the issue happening until I threw in a bunch of sleeps around my code so I could see it go in slow motion. That's when I realized it was going the wrong direction. So really, this whole issue is because of that. Oops. Not sure what to do with this question, since I technically can answer it myself but it's so far from being related to what the post is about because I left out the ViewPager bits.
Original:
I'm doing a pretty straightforward check for text and it doesn't want to pass.
onView(withText("My text")).check(matches(isDisplayed()));
android.support.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 'is displayed on the screen to the user' doesn't match the selected view.
Expected: is displayed on the screen to the user
Got: "CustomTextView{id=2131756070, res-name=label_name, visibility=VISIBLE, width=506, height=53, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=220.0, y=375.0, text=My text, input-type=0, ime-target=false, has-links=false}"
And here's the layout code:
<snip.snip.CustomTextView
android:id="@+id/label_name"
style="@style/typographyH4Subheading"
android:layout_centerHorizontal="true"
android:gravity="center"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:text="@{viewModel.nameLabel}"
android:ellipsize="end"
android:singleLine="true"/>
Any idea what could cause this to not match?