@Test public void testDoesNotReturnOriginalDrawableOnGet() { when(drawable.getConstantState()).thenReturn(mock(Drawable.ConstantState.class)); assertNotEquals(drawable, resource.get()); }
@Test public void get_withNullState_returnsOriginalDrawable() { when(drawable.getConstantState()).thenReturn(null); assertThat(resource.get()).isEqualTo(drawable); }
@Test public void testReturnsNewDrawableOnGet() { GifDrawable expected = mock(GifDrawable.class); Drawable.ConstantState constantState = mock(Drawable.ConstantState.class); when(constantState.newDrawable()).thenReturn(expected); when(drawable.getConstantState()).thenReturn(constantState); assertThat(resource.get()).isEqualTo(expected); verify(drawable).getConstantState(); verify(constantState).newDrawable(); }