ImageInteractionPresenter { public final void enableInteractions(Context context) { mInteractionRequester = getNewInstanceOfRequester(context, new InteractionRequestHandler()); initializeInteractionListeners(); toggleInteractionButtons(true); } protected  ImageInteractionPresenter(int imageId,
                                        @Nullable AccentColorIconButton scoreButton,
                                        @Nullable AccentColorIconButton faveButton,
                                        @Nullable AccentColorIconButton upvoteButton,
                                        @Nullable AccentColorIconButton downvoteButton); final void enableInteractions(Context context); void refreshInfo(int faves, int upvotes, int downvotes);  }
@Test public void testInitialState() { assertThat(scoreButton.isEnabled(), is(false)); assertThat(faveButton.isEnabled(), is(false)); assertThat(upvoteButton.isEnabled(), is(false)); assertThat(downvoteButton.isEnabled(), is(false)); presenter.enableInteractions(context); assertThat(scoreButton.isEnabled(), is(false)); assertThat(faveButton.isEnabled(), is(true)); assertThat(upvoteButton.isEnabled(), is(true)); assertThat(downvoteButton.isEnabled(), is(true)); }
@Test public void testInteractions() { presenter.enableInteractions(context); testInteraction(DerpibooruImageInteraction.InteractionType.Fave, new Runnable() { @Override public void run() { assertThat(faveButton.isActive(), is(true)); assertThat(upvoteButton.isActive(), is(true)); assertThat(downvoteButton.isActive(), is(false)); } }); faveButton.performClick(); testInteraction(DerpibooruImageInteraction.InteractionType.ClearFave, new Runnable() { @Override public void run() { assertThat(faveButton.isActive(), is(false)); assertThat(upvoteButton.isActive(), is(true)); assertThat(downvoteButton.isActive(), is(false)); } }); faveButton.performClick(); testInteraction(DerpibooruImageInteraction.InteractionType.Downvote, new Runnable() { @Override public void run() { assertThat(faveButton.isActive(), is(false)); assertThat(upvoteButton.isActive(), is(false)); assertThat(downvoteButton.isActive(), is(true)); } }); downvoteButton.performClick(); testInteraction(DerpibooruImageInteraction.InteractionType.Upvote, new Runnable() { @Override public void run() { assertThat(faveButton.isActive(), is(false)); assertThat(upvoteButton.isActive(), is(true)); assertThat(downvoteButton.isActive(), is(false)); } }); upvoteButton.performClick(); testInteraction(DerpibooruImageInteraction.InteractionType.ClearVote, new Runnable() { @Override public void run() { assertThat(faveButton.isActive(), is(false)); assertThat(upvoteButton.isActive(), is(false)); assertThat(downvoteButton.isActive(), is(false)); } }); upvoteButton.performClick(); }