tir38
tir38

Reputation: 10441

Navigation Drawer animation is failing Espresso test

I'm testing changes to my NavigationDrawer via espresso. I open and close the drawer several times in a single test and I end up with this failing test:

Caused by: java.lang.RuntimeException: Action will not be performed because the target view does not match one or more of the following constraints: at least 90 percent of the view's area is displayed to the user.

The view in question is a view I am asserting against inside the drawer. I assume this is failing because Espresso is not idling for the drawer to open. I have all "animation scales" set to off in Developer options, but I see that the drawer sliding is not affected by this. Aside from creating a custom IdlingResouce, is there a built-in espresso function to tell it to wait?

Upvotes: 0

Views: 309

Answers (1)

oziem
oziem

Reputation: 470

If you are not using espressoContrib library, then you should. With function:

onView(withId(R.id.drawerLayout)) .perform(DrawerActions.open()) .check(matches(DrawerMatchers.isOpen()))

If you are, and still see that error, maybe this custom idling resource will help. (It's @chiuki code so i will not pass it here)

Upvotes: 1

Related Questions