@@ -62,6 +62,7 @@ import org.mockito.kotlin.whenever
6262import org.robolectric.annotation.Config
6363import java.io.ByteArrayOutputStream
6464import java.io.File
65+ import java.util.UUID
6566import kotlin.test.BeforeTest
6667import kotlin.test.Test
6768import kotlin.test.assertEquals
@@ -203,10 +204,13 @@ class ReplayIntegrationTest {
203204 @Test
204205 fun `starting two times does nothing` () {
205206 val captureStrategy = mock<CaptureStrategy >()
207+ whenever(captureStrategy.currentReplayId).thenReturn(SentryId .EMPTY_ID )
208+
206209 val replay = fixture.getSut(context, replayCaptureStrategyProvider = { captureStrategy })
207210
208211 replay.register(fixture.scopes, fixture.options)
209212 replay.start()
213+ replay.onWindowSizeChanged(640 , 480 )
210214 replay.start()
211215
212216 verify(captureStrategy, times(1 )).start(
@@ -236,10 +240,13 @@ class ReplayIntegrationTest {
236240 @Test
237241 fun `still starts replay when errorsSampleRate is set` () {
238242 val captureStrategy = mock<CaptureStrategy >()
243+ whenever(captureStrategy.currentReplayId).thenReturn(SentryId .EMPTY_ID )
244+
239245 val replay = fixture.getSut(context, sessionSampleRate = 0.0 , replayCaptureStrategyProvider = { captureStrategy })
240246
241247 replay.register(fixture.scopes, fixture.options)
242248 replay.start()
249+ replay.onWindowSizeChanged(640 , 480 )
243250
244251 verify(captureStrategy, times(1 )).start(
245252 any(),
@@ -256,6 +263,7 @@ class ReplayIntegrationTest {
256263
257264 replay.register(fixture.scopes, fixture.options)
258265 replay.start()
266+ replay.onWindowSizeChanged(640 , 480 )
259267
260268 verify(recorder).start(any())
261269 }
@@ -445,10 +453,13 @@ class ReplayIntegrationTest {
445453
446454 replay.register(fixture.scopes, fixture.options)
447455 replay.start()
456+ replay.onWindowSizeChanged(480 , 640 )
457+
448458 replay.onConfigurationChanged(mock())
459+ replay.onWindowSizeChanged(640 , 480 )
449460
450- verify(recorder).stop()
451- verify(captureStrategy).onConfigurationChanged(eq(recorderConfig))
461+ verify(recorder, times( 3 ) ).stop()
462+ verify(captureStrategy, times( 2 ) ).onConfigurationChanged(eq(recorderConfig))
452463 verify(recorder, times(2 )).start(eq(recorderConfig))
453464 assertTrue(configChanged)
454465 }
@@ -599,6 +610,8 @@ class ReplayIntegrationTest {
599610
600611 replay.register(fixture.scopes, fixture.options)
601612 replay.start()
613+ replay.onWindowSizeChanged(640 , 480 )
614+
602615 replay.onScreenshotRecorded(mock<Bitmap >())
603616
604617 verify(recorder).pause()
@@ -617,6 +630,7 @@ class ReplayIntegrationTest {
617630
618631 replay.register(fixture.scopes, fixture.options)
619632 replay.start()
633+ replay.onWindowSizeChanged(640 , 480 )
620634 replay.onScreenshotRecorded(mock<Bitmap >())
621635
622636 verify(recorder).pause()
@@ -713,6 +727,8 @@ class ReplayIntegrationTest {
713727 var configChanged = false
714728 val recorderConfig = mock<ScreenshotRecorderConfig >()
715729 val captureStrategy = mock<CaptureStrategy >()
730+ whenever(captureStrategy.currentReplayId).thenReturn(SentryId (UUID .randomUUID()))
731+
716732 val recorder = mock<Recorder >()
717733 val replay = fixture.getSut(
718734 context,
@@ -723,11 +739,14 @@ class ReplayIntegrationTest {
723739
724740 replay.register(fixture.scopes, fixture.options)
725741 replay.start()
742+ replay.onWindowSizeChanged(640 , 480 )
743+
726744 replay.pause()
727745 replay.onConfigurationChanged(mock())
746+ replay.onWindowSizeChanged(480 , 640 )
728747
729- verify(recorder).stop()
730- verify(captureStrategy).onConfigurationChanged(eq(recorderConfig))
748+ verify(recorder, times( 3 ) ).stop()
749+ verify(captureStrategy, times( 2 ) ).onConfigurationChanged(eq(recorderConfig))
731750 verify(recorder, times(2 )).start(eq(recorderConfig))
732751 verify(recorder, times(2 )).pause()
733752 assertTrue(configChanged)
0 commit comments