-
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.
Add an helper method to create an SRG test player
- Loading branch information
Showing
3 changed files
with
41 additions
and
24 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
...rbox-core-business/src/test/java/ch/srgssr/pillarbox/core/business/PillarboxTestPlayer.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,36 @@ | ||
/* | ||
* Copyright (c) SRG SSR. All rights reserved. | ||
* License information is available from the LICENSE file. | ||
*/ | ||
package ch.srgssr.pillarbox.core.business | ||
|
||
import android.content.Context | ||
import androidx.media3.common.C | ||
import androidx.media3.exoplayer.DefaultLoadControl | ||
import androidx.media3.test.utils.FakeClock | ||
import androidx.test.core.app.ApplicationProvider | ||
import ch.srgssr.pillarbox.player.PillarboxDsl | ||
import ch.srgssr.pillarbox.player.PillarboxExoPlayer | ||
import kotlin.coroutines.EmptyCoroutineContext | ||
|
||
/** | ||
* Pillarbox ExoPlayer | ||
* | ||
* @param context The [Context], by default [ApplicationProvider.getApplicationContext] | ||
* @param block The block to further configure the [PillarboxExoPlayer]. | ||
* @return [PillarboxExoPlayer] configured for tests. | ||
*/ | ||
@PillarboxDsl | ||
fun PillarboxExoPlayer(context: Context = ApplicationProvider.getApplicationContext(), block: SRG.Builder.() -> Unit = {}): PillarboxExoPlayer { | ||
return PillarboxExoPlayer(context, SRG) { | ||
loadControl(DefaultLoadControl()) | ||
clock(FakeClock(true)) | ||
coroutineContext(EmptyCoroutineContext) | ||
block() | ||
}.apply { | ||
// FIXME Investigate why we need to disable the image track in tests | ||
trackSelectionParameters = trackSelectionParameters.buildUpon() | ||
.setTrackTypeDisabled(C.TRACK_TYPE_IMAGE, true) | ||
.build() | ||
} | ||
} |
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