use of org.robolectric.fakes.RoboMenuItem in project materialistic by hidroh.
the class ListFragmentViewHolderTest method testVoteItemFailed.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testVoteItemFailed() {
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_vote));
verify(userServices).voteUp(any(Context.class), eq(item.getId()), voteCallback.capture());
voteCallback.getValue().onError(new IOException());
assertEquals(activity.getString(R.string.vote_failed), ShadowToast.getTextOfLatestToast());
}
use of org.robolectric.fakes.RoboMenuItem in project materialistic by hidroh.
the class ListFragmentViewHolderTest method testViewUser.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testViewUser() {
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_profile));
assertThat(shadowOf(activity).getNextStartedActivity()).hasComponent(activity, UserActivity.class).hasExtra(UserActivity.EXTRA_USERNAME, "author");
}
use of org.robolectric.fakes.RoboMenuItem in project materialistic by hidroh.
the class ListFragmentViewHolderTest method testVoteItemPromptToLogin.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testVoteItemPromptToLogin() {
verify(itemManager).getItem(any(), eq(ItemManager.MODE_DEFAULT), itemListener.capture());
itemListener.getValue().onResponse(item);
adapter.getViewHolder(0).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), eq(item.getId()), voteCallback.capture());
voteCallback.getValue().onDone(false);
assertThat(shadowOf(activity).getNextStartedActivity()).hasComponent(activity, LoginActivity.class);
}
use of org.robolectric.fakes.RoboMenuItem in project materialistic by hidroh.
the class ListFragmentViewHolderTest method testShare.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testShare() {
TestApplication.addResolver(new Intent(Intent.ACTION_SEND));
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_share));
assertThat(shadowOf(activity).getNextStartedActivity()).hasAction(Intent.ACTION_SEND);
}
use of org.robolectric.fakes.RoboMenuItem in project materialistic by hidroh.
the class ItemFragmentMultiPageTest method testDisplayMenu.
@Test
public void testDisplayMenu() {
WebItem webItem = mock(WebItem.class);
when(webItem.getId()).thenReturn("1");
Bundle args = new Bundle();
args.putParcelable(ItemFragment.EXTRA_ITEM, webItem);
Fragment fragment = Fragment.instantiate(RuntimeEnvironment.application, ItemFragment.class.getName(), args);
makeVisible(fragment);
fragment.onOptionsItemSelected(new RoboMenuItem(R.id.menu_comments));
assertThat(fragment.getFragmentManager()).hasFragmentWithTag(PopupSettingsFragment.class.getName());
}
Aggregations