use of android.widget.PopupMenu in project materialistic by hidroh.
the class ItemFragmentSinglePageTest method testVoteItemPromptToLogin.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testVoteItemPromptToLogin() {
viewHolder.itemView.findViewById(R.id.button_more).performClick();
PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
assertNotNull(popupMenu);
shadowOf(popupMenu).getOnMenuItemClickListener().onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_vote));
verify(userServices).voteUp(any(Context.class), any(), voteCallback.capture());
voteCallback.getValue().onDone(false);
assertThat(shadowOf(activity).getNextStartedActivity()).hasComponent(activity, LoginActivity.class);
}
use of android.widget.PopupMenu in project materialistic by hidroh.
the class ListFragmentViewHolderTest method testReply.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testReply() {
verify(itemManager).getItem(any(), eq(ItemManager.MODE_DEFAULT), itemListener.capture());
itemListener.getValue().onResponse(item);
adapter.getViewHolder(0).itemView.performLongClick();
PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
assertNotNull(popupMenu);
shadowOf(popupMenu).getOnMenuItemClickListener().onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_comment));
assertThat(shadowOf(activity).getNextStartedActivity()).hasComponent(activity, ComposeActivity.class).hasExtra(ComposeActivity.EXTRA_PARENT_ID, "1");
}
use of android.widget.PopupMenu in project materialistic by hidroh.
the class ListFragmentViewHolderTest method testVoteItem.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testVoteItem() {
verify(itemManager).getItem(any(), eq(ItemManager.MODE_DEFAULT), itemListener.capture());
itemListener.getValue().onResponse(item);
adapter.getViewHolder(0).itemView.performLongClick();
PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
assertNotNull(popupMenu);
assertThat(popupMenu.getMenu().findItem(R.id.menu_contextual_vote).isVisible()).isFalse();
shadowOf(popupMenu).getOnMenuItemClickListener().onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_vote));
verify(userServices).voteUp(any(Context.class), eq(item.getId()), voteCallback.capture());
}
use of android.widget.PopupMenu in project materialistic by hidroh.
the class ListFragmentViewHolderTest method testRefresh.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testRefresh() {
verify(itemManager).getItem(any(), eq(ItemManager.MODE_DEFAULT), itemListener.capture());
itemListener.getValue().onResponse(item);
reset(itemManager);
adapter.getViewHolder(0).itemView.performLongClick();
PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
assertNotNull(popupMenu);
shadowOf(popupMenu).getOnMenuItemClickListener().onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_refresh));
verify(itemManager).getItem(any(), eq(ItemManager.MODE_DEFAULT), any());
}
use of android.widget.PopupMenu in project materialistic by hidroh.
the class ListFragmentViewHolderTest method testSaveItem.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testSaveItem() {
ShadowContentObserver observer = shadowOf(shadowOf(activity.getContentResolver()).getContentObservers(MaterialisticProvider.URI_FAVORITE).iterator().next());
verify(itemManager).getItem(any(), eq(ItemManager.MODE_DEFAULT), itemListener.capture());
itemListener.getValue().onResponse(item);
adapter.getViewHolder(0).itemView.performLongClick();
PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
assertNotNull(popupMenu);
assertThat(popupMenu.getMenu().findItem(R.id.menu_contextual_save).isVisible()).isFalse();
shadowOf(popupMenu).getOnMenuItemClickListener().onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_save));
verify(favoriteManager).add(any(Context.class), eq(item));
observer.dispatchChange(false, MaterialisticProvider.URI_FAVORITE.buildUpon().appendPath("add").appendPath("1").build());
assertTrue(item.isFavorite());
View snackbarView = ShadowSnackbar.getLatestView();
assertThat((TextView) snackbarView.findViewById(R.id.snackbar_text)).isNotNull().containsText(R.string.toast_saved);
snackbarView.findViewById(R.id.snackbar_action).performClick();
verify(favoriteManager).remove(any(Context.class), eq("1"));
observer.dispatchChange(false, MaterialisticProvider.URI_FAVORITE.buildUpon().appendPath("remove").appendPath("1").build());
assertFalse(item.isFavorite());
}
Aggregations