TweetMediaUtils { public static VideoInfo.Variant getSupportedVariant(MediaEntity mediaEntity) { for (VideoInfo.Variant variant : mediaEntity.videoInfo.variants) { if (isVariantSupported(variant)) { return variant; } } return null; } private  TweetMediaUtils(); static MediaEntity getPhotoEntity(Tweet tweet); static List<MediaEntity> getPhotoEntities(Tweet tweet); static boolean hasPhoto(Tweet tweet); static MediaEntity getVideoEntity(Tweet tweet); static boolean hasSupportedVideo(Tweet tweet); static VideoInfo.Variant getSupportedVariant(MediaEntity mediaEntity); static boolean isLooping(MediaEntity mediaEntity); static boolean showVideoControls(MediaEntity mediaEntity); static final String PHOTO_TYPE; static final String VIDEO_TYPE; static final String GIF_TYPE; }
@Test public void testGetSupportedVariant() { final VideoInfo.Variant variant = new VideoInfo.Variant(0, TEST_CONTENT_TYPE_MP4, null); final VideoInfo videoInfo = TestFixtures.createVideoInfoWithVariant(variant); final MediaEntity entity = TestFixtures.createEntityWithVideo(videoInfo); assertNotNull(TweetMediaUtils.getSupportedVariant(entity)); assertEquals(variant, TweetMediaUtils.getSupportedVariant(entity)); }
@Test public void testGetSupportedVariant_unsupportedContentType() { final VideoInfo.Variant variant = new VideoInfo.Variant(0, TEST_CONTENT_TYPE_DASH, null); final VideoInfo videoInfo = TestFixtures.createVideoInfoWithVariant(variant); final MediaEntity entity = TestFixtures.createEntityWithVideo(videoInfo); assertNull(TweetMediaUtils.getSupportedVariant(entity)); }