jeudi 21 février 2019

How to write test case for recyclerview drag and drop using espress

I am writing test cases for recyclerview. I am struck with drag and drop test in recyclerview. I tried in some way. But not able to write drag and drop test for recyclerview.

In recyclerview I am having drag button. Using of that button I am drag and drop the item on position to other position.

My code to swipe bottom to top

onView(withId(R.id.recyclerView)).perform(
                    RecyclerViewActions.actionOnItemAtPosition(0, new GeneralSwipeAction(
                            Swipe.SLOW, GeneralLocation.BOTTOM_CENTER, GeneralLocation.TOP_CENTER,
                            Press.FINGER)));

This code is swipe the recyclerview.

So I am trying like this:

onView(withId(R.id.recyclerView)).perform(
                RecyclerViewActions.actionOnItemAtPosition(0,
                        MyViewAction.clickChildViewWithId(R.id.img_drag)),new GeneralSwipeAction(
                        Swipe.SLOW, GeneralLocation.TOP_RIGHT, GeneralLocation.CENTER_RIGHT,
                        Press.FINGER));

But this is not workout to me. Please let me any idea to test the drag and drop functionality.

Aucun commentaire:

Enregistrer un commentaire