@@ -652,4 +652,57 @@ internal class TwoMediaProductsPlayLogTest {
652652 },
653653 )
654654 }
655+
656+ @Suppress(" CyclomaticComplexMethod" )
657+ @Test
658+ fun playSequentiallyWithoutRepeatOne () = runTest {
659+ val gson = Gson ()
660+ val payloadCaptor = argumentCaptor<String >()
661+
662+ player.playbackEngine.load(mediaProduct1)
663+ player.playbackEngine.play()
664+ withContext(Dispatchers .Default .limitedParallelism(1 )) {
665+ delay(2 .seconds)
666+ while (player.playbackEngine.assetPosition < 2 ) {
667+ delay(10 .milliseconds)
668+ }
669+ player.playbackEngine.load(mediaProduct2)
670+ player.playbackEngine.play()
671+ delay(1 .seconds)
672+ while (player.playbackEngine.assetPosition < 1 ) {
673+ delay(10 .milliseconds)
674+ }
675+ player.playbackEngine.reset()
676+ }
677+
678+ eventReporterCoroutineScope.advanceUntilIdle()
679+
680+ eventReporterCoroutineScope.advanceUntilIdle()
681+ verify(eventSender, times(2 )).sendEvent(
682+ eq(" playback_session" ),
683+ eq(ConsentCategory .NECESSARY ),
684+ payloadCaptor.capture(),
685+ eq(emptyMap()),
686+ )
687+ payloadCaptor.allValues.map {
688+ gson.fromJson(it, JsonObject ::class .java)[" payload" ].asJsonObject
689+ }.combinedPassAllOf(
690+ 1 to {
691+ assertThat(get(" startAssetPosition" ).asDouble).isAssetPositionEqualTo(0.0 )
692+ assertThat(get(" endAssetPosition" ).asDouble).isAssetPositionEqualTo(2.0 )
693+ assertThat(get(" actualProductId" )?.asString).isEqualTo(mediaProduct1.productId)
694+ assertThat(get(" sourceType" )?.asString).isEqualTo(mediaProduct1.sourceType)
695+ assertThat(get(" sourceId" )?.asString).isEqualTo(mediaProduct1.sourceId)
696+ assertThat(get(" actions" ).asJsonArray).isEmpty()
697+ },
698+ 1 to {
699+ assertThat(get(" startAssetPosition" ).asDouble).isAssetPositionEqualTo(0.0 )
700+ assertThat(get(" endAssetPosition" ).asDouble).isAssetPositionEqualTo(1.0 )
701+ assertThat(get(" actualProductId" )?.asString).isEqualTo(mediaProduct2.productId)
702+ assertThat(get(" sourceType" )?.asString).isEqualTo(mediaProduct2.sourceType)
703+ assertThat(get(" sourceId" )?.asString).isEqualTo(mediaProduct2.sourceId)
704+ assertThat(get(" actions" ).asJsonArray).isEmpty()
705+ },
706+ )
707+ }
655708}
0 commit comments