List of usage examples for android.app Instrumentation invokeContextMenuAction
public boolean invokeContextMenuAction(Activity targetActivity, int id, int flag)
From source file:org.barbon.mangaget.MainTest.java
public void testRemoveManga() { Instrumentation instr = getInstrumentation(); UiUtils.selectListAndMoveToTop(mangaList.getListView()); UiUtils.moveDown();/*from www . ja v a 2s . com*/ UiUtils.selectCurrent(); // sanity check assertEquals(2, mangaList.getListView().getCount()); assertTrue(instr.invokeContextMenuAction(activity, R.id.delete, 0)); // click on confirmation dialog for (;;) { if (UiUtils.clickAlertDialog(DeleteConfirmationDialog.find(mangaList), DialogInterface.BUTTON_POSITIVE)) break; UiUtils.sleep(500); } DB db = DB.getInstance(null); // wait until refresh completes for (;;) { Cursor cursor = db.getSubscribedMangaList(); int count = cursor.getCount(); cursor.close(); if (count == 1) break; UiUtils.sleep(500); } UiUtils.waitForIdle(2000); // check chapter list has been refreshed assertEquals(1, mangaList.getListView().getCount()); }
From source file:org.barbon.mangaget.SearchTest.java
public void testMangaAdd() { Instrumentation instr = getInstrumentation(); setActivityIntent(searchIntent("")); setActivity(UiUtils.forceHorizontal(getActivity())); refreshMembers();/*from w w w . ja v a2 s . c om*/ ListView resultList = results.getListView(); while (resultList.getCount() == 0) UiUtils.sleep(500); assertEquals(49, resultList.getCount()); UiUtils.selectListAndMoveToTop(resultList); UiUtils.moveDown(); UiUtils.selectCurrent(); int prev_count = mangaCount(); instr.invokeContextMenuAction(activity, R.id.add_manga, 0); while (mangaCount() == prev_count) UiUtils.sleep(500); assertEquals(prev_count + 1, mangaCount()); }