Skip to content

Commit

Permalink
Add PlayLog test 19
Browse files Browse the repository at this point in the history
  • Loading branch information
stoyicker committed Jul 2, 2024
1 parent d4059f9 commit 3d0ebb7
Showing 1 changed file with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -405,4 +405,64 @@ internal class TwoMediaProductsPlayLogTest {
eq(emptyMap()),
)
}

@Suppress("CyclomaticComplexMethod", "LongMethod")
@Test
fun skipToNext() = runTest {
val gson = Gson()

player.playbackEngine.load(mediaProduct1)
player.playbackEngine.play()
player.playbackEngine.setNext(mediaProduct2)
withContext(Dispatchers.Default.limitedParallelism(1)) {
withTimeout(8.seconds) {
player.playbackEngine.events.filter { it is Event.MediaProductTransition }.first()
}
delay(1.seconds)
while (player.playbackEngine.assetPosition < 1) {
delay(10.milliseconds)
}
player.playbackEngine.skipToNext()
withTimeout(8.seconds) {
player.playbackEngine.events.filter { it is Event.MediaProductTransition }.first()
}
delay(1.seconds)
while (player.playbackEngine.assetPosition < 1) {
delay(10.milliseconds)
}
player.playbackEngine.reset()
}

eventReporterCoroutineScope.advanceUntilIdle()
verify(eventSender).sendEvent(
eq("playback_session"),
eq(ConsentCategory.NECESSARY),
argThat {
with(gson.fromJson(this, JsonObject::class.java)["payload"].asJsonObject) {
get("startAssetPosition").asDouble.isAssetPositionEqualTo(0.0) &&
get("endAssetPosition").asDouble.isAssetPositionEqualTo(1.0) &&
get("actualProductId")?.asString.contentEquals(mediaProduct1.productId) &&
get("sourceType")?.asString.contentEquals(mediaProduct1.sourceType) &&
get("sourceId")?.asString.contentEquals(mediaProduct1.sourceId) &&
get("actions").asJsonArray.isEmpty
}
},
eq(emptyMap()),
)
verify(eventSender).sendEvent(
eq("playback_session"),
eq(ConsentCategory.NECESSARY),
argThat {
with(gson.fromJson(this, JsonObject::class.java)["payload"].asJsonObject) {
get("startAssetPosition").asDouble.isAssetPositionEqualTo(0.0) &&
get("endAssetPosition").asDouble.isAssetPositionEqualTo(1.0) &&
get("actualProductId")?.asString.contentEquals(mediaProduct2.productId) &&
get("sourceType")?.asString.contentEquals(mediaProduct2.sourceType) &&
get("sourceId")?.asString.contentEquals(mediaProduct2.sourceId) &&
get("actions").asJsonArray.isEmpty
}
},
eq(emptyMap()),
)
}
}

0 comments on commit 3d0ebb7

Please sign in to comment.