Skip to content

Commit

Permalink
Add timeout to every test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
StaehliJ committed Aug 25, 2023
1 parent 444add5 commit 4aec9a8
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import ch.srgssr.pillarbox.player.PillarboxPlayer
import ch.srgssr.pillarbox.player.test.utils.TestPlayer
import ch.srgssr.pillarbox.player.tracker.MediaItemTrackerRepository
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.runTest
Expand All @@ -29,7 +28,6 @@ import kotlin.math.abs
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds

@OptIn(ExperimentalCoroutinesApi::class)
class CommandersActTrackerTest {
private lateinit var commandersActDelegate: CommandersActDelegate

Expand Down Expand Up @@ -61,7 +59,7 @@ class CommandersActTrackerTest {
}

@Test
fun testStartEoF() = runTest {
fun testStartEoF() = runTest(timeout = TEST_TIMEOUT) {
val expected = listOf(
MediaEventType.Play.toString(),
MediaEventType.Eof.toString()
Expand All @@ -77,7 +75,7 @@ class CommandersActTrackerTest {
}

@Test
fun testPlayStop() = runTest {
fun testPlayStop() = runTest(timeout = TEST_TIMEOUT) {
val expected = listOf(
MediaEventType.Play.toString(),
MediaEventType.Stop.toString()
Expand All @@ -90,7 +88,7 @@ class CommandersActTrackerTest {
}

@Test
fun testPlaySeekPlay() = runTest {
fun testPlaySeekPlay() = runTest(timeout = TEST_TIMEOUT) {
val seekPositionMs = 2_000L
val expectedEvents = listOf(
CommandersActDelegate.Event(MediaEventType.Play.toString(), 0L),
Expand All @@ -111,7 +109,7 @@ class CommandersActTrackerTest {
* Seek event is not send but play event position should be the seek position.
*/
@Test
fun testPausePlaySeekPlay() = runTest {
fun testPausePlaySeekPlay() = runTest(timeout = TEST_TIMEOUT) {
val seekPositionMs = 2_000L
val expected = listOf(
CommandersActDelegate.Event(MediaEventType.Play.toString(), seekPositionMs.milliseconds.inWholeSeconds),
Expand All @@ -127,7 +125,7 @@ class CommandersActTrackerTest {
}

@Test
fun testPlayPauseSeekPause() = runTest {
fun testPlayPauseSeekPause() = runTest(timeout = TEST_TIMEOUT) {
val seekPositionMs = 4_000L
val expected = listOf(
MediaEventType.Play.toString(),
Expand Down Expand Up @@ -186,7 +184,7 @@ class CommandersActTrackerTest {

@FlakyTest(detail = "POS and UPTIME not always send due to timers")
@Test
fun testUpTimeLiveWithDvr() = runTest {
fun testUpTimeLiveWithDvr() = runTest(timeout = TEST_TIMEOUT) {
val expected = listOf(
MediaEventType.Uptime.toString(),
MediaEventType.Uptime.toString(),
Expand Down Expand Up @@ -221,7 +219,7 @@ class CommandersActTrackerTest {
}

@Test
fun testPauseSeekPause() = runTest {
fun testPauseSeekPause() = runTest(timeout = TEST_TIMEOUT) {
val seekPositionMs = 4_000L
launch(Dispatchers.Main) {
val player = createPlayerWithUrn(LocalMediaCompositionDataSource.Vod, false)
Expand Down

0 comments on commit 4aec9a8

Please sign in to comment.