Skip to content

Commit

Permalink
Cherry-pick test changes from #615 (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
MGaetan89 authored Jul 2, 2024
1 parent a65b2f8 commit 869d686
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -45,6 +47,7 @@ class PlayerCallbackFlowTest {
@AfterTest
fun tearDown() {
player.release()
shadowOf(Looper.getMainLooper()).idle()
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -37,6 +39,7 @@ class TestPillarboxExoPlayerPlaybackSpeed {
@After
fun releasePlayer() {
player.release()
shadowOf(Looper.getMainLooper()).idle()
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -60,6 +62,7 @@ class BlockedTimeRangeTrackerTest {
fun releasePlayer() {
player.removeListener(listener)
player.release()
shadowOf(Looper.getMainLooper()).idle()
clearAllMocks()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -60,6 +62,7 @@ class ChapterTrackerTest {
fun releasePlayer() {
player.removeListener(listener)
player.release()
shadowOf(Looper.getMainLooper()).idle()
clearAllMocks()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -49,6 +51,7 @@ class CurrentMediaItemPillarboxDataTrackerTest {
@AfterTest
fun tearDown() {
player.release()
shadowOf(Looper.getMainLooper()).idle()
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -57,6 +59,7 @@ class MediaItemTrackerTest {
fun releasePlayer() {
clearAllMocks()
player.release()
shadowOf(Looper.getMainLooper()).idle()
}

@Test
Expand Down

0 comments on commit 869d686

Please sign in to comment.