Skip to content

Commit

Permalink
Fix Unit Test to not depend on Android classes
Browse files Browse the repository at this point in the history
  • Loading branch information
MGaetan89 committed Nov 7, 2023
1 parent f9b685f commit 6be9381
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import androidx.media3.common.MediaItem
import androidx.media3.common.MediaMetadata
import ch.srgssr.pillarbox.core.business.exception.BlockReasonException
import ch.srgssr.pillarbox.core.business.exception.ResourceNotFoundException
import ch.srgssr.pillarbox.core.business.images.DefaultImageScalingService
import ch.srgssr.pillarbox.core.business.images.ImageScalingService
import ch.srgssr.pillarbox.core.business.integrationlayer.data.BlockReason
import ch.srgssr.pillarbox.core.business.integrationlayer.data.Chapter
import ch.srgssr.pillarbox.core.business.integrationlayer.data.MediaComposition
Expand All @@ -23,7 +23,7 @@ class MediaCompositionMediaItemSourceTest {

private val mediaItemSource = MediaCompositionMediaItemSource(
mediaCompositionDataSource = DummyMediaCompositionProvider(),
imageScalingService = DefaultImageScalingService()
imageScalingService = NoOpImageScalingService()
)

@Test(expected = IllegalArgumentException::class)
Expand Down Expand Up @@ -186,6 +186,12 @@ class MediaCompositionMediaItemSourceTest {
}
}

private class NoOpImageScalingService : ImageScalingService {
override fun getScaledImageUrl(imageUrl: String, width: ImageScalingService.ImageWidth, format: ImageScalingService.ImageFormat): String {
return imageUrl
}
}

companion object {
private fun createMediaItem(urn: String): MediaItem {
return MediaItem.Builder().setMediaId(urn).build()
Expand Down

0 comments on commit 6be9381

Please sign in to comment.