I am trying to test my activity using either ActivityUnitTestCase or ActivityInstrumentationTestCase2. In the activity I want to test my
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
menu.setHeaderTitle(R.string.lcMenuHeader);
menu.add(Menu.NONE, EDIT_MENU_POS, EDIT_MENU_POS, R.string.lcEditAccount);
menu.add(Menu.NONE, COPY_MENU_POS, COPY_MENU_POS, R.string.lcCopyAccount);
menu.add(Menu.NONE, DELETE_MENU_POS, DELETE_MENU_POS, R.string.lcDeleteAccount);
}
How can I test that the menu is in the right state – ie. 3 items and a given header? I can trigger it being created in my ActivityInstrumentationTestCase2 test using
textView.performLongClick();
But I don’t know how to get it back.
Thanks
Stephen
In the end, I used reflection with the ActivityUnitTestCase test case:
With the mock menu looking like: