MediaBadgeView extends FrameLayout { public void setMediaEntity(MediaEntity entity) { if (TweetMediaUtils.GIF_TYPE.equals(entity.type)) { setBadge(getResources().getDrawable(R.drawable.tw__gif_badge)); } else if (TweetMediaUtils.VIDEO_TYPE.equals(entity.type)) { final long duration = entity.videoInfo == null ? 0 : entity.videoInfo.durationMillis; setText(duration); } else { setEmpty(); } } MediaBadgeView(Context context);  MediaBadgeView(Context context, AttributeSet attrs);  MediaBadgeView(Context context, AttributeSet attrs, int defStyleAttr); void setMediaEntity(MediaEntity entity); void setCard(Card card);  }
@Test public void testSetMediaEntity_withAnimatedGif() { final MediaEntity entity = TestFixtures.createEntityWithAnimatedGif(null); view.setMediaEntity(entity); assertEquals(View.VISIBLE, view.badge.getVisibility()); assertEquals(View.GONE, view.videoDuration.getVisibility()); }
@Test public void testSetMediaEntity_withVideo() { final VideoInfo videoInfo = new VideoInfo(null, 1000, null); final MediaEntity entity = TestFixtures.createEntityWithVideo(videoInfo); view.setMediaEntity(entity); assertEquals(View.GONE, view.badge.getVisibility()); assertEquals(View.VISIBLE, view.videoDuration.getVisibility()); assertEquals("0:01", view.videoDuration.getText()); }
@Test public void testSetMediaEntity_withNullVideoInfo() { final MediaEntity entity = TestFixtures.createEntityWithVideo(null); view.setMediaEntity(entity); assertEquals(View.GONE, view.badge.getVisibility()); assertEquals(View.VISIBLE, view.videoDuration.getVisibility()); assertEquals("0:00", view.videoDuration.getText()); }
@Test public void testSetMediaEntity_withImage() { final MediaEntity entity = TestFixtures.createMediaEntityWithPhoto(null); view.setMediaEntity(entity); assertEquals(View.GONE, view.badge.getVisibility()); assertEquals(View.GONE, view.videoDuration.getVisibility()); }