-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
89 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/TestUnsupportedTracks.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2023. SRG SSR. All rights reserved. | ||
* License information is available from the LICENSE file. | ||
*/ | ||
package ch.srgssr.pillarbox.player | ||
|
||
import androidx.media3.common.C | ||
import androidx.media3.common.Format | ||
import androidx.media3.common.MimeTypes | ||
import androidx.media3.common.TrackGroup | ||
import androidx.media3.common.Tracks | ||
import ch.srgssr.pillarbox.player.extension.filterUnsupported | ||
import org.junit.Assert | ||
import org.junit.Test | ||
|
||
class TestUnsupportedTracks { | ||
|
||
@Test | ||
fun test1() { | ||
val format1 = createSampleFormat("F1") | ||
val format2 = createSampleFormat("F2") | ||
val formatUnsupportedTrack = createSampleFormat("Unsupported") | ||
val listFormat = listOf(format1, format2, formatUnsupportedTrack) | ||
val trackGroup = TrackGroup(*listFormat.toTypedArray()) | ||
val selected = BooleanArray(listFormat.size) | ||
val trackSupport = IntArray(listFormat.size) | ||
trackSupport[0] = C.FORMAT_HANDLED | ||
trackSupport[1] = C.FORMAT_HANDLED | ||
trackSupport[2] = C.FORMAT_UNSUPPORTED_SUBTYPE | ||
val tracks = Tracks(listOf(Tracks.Group(trackGroup, false, trackSupport, selected))) | ||
|
||
val expectedTracksGroups = listOf( | ||
Tracks.Group( | ||
TrackGroup(*listOf(format1, format2).toTypedArray()), false, IntArray(2){ | ||
C.FORMAT_HANDLED | ||
}, BooleanArray | ||
(2) | ||
) | ||
) | ||
Assert.assertEquals(expectedTracksGroups, tracks.groups.mapNotNull { it.filterUnsupported() }) | ||
} | ||
|
||
companion object { | ||
private fun createSampleFormat( | ||
label: String | ||
): | ||
Format { | ||
return Format.Builder() | ||
.setId("id:${label}") | ||
.setLabel(label) | ||
.setContainerMimeType(MimeTypes.AUDIO_MP4) | ||
.build() | ||
} | ||
} | ||
|
||
} |