Skip to content

Commit 3e45a22

Browse files
committed
Add PlayLog test 23
1 parent 1ef974a commit 3e45a22

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,4 +654,58 @@ internal class TwoMediaProductsPlayLogTest {
654654
eq(emptyMap()),
655655
)
656656
}
657+
658+
@Suppress("CyclomaticComplexMethod")
659+
@Test
660+
fun playSequentiallyWithoutRepeatOne() = runTest {
661+
val gson = Gson()
662+
663+
player.playbackEngine.load(mediaProduct1)
664+
player.playbackEngine.play()
665+
withContext(Dispatchers.Default.limitedParallelism(1)) {
666+
delay(2.seconds)
667+
while (player.playbackEngine.assetPosition < 2) {
668+
delay(10.milliseconds)
669+
}
670+
player.playbackEngine.load(mediaProduct2)
671+
player.playbackEngine.play()
672+
delay(1.seconds)
673+
while (player.playbackEngine.assetPosition < 1) {
674+
delay(10.milliseconds)
675+
}
676+
player.playbackEngine.reset()
677+
}
678+
679+
eventReporterCoroutineScope.advanceUntilIdle()
680+
verify(eventSender).sendEvent(
681+
eq("playback_session"),
682+
eq(ConsentCategory.NECESSARY),
683+
argThat {
684+
with(gson.fromJson(this, JsonObject::class.java)["payload"].asJsonObject) {
685+
get("startAssetPosition").asDouble.isAssetPositionEqualTo(0.0) &&
686+
get("endAssetPosition").asDouble.isAssetPositionEqualTo(2.0) &&
687+
get("actualProductId")?.asString.contentEquals(mediaProduct1.productId) &&
688+
get("sourceType")?.asString.contentEquals(mediaProduct1.sourceType) &&
689+
get("sourceId")?.asString.contentEquals(mediaProduct1.sourceId) &&
690+
get("actions").asJsonArray.isEmpty
691+
}
692+
},
693+
eq(emptyMap()),
694+
)
695+
verify(eventSender).sendEvent(
696+
eq("playback_session"),
697+
eq(ConsentCategory.NECESSARY),
698+
argThat {
699+
with(gson.fromJson(this, JsonObject::class.java)["payload"].asJsonObject) {
700+
get("startAssetPosition").asDouble.isAssetPositionEqualTo(0.0) &&
701+
get("endAssetPosition").asDouble.isAssetPositionEqualTo(1.0) &&
702+
get("actualProductId")?.asString.contentEquals(mediaProduct2.productId) &&
703+
get("sourceType")?.asString.contentEquals(mediaProduct2.sourceType) &&
704+
get("sourceId")?.asString.contentEquals(mediaProduct2.sourceId) &&
705+
get("actions").asJsonArray.isEmpty
706+
}
707+
},
708+
eq(emptyMap()),
709+
)
710+
}
657711
}

0 commit comments

Comments
 (0)