TranslationCardItem extends LinearLayout { public void setDeleteClickListener(OnClickListener listener){ if(!deckService.currentDeck().isLocked()) { this.deleteButton.setOnClickListener(listener); } } TranslationCardItem(Context context);  TranslationCardItem(Context context, AttributeSet attrs);  TranslationCardItem(Context context, AttributeSet attrs, int defStyleAttr); void setTranslation(Translation translation, String language); void setTranslation(Translation translation, String language, int index); void setEditClickListener(OnClickListener listener); void setDeleteClickListener(OnClickListener listener); void setCardExpanded(boolean cardExpanded); void setShowDeleteAndEditOptions(boolean showDeleteAndEditOptions); void setGreyOutIfNoAudio(boolean greyOutIfNoAudio); Translation getTranslation(); static final int DISABLED_OPACITY; static final int DEFAULT_OPACITY; }
@Test public void shouldSetDeleteClickListenerIfCardNotLocked() { TranslationCardItem translationCardItem = getDefaultTranslationCard(); View.OnClickListener deleteListener = mock(View.OnClickListener.class); translationCardItem.setDeleteClickListener(deleteListener); translationCardItem.findViewById(R.id.translation_card_delete).performClick(); verify(deleteListener).onClick(any(View.class)); }
@Test public void shouldNotSetDeleteClickListenerIfCardLocked() { Deck basicDeck = new Deck("Test Deck", "", "1", 1, true, "Language"); when(deckService.currentDeck()).thenReturn(basicDeck); TranslationCardItem translationCardItem = getDefaultTranslationCard(); View.OnClickListener deleteListener = mock(View.OnClickListener.class); translationCardItem.setDeleteClickListener(deleteListener); translationCardItem.findViewById(R.id.translation_card_delete).performClick(); verifyZeroInteractions(deleteListener); }