Espresso swipeUp() wait too long after performed

1.6k views Asked by At

I am currently testing my NavigationDrawer with the Espresso library. The purpose of this test is just to open the drawer and click on every items.

All of this works well, except that once I'm on the middle of the drawer, I perform a perform(swipeUp()) which works too, but after the swipe, it waits approximately 30 seconds before executing the rest of the test.

Here is the code of my test :

public void testNavigate() {
    String[] frags = new String[] {
            authActivity.getString(R.string.title_fragment_vehicles),
            authActivity.getString(R.string.title_fragment_smartphones),
            authActivity.getString(R.string.title_fragment_tools),
            authActivity.getString(R.string.title_fragment_pool),
            authActivity.getString(R.string.title_fragment_users),
            authActivity.getString(R.string.title_fragment_reporting),
            authActivity.getString(R.string.title_fragment_taxes),
            authActivity.getString(R.string.title_fragment_support),
            authActivity.getString(R.string.title_fragment_settings)
    };
    for (String elem : frags) {
        openDrawer(R.id.drawer_layout);
        if (elem.equals(frags[frags.length / 2]))
            onView(withId(R.id.drawer_layout)).perform(swipeUp());
        onView(withText(elem)).perform(click());
    }
}

This test passes, the only problem is that it takes too long.

I even tried to override the swipeUp() method, by changing the parameters :

    private static ViewAction swipeUp() {
    return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.CENTER_LEFT,
            GeneralLocation.TOP_LEFT, Press.FINGER);
}

FYI, I'm swiping because the last element of my drawer isn't visible, so I can't perform onClick() on it without swiping. I swipe only for one element, maybe the method is made for more elements, that's why I tried with other locations.

Thank you in advance.

0

There are 0 answers