Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ListHelperTest failure caused by immutable list being used #8679

Merged
merged 1 commit into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions app/src/main/java/org/schabi/newpipe/util/ListHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,15 @@ private static String computeDefaultResolution(final Context context, final int
}

/**
* Return the index of the default stream in the list, based on the parameters
* defaultResolution and defaultFormat.
* Return the index of the default stream in the list, that will be sorted in the process, based
* on the parameters defaultResolution and defaultFormat.
*
* @param defaultResolution the default resolution to look for
* @param bestResolutionKey key of the best resolution
* @param defaultFormat the default format to look for
* @param videoStreams list of the video streams to check
* @return index of the default resolution&format
* @param videoStreams a mutable list of the video streams to check (it will be sorted in
* place)
* @return index of the default resolution&format in the sorted videoStreams
*/
static int getDefaultResolutionIndex(final String defaultResolution,
final String bestResolutionKey,
Expand Down
4 changes: 2 additions & 2 deletions app/src/test/java/org/schabi/newpipe/util/ListHelperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ public void getSortedStreamVideosExceptHighResolutionsTest() {

@Test
public void getDefaultResolutionTest() {
final List<VideoStream> testList = List.of(
final List<VideoStream> testList = new ArrayList<>(List.of(
generateVideoStream("mpeg_4-720", MediaFormat.MPEG_4, "720p", false),
generateVideoStream("v3gpp-240", MediaFormat.v3GPP, "240p", false),
generateVideoStream("webm-480", MediaFormat.WEBM, "480p", false),
generateVideoStream("webm-240", MediaFormat.WEBM, "240p", false),
generateVideoStream("mpeg_4-240", MediaFormat.MPEG_4, "240p", false),
generateVideoStream("webm-144", MediaFormat.WEBM, "144p", false),
generateVideoStream("mpeg_4-360", MediaFormat.MPEG_4, "360p", false),
generateVideoStream("webm-360", MediaFormat.WEBM, "360p", false));
generateVideoStream("webm-360", MediaFormat.WEBM, "360p", false)));
VideoStream result = testList.get(ListHelper.getDefaultResolutionIndex(
"720p", BEST_RESOLUTION_KEY, MediaFormat.MPEG_4, testList));
assertEquals("720p", result.getResolution());
Expand Down