Skip to content

Commit

Permalink
Audio main chapter always returns empty list of Player chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
StaehliJ committed Jun 6, 2024
1 parent cdd115e commit 75cc6a0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal object ChapterAdapter {

fun getChapters(mediaComposition: MediaComposition): List<TimeRangeChapter> {
val mainChapter = mediaComposition.mainChapter
if (!mainChapter.isFullLengthChapter && mainChapter.mediaType == MediaType.AUDIO) return emptyList()
if (mainChapter.mediaType == MediaType.AUDIO) return emptyList()
return mediaComposition.listChapter
.asSequence()
.filter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,24 @@ class ChapterAdapterTest {
assertEquals(emptyList(), ChapterAdapter.getChapters(mediaComposition))
}

@Test
fun `main chapter with other chapter`() {
val fullLengthChapter = Chapter(
urn = "urn",
title = "title",
lead = "lead",
description = "description",
imageUrl = "https://www.rts.ch/image.png",
mediaType = MediaType.VIDEO,
)
val chapter1 = fullLengthChapter.copy(urn = "urn:chapitre1")
val chapter2 = fullLengthChapter.copy(urn = "urn:chapitre2")
val mediaComposition = MediaComposition(
chapterUrn = "urn", listChapter = listOf(fullLengthChapter, chapter1, chapter2)
)
assertEquals(emptyList(), ChapterAdapter.getChapters(mediaComposition))
}

@Test
fun `main chapter with chapters return asset chapter list without main chapter`() {
val mainChapter = Chapter(
Expand Down Expand Up @@ -126,7 +144,7 @@ class ChapterAdapterTest {
}

@Test
fun `main audio chapter with chapters return empty asset chapter list`() {
fun `chapter audio with chapters return empty asset chapter list`() {
val fullLengthChapter = Chapter(
urn = "urn",
title = "title",
Expand All @@ -136,13 +154,31 @@ class ChapterAdapterTest {
mediaType = MediaType.AUDIO,
)
val chapter1 = fullLengthChapter.copy(urn = "urn:chapitre1", fullLengthMarkIn = 0, fullLengthMarkOut = 10, fullLengthUrn = "urn")
val chapter2 = fullLengthChapter.copy(urn = "urn:chapitre2", fullLengthMarkIn = 30, fullLengthMarkOut = 60, fullLengthUrn = "urn")
val chapter2 = fullLengthChapter.copy(urn = "urn:chapitre2", fullLengthUrn = "urn")
val mediaComposition = MediaComposition(
chapterUrn = "urn:chapitre1", listChapter = listOf(fullLengthChapter, chapter1, chapter2)
)
assertEquals(emptyList(), ChapterAdapter.getChapters(mediaComposition))
}

@Test
fun `main audio chapter with chapters return empty asset chapter list`() {
val fullLengthChapter = Chapter(
urn = "urn",
title = "title",
lead = "lead",
description = "description",
imageUrl = "https://www.rts.ch/image.png",
mediaType = MediaType.AUDIO,
)
val chapter1 = fullLengthChapter.copy(urn = "urn:chapitre1", fullLengthMarkIn = 0, fullLengthMarkOut = 10, fullLengthUrn = "urn")
val chapter2 = fullLengthChapter.copy(urn = "urn:chapitre2", fullLengthMarkIn = 0, fullLengthMarkOut = 10, fullLengthUrn = "urn")
val mediaComposition = MediaComposition(
chapterUrn = "urn", listChapter = listOf(fullLengthChapter, chapter1, chapter2)
)
assertEquals(emptyList(), ChapterAdapter.getChapters(mediaComposition))
}

@Test
fun `main video chapter with mixed audio and video chapters return only video chapters`() {
val fullLengthChapter = Chapter(
Expand Down

0 comments on commit 75cc6a0

Please sign in to comment.