Skip to content

Commit 7ee46d4

Browse files
committed
MF-171: Add PlayLog test 24
1 parent db2266c commit 7ee46d4

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

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

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,4 +716,61 @@ internal class TwoMediaProductsPlayLogTest {
716716
},
717717
)
718718
}
719+
720+
@Suppress("CyclomaticComplexMethod")
721+
@Test
722+
fun playTwiceWithoutRepeatOne() = runTest {
723+
val gson = Gson()
724+
val payloadCaptor = argumentCaptor<String>()
725+
726+
player.playbackEngine.load(mediaProduct1)
727+
player.playbackEngine.play()
728+
withContext(Dispatchers.Default.limitedParallelism(1)) {
729+
withTimeout(8.seconds) {
730+
player.playbackEngine.events.filter { it is Event.MediaProductTransition }.first()
731+
}
732+
delay(2.seconds)
733+
while (player.playbackEngine.assetPosition < 2) {
734+
delay(10.milliseconds)
735+
}
736+
player.playbackEngine.load(mediaProduct1)
737+
player.playbackEngine.play()
738+
withTimeout(8.seconds) {
739+
player.playbackEngine.events.filter { it is Event.MediaProductTransition }.first()
740+
}
741+
delay(1.seconds)
742+
while (player.playbackEngine.assetPosition < 1) {
743+
delay(10.milliseconds)
744+
}
745+
player.playbackEngine.reset()
746+
}
747+
748+
eventReporterCoroutineScope.advanceUntilIdle()
749+
verify(eventSender, times(2)).sendEvent(
750+
eq("playback_session"),
751+
eq(ConsentCategory.NECESSARY),
752+
payloadCaptor.capture(),
753+
eq(emptyMap()),
754+
)
755+
payloadCaptor.allValues.map {
756+
gson.fromJson(it, JsonObject::class.java)["payload"].asJsonObject
757+
}.combinedPassAllOf(
758+
1 to {
759+
assertThat(get("startAssetPosition").asDouble).isAssetPositionEqualTo(0.0)
760+
assertThat(get("endAssetPosition").asDouble).isAssetPositionEqualTo(2.0)
761+
assertThat(get("actualProductId")?.asString).isEqualTo(mediaProduct1.productId)
762+
assertThat(get("sourceType")?.asString).isEqualTo(mediaProduct1.sourceType)
763+
assertThat(get("sourceId")?.asString).isEqualTo(mediaProduct1.sourceId)
764+
assertThat(get("actions").asJsonArray).isEmpty()
765+
},
766+
1 to {
767+
assertThat(get("startAssetPosition").asDouble).isAssetPositionEqualTo(0.0)
768+
assertThat(get("endAssetPosition").asDouble).isAssetPositionEqualTo(1.0)
769+
assertThat(get("actualProductId")?.asString).isEqualTo(mediaProduct1.productId)
770+
assertThat(get("sourceType")?.asString).isEqualTo(mediaProduct1.sourceType)
771+
assertThat(get("sourceId")?.asString).isEqualTo(mediaProduct1.sourceId)
772+
assertThat(get("actions").asJsonArray).isEmpty()
773+
},
774+
)
775+
}
719776
}

0 commit comments

Comments
 (0)