Skip to content

Commit

Permalink
Add SRGAssetLoader canLoadAsset tests
Browse files Browse the repository at this point in the history
  • Loading branch information
StaehliJ committed Dec 16, 2024
1 parent 0f41ada commit 551e56b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class SRGAssetLoader internal constructor(

override fun canLoadAsset(mediaItem: MediaItem): Boolean {
val localConfiguration = mediaItem.localConfiguration ?: return false
return localConfiguration.mimeType == MimeTypeSrg && kotlin.runCatching {
return localConfiguration.mimeType == MimeTypeSrg && runCatching {
localConfiguration.uri.toIlUrl()
}.isSuccess
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import ch.srgssr.pillarbox.core.business.integrationlayer.data.Segment
import ch.srgssr.pillarbox.core.business.integrationlayer.data.TimeInterval
import ch.srgssr.pillarbox.core.business.integrationlayer.data.TimeIntervalType
import ch.srgssr.pillarbox.core.business.integrationlayer.service.MediaCompositionService
import ch.srgssr.pillarbox.core.business.source.MimeTypeSrg
import ch.srgssr.pillarbox.core.business.source.SRGAssetLoader
import ch.srgssr.pillarbox.core.business.source.SegmentAdapter
import ch.srgssr.pillarbox.core.business.source.TimeIntervalAdapter
Expand Down Expand Up @@ -51,6 +52,20 @@ class SRGAssetLoaderTest {
}
}

@Test
fun testCanLoadMediaItem() {
assertFalse(assetLoader.canLoadAsset(MediaItem.EMPTY))
assertFalse(
assetLoader.canLoadAsset(
MediaItem.Builder()
.setMimeType(MimeTypeSrg)
.setUri("https://fake.il/mediaComposition/urn:rts:video:123/path")
.build()
)
)
assertTrue(assetLoader.canLoadAsset(SRGMediaItem("urn:rts:video:123")))
}

@Test(expected = IllegalStateException::class)
fun testNoMediaId() = runTest {
assetLoader.loadAsset(MediaItem.Builder().build())
Expand Down

0 comments on commit 551e56b

Please sign in to comment.