Skip to content

Commit e4287fe

Browse files
committed
Add PlayLog test 19
1 parent d4059f9 commit e4287fe

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

player/src/androidTest/kotlin/com/tidal/sdk/player/playlog/TwoMediaProductsPlayLogTest.kt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,4 +405,64 @@ internal class TwoMediaProductsPlayLogTest {
405405
eq(emptyMap()),
406406
)
407407
}
408+
409+
@Suppress("CyclomaticComplexMethod", "LongMethod")
410+
@Test
411+
fun skipToNext() = runTest {
412+
val gson = Gson()
413+
414+
player.playbackEngine.load(mediaProduct1)
415+
player.playbackEngine.play()
416+
player.playbackEngine.setNext(mediaProduct2)
417+
withContext(Dispatchers.Default.limitedParallelism(1)) {
418+
withTimeout(8.seconds) {
419+
player.playbackEngine.events.filter { it is Event.MediaProductTransition }.first()
420+
}
421+
delay(1.seconds)
422+
while (player.playbackEngine.assetPosition < 1) {
423+
delay(10.milliseconds)
424+
}
425+
player.playbackEngine.skipToNext()
426+
withTimeout(4.seconds) {
427+
player.playbackEngine.events.filter { it is Event.MediaProductTransition }.first()
428+
}
429+
delay(1.seconds)
430+
while (player.playbackEngine.assetPosition < 1) {
431+
delay(10.milliseconds)
432+
}
433+
player.playbackEngine.reset()
434+
}
435+
436+
eventReporterCoroutineScope.advanceUntilIdle()
437+
verify(eventSender).sendEvent(
438+
eq("playback_session"),
439+
eq(ConsentCategory.NECESSARY),
440+
argThat {
441+
with(gson.fromJson(this, JsonObject::class.java)["payload"].asJsonObject) {
442+
get("startAssetPosition").asDouble.isAssetPositionEqualTo(0.0) &&
443+
get("endAssetPosition").asDouble.isAssetPositionEqualTo(1.0) &&
444+
get("actualProductId")?.asString.contentEquals(mediaProduct1.productId) &&
445+
get("sourceType")?.asString.contentEquals(mediaProduct1.sourceType) &&
446+
get("sourceId")?.asString.contentEquals(mediaProduct1.sourceId) &&
447+
get("actions").asJsonArray.isEmpty
448+
}
449+
},
450+
eq(emptyMap()),
451+
)
452+
verify(eventSender).sendEvent(
453+
eq("playback_session"),
454+
eq(ConsentCategory.NECESSARY),
455+
argThat {
456+
with(gson.fromJson(this, JsonObject::class.java)["payload"].asJsonObject) {
457+
get("startAssetPosition").asDouble.isAssetPositionEqualTo(0.0) &&
458+
get("endAssetPosition").asDouble.isAssetPositionEqualTo(1.0) &&
459+
get("actualProductId")?.asString.contentEquals(mediaProduct2.productId) &&
460+
get("sourceType")?.asString.contentEquals(mediaProduct2.sourceType) &&
461+
get("sourceId")?.asString.contentEquals(mediaProduct2.sourceId) &&
462+
get("actions").asJsonArray.isEmpty
463+
}
464+
},
465+
eq(emptyMap()),
466+
)
467+
}
408468
}

0 commit comments

Comments
 (0)