ListHelper { public static int getDefaultResolutionIndex(final Context context, final List<VideoStream> videoStreams) { final String defaultResolution = computeDefaultResolution(context, R.string.default_resolution_key, R.string.default_resolution_value); return getDefaultResolutionWithDefaultFormat(context, defaultResolution, videoStreams); } private  ListHelper(); static int getDefaultResolutionIndex(final Context context,
                                                final List<VideoStream> videoStreams); static int getResolutionIndex(final Context context,
                                         final List<VideoStream> videoStreams,
                                         final String defaultResolution); static int getPopupDefaultResolutionIndex(final Context context,
                                                     final List<VideoStream> videoStreams); static int getPopupResolutionIndex(final Context context,
                                              final List<VideoStream> videoStreams,
                                              final String defaultResolution); static int getDefaultAudioFormat(final Context context,
                                            final List<AudioStream> audioStreams); static List<VideoStream> getSortedStreamVideosList(final Context context,
                                                              final List<VideoStream> videoStreams,
                                                              final List<VideoStream>
                                                                      videoOnlyStreams,
                                                              final boolean ascendingOrder); static boolean isMeteredNetwork(final Context context);  }
@Test public void getDefaultResolutionTest() { final List<VideoStream> testList = Arrays.asList( new VideoStream("", MediaFormat.MPEG_4, "720p"), new VideoStream("", MediaFormat.v3GPP, "240p"), new VideoStream("", MediaFormat.WEBM, "480p"), new VideoStream("", MediaFormat.WEBM, "240p"), new VideoStream("", MediaFormat.MPEG_4, "240p"), new VideoStream("", MediaFormat.WEBM, "144p"), new VideoStream("", MediaFormat.MPEG_4, "360p"), new VideoStream("", MediaFormat.WEBM, "360p")); VideoStream result = testList.get(ListHelper.getDefaultResolutionIndex( "720p", BEST_RESOLUTION_KEY, MediaFormat.MPEG_4, testList)); assertEquals("720p", result.resolution); assertEquals(MediaFormat.MPEG_4, result.getFormat()); result = testList.get(ListHelper.getDefaultResolutionIndex( "480p", BEST_RESOLUTION_KEY, MediaFormat.WEBM, testList)); assertEquals("480p", result.resolution); assertEquals(MediaFormat.WEBM, result.getFormat()); result = testList.get(ListHelper.getDefaultResolutionIndex( "480p", BEST_RESOLUTION_KEY, MediaFormat.MPEG_4, testList)); assertEquals("480p", result.resolution); assertEquals(MediaFormat.WEBM, result.getFormat()); result = testList.get(ListHelper.getDefaultResolutionIndex( "240p", BEST_RESOLUTION_KEY, MediaFormat.WEBM, testList)); assertEquals("240p", result.resolution); assertEquals(MediaFormat.WEBM, result.getFormat()); result = testList.get(ListHelper.getDefaultResolutionIndex( BEST_RESOLUTION_KEY, BEST_RESOLUTION_KEY, MediaFormat.WEBM, testList)); assertEquals("720p", result.resolution); assertEquals(MediaFormat.MPEG_4, result.getFormat()); result = testList.get(ListHelper.getDefaultResolutionIndex( "720p60", BEST_RESOLUTION_KEY, MediaFormat.WEBM, testList)); assertEquals("720p", result.resolution); assertEquals(MediaFormat.MPEG_4, result.getFormat()); result = testList.get(ListHelper.getDefaultResolutionIndex( "480p60", BEST_RESOLUTION_KEY, MediaFormat.WEBM, testList)); assertEquals("480p", result.resolution); assertEquals(MediaFormat.WEBM, result.getFormat()); result = testList.get(ListHelper.getDefaultResolutionIndex( "2160p60", BEST_RESOLUTION_KEY, MediaFormat.WEBM, testList)); assertEquals("720p", result.resolution); assertEquals(MediaFormat.MPEG_4, result.getFormat()); }