diff --git a/pillarbox-core-business/src/test/java/ch/srgssr/pillarbox/core/business/tracker/commandersact/CommandersActTrackerIntegrationTest.kt b/pillarbox-core-business/src/test/java/ch/srgssr/pillarbox/core/business/tracker/commandersact/CommandersActTrackerIntegrationTest.kt index 7389e6d2e..7c2af9308 100644 --- a/pillarbox-core-business/src/test/java/ch/srgssr/pillarbox/core/business/tracker/commandersact/CommandersActTrackerIntegrationTest.kt +++ b/pillarbox-core-business/src/test/java/ch/srgssr/pillarbox/core/business/tracker/commandersact/CommandersActTrackerIntegrationTest.kt @@ -409,7 +409,7 @@ class CommandersActTrackerIntegrationTest { assertEquals(Stop, it.eventType) assertTrue(it.assets.isNotEmpty()) assertNull(it.sourceId) - assertEquals(position, it.mediaPosition) + assertEquals(position.inWholeMinutes, it.mediaPosition.inWholeMinutes) } tcMediaEvents[1].let { @@ -450,7 +450,7 @@ class CommandersActTrackerIntegrationTest { assertEquals(Stop, it.eventType) assertTrue(it.assets.isNotEmpty()) assertNull(it.sourceId) - assertEquals(position, it.mediaPosition) + assertEquals(position.inWholeMinutes, it.mediaPosition.inWholeMinutes) } tcMediaEvents[1].let { diff --git a/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/PlayerCallbackFlowTest.kt b/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/PlayerCallbackFlowTest.kt index 1f435e0d7..1ec061eab 100644 --- a/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/PlayerCallbackFlowTest.kt +++ b/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/PlayerCallbackFlowTest.kt @@ -5,6 +5,7 @@ package ch.srgssr.pillarbox.player import android.content.Context +import android.os.Looper import androidx.media3.common.C import androidx.media3.common.MediaItem import androidx.media3.common.Player @@ -17,6 +18,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import app.cash.turbine.test import kotlinx.coroutines.test.runTest import org.junit.runner.RunWith +import org.robolectric.Shadows.shadowOf import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.Test @@ -45,6 +47,7 @@ class PlayerCallbackFlowTest { @AfterTest fun tearDown() { player.release() + shadowOf(Looper.getMainLooper()).idle() } @Test diff --git a/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/TestPillarboxExoPlayerPlaybackSpeed.kt b/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/TestPillarboxExoPlayerPlaybackSpeed.kt index 9abff8b6c..21993fca6 100644 --- a/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/TestPillarboxExoPlayerPlaybackSpeed.kt +++ b/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/TestPillarboxExoPlayerPlaybackSpeed.kt @@ -5,6 +5,7 @@ package ch.srgssr.pillarbox.player import android.content.Context +import android.os.Looper import androidx.media3.common.C import androidx.media3.common.MediaItem import androidx.media3.common.Player @@ -20,6 +21,7 @@ import org.junit.Assert import org.junit.Before import org.junit.Test import org.junit.runner.RunWith +import org.robolectric.Shadows.shadowOf @RunWith(AndroidJUnit4::class) class TestPillarboxExoPlayerPlaybackSpeed { @@ -37,6 +39,7 @@ class TestPillarboxExoPlayerPlaybackSpeed { @After fun releasePlayer() { player.release() + shadowOf(Looper.getMainLooper()).idle() } @Test diff --git a/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/tracker/BlockedTimeRangeTrackerTest.kt b/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/tracker/BlockedTimeRangeTrackerTest.kt index aa7a1b90a..ea51b5b95 100644 --- a/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/tracker/BlockedTimeRangeTrackerTest.kt +++ b/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/tracker/BlockedTimeRangeTrackerTest.kt @@ -5,6 +5,7 @@ package ch.srgssr.pillarbox.player.tracker import android.content.Context +import android.os.Looper import androidx.media3.common.MediaItem import androidx.media3.common.Player import androidx.media3.exoplayer.DefaultLoadControl @@ -25,6 +26,7 @@ import io.mockk.spyk import io.mockk.verify import io.mockk.verifyOrder import org.junit.runner.RunWith +import org.robolectric.Shadows.shadowOf import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.Test @@ -60,6 +62,7 @@ class BlockedTimeRangeTrackerTest { fun releasePlayer() { player.removeListener(listener) player.release() + shadowOf(Looper.getMainLooper()).idle() clearAllMocks() } diff --git a/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/tracker/ChapterTrackerTest.kt b/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/tracker/ChapterTrackerTest.kt index 6faab17e8..f1f9c440c 100644 --- a/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/tracker/ChapterTrackerTest.kt +++ b/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/tracker/ChapterTrackerTest.kt @@ -5,6 +5,7 @@ package ch.srgssr.pillarbox.player.tracker import android.content.Context +import android.os.Looper import androidx.media3.common.MediaItem import androidx.media3.common.MediaMetadata import androidx.media3.common.Player @@ -26,6 +27,7 @@ import io.mockk.spyk import io.mockk.verify import io.mockk.verifyOrder import org.junit.runner.RunWith +import org.robolectric.Shadows.shadowOf import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.Test @@ -60,6 +62,7 @@ class ChapterTrackerTest { fun releasePlayer() { player.removeListener(listener) player.release() + shadowOf(Looper.getMainLooper()).idle() clearAllMocks() } diff --git a/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/tracker/CurrentMediaItemPillarboxDataTrackerTest.kt b/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/tracker/CurrentMediaItemPillarboxDataTrackerTest.kt index 3c53a834a..fcf803a6b 100644 --- a/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/tracker/CurrentMediaItemPillarboxDataTrackerTest.kt +++ b/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/tracker/CurrentMediaItemPillarboxDataTrackerTest.kt @@ -5,6 +5,7 @@ package ch.srgssr.pillarbox.player.tracker import android.content.Context +import android.os.Looper import androidx.media3.common.Player import androidx.media3.exoplayer.ExoPlayer import androidx.media3.test.utils.FakeClock @@ -18,6 +19,7 @@ import io.mockk.confirmVerified import io.mockk.mockk import io.mockk.verifyOrder import org.junit.runner.RunWith +import org.robolectric.Shadows.shadowOf import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.Test @@ -49,6 +51,7 @@ class CurrentMediaItemPillarboxDataTrackerTest { @AfterTest fun tearDown() { player.release() + shadowOf(Looper.getMainLooper()).idle() } @Test diff --git a/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/tracker/MediaItemTrackerTest.kt b/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/tracker/MediaItemTrackerTest.kt index 6a4b7c998..db18cd74c 100644 --- a/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/tracker/MediaItemTrackerTest.kt +++ b/pillarbox-player/src/test/java/ch/srgssr/pillarbox/player/tracker/MediaItemTrackerTest.kt @@ -5,6 +5,7 @@ package ch.srgssr.pillarbox.player.tracker import android.content.Context +import android.os.Looper import androidx.media3.common.MediaMetadata import androidx.media3.common.Player import androidx.media3.exoplayer.DefaultLoadControl @@ -26,6 +27,7 @@ import io.mockk.verifyOrder import org.junit.After import org.junit.Before import org.junit.runner.RunWith +import org.robolectric.Shadows.shadowOf import kotlin.test.Test import kotlin.test.assertNotNull @@ -57,6 +59,7 @@ class MediaItemTrackerTest { fun releasePlayer() { clearAllMocks() player.release() + shadowOf(Looper.getMainLooper()).idle() } @Test