Skip to content

Commit e355eea

Browse files
committed
test: add iOS playback observer lifecycle regression
1 parent b3ff2c7 commit e355eea

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package io.github.moonggae.kmedia.session
2+
3+
import kotlinx.coroutines.CoroutineScope
4+
import kotlinx.coroutines.Dispatchers
5+
import kotlinx.coroutines.SupervisorJob
6+
import kotlinx.coroutines.cancel
7+
import platform.AVFoundation.AVPlayer
8+
import kotlin.test.Test
9+
10+
class PlaybackStateObserverManagerTest {
11+
@Test
12+
fun observingLifecycleIsIdempotentAcrossRestart() {
13+
val scope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
14+
val manager = PlaybackStateObserverManager(
15+
player = AVPlayer(),
16+
coroutineScope = scope,
17+
onPlaybackStateChanged = {}
18+
)
19+
20+
try {
21+
manager.stopObserving()
22+
manager.startObserving()
23+
manager.startObserving()
24+
manager.stopObserving()
25+
manager.stopObserving()
26+
manager.startObserving()
27+
manager.stopObserving()
28+
} finally {
29+
scope.cancel()
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)