lundi 22 février 2016

How can I write Junit for Context Menu in android studio?

@Test
public void testContextMenuOnFileItemClick()
{


    onView(withId(R.id.fab)).check(matches(isDisplayed()));
    onView(withId(R.id.fab)).perform(click());
    onView(withText("Username")).check(matches(isDisplayed()));
    pressBack();
    onView(withId(R.id.pager)).perform(swipeLeft());

    final ListView list = (ListView) mActivity.findViewById(R.id.file_list);
    assertNotNull("The list was not loaded", list);

    mActivity.runOnUiThread(new Runnable() {
        @Override
        public void run() {

            list.performItemClick(
                    list.getAdapter().getView(0, null, null),
                    0, list.getAdapter().getItemId(0));

        }
    });
}

Now after performing Item Click, a context menu appears. How to interact with that and write JUnit to test for each menu item selection/operation?

Aucun commentaire:

Enregistrer un commentaire