TweetMediaView extends ViewGroup implements View.OnClickListener { public void setTweetMediaEntities(Tweet tweet, List<MediaEntity> mediaEntities) { if (tweet == null || mediaEntities == null || mediaEntities.isEmpty() || mediaEntities.equals(this.mediaEntities)) { return; } this.tweet = tweet; this.mediaEntities = mediaEntities; clearImageViews(); initializeImageViews(mediaEntities); internalRoundedCornersEnabled = TweetMediaUtils.isPhotoType(mediaEntities.get(0)); requestLayout(); } TweetMediaView(Context context);  TweetMediaView(Context context, AttributeSet attrs);   TweetMediaView(Context context, AttributeSet attrs, DependencyProvider dependencyProvider); void setRoundedCornersRadii(int topLeft, int topRight, int bottomRight, int bottomLeft); void setMediaBgColor(int mediaBgColor); void setTweetMediaClickListener(TweetMediaClickListener tweetMediaClickListener); void setPhotoErrorResId(int photoErrorResId); @Override void onClick(View view); void launchVideoPlayer(MediaEntity entity); void launchVideoPlayer(Tweet tweet); void launchPhotoGallery(int mediaEntityIndex); void setTweetMediaEntities(Tweet tweet, List<MediaEntity> mediaEntities); void setVineCard(Tweet tweet);  }
@Test public void testSetTweetMediaEntities_withEmptyList() { final List<MediaEntity> emptyMediaEntities = Collections.EMPTY_LIST; tweetMediaView.setTweetMediaEntities(TestFixtures.TEST_TWEET, emptyMediaEntities); for (int index = 0; index < TweetMediaView.MAX_IMAGE_VIEW_COUNT; index++) { final ImageView imageView = (ImageView) tweetMediaView.getChildAt(index); assertNull(imageView); } }
@Test public void testSetTweetMediaEntities_withSingleEntity() { final MediaEntity entity = TestFixtures.createMediaEntityWithPhoto(100, 100); final List<MediaEntity> mediaEntities = new ArrayList<>(); mediaEntities.add(entity); tweetMediaView.setTweetMediaEntities(TestFixtures.TEST_TWEET, mediaEntities); final ImageView imageView = (ImageView) tweetMediaView.getChildAt(0); assertEquals(View.VISIBLE, imageView.getVisibility()); assertNull(tweetMediaView.getChildAt(1)); assertNull(tweetMediaView.getChildAt(2)); assertNull(tweetMediaView.getChildAt(3)); }
@Test public void testSetTweetMediaEntities_withMultipleEntities() { final List<MediaEntity> mediaEntities = TestFixtures.createMultipleMediaEntitiesWithPhoto (TweetMediaView.MAX_IMAGE_VIEW_COUNT, 100, 100); tweetMediaView.setTweetMediaEntities(TestFixtures.TEST_TWEET, mediaEntities); for (int index = 0; index < TweetMediaView.MAX_IMAGE_VIEW_COUNT; index++) { final ImageView imageView = (ImageView) tweetMediaView.getChildAt(index); assertEquals(View.VISIBLE, imageView.getVisibility()); assertEquals(index, imageView.getTag(R.id.tw__entity_index)); assertEquals(contentDefaultDescription, imageView.getContentDescription()); } }