Fix flaky test by slightly changing its setup.

The test is flkay (2/1000 runs) because the decoder initialization
before and after the seek are not perfectly deterministic. I couldn't
find a way to make them deterministic, so slightly chaning the test
setup instead. The test setup change doesn't affect the scenario being
tested.

PiperOrigin-RevId: 301390491
This commit is contained in:
tonihei 2020-03-17 16:34:47 +00:00 committed by Oliver Woodman
parent 363b4224b9
commit 9d5319d6ac

View File

@ -305,7 +305,10 @@ public final class AnalyticsCollectorTest {
public void seekToOtherPeriod() throws Exception { public void seekToOtherPeriod() throws Exception {
MediaSource mediaSource = MediaSource mediaSource =
new ConcatenatingMediaSource( new ConcatenatingMediaSource(
new FakeMediaSource(SINGLE_PERIOD_TIMELINE, ExoPlayerTestRunner.Builder.VIDEO_FORMAT), new FakeMediaSource(
SINGLE_PERIOD_TIMELINE,
ExoPlayerTestRunner.Builder.VIDEO_FORMAT,
ExoPlayerTestRunner.Builder.AUDIO_FORMAT),
new FakeMediaSource(SINGLE_PERIOD_TIMELINE, ExoPlayerTestRunner.Builder.AUDIO_FORMAT)); new FakeMediaSource(SINGLE_PERIOD_TIMELINE, ExoPlayerTestRunner.Builder.AUDIO_FORMAT));
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
@ -315,7 +318,6 @@ public final class AnalyticsCollectorTest {
.waitForIsLoading(false) .waitForIsLoading(false)
.waitForIsLoading(true) .waitForIsLoading(true)
.waitForIsLoading(false) .waitForIsLoading(false)
.waitForPlaybackState(Player.STATE_READY)
.seek(/* windowIndex= */ 1, /* positionMs= */ 0) .seek(/* windowIndex= */ 1, /* positionMs= */ 0)
.waitForSeekProcessed() .waitForSeekProcessed()
.play() .play()
@ -355,19 +357,19 @@ public final class AnalyticsCollectorTest {
WINDOW_1 /* manifest */, WINDOW_1 /* manifest */,
period1 /* media */); period1 /* media */);
assertThat(listener.getEvents(EVENT_DOWNSTREAM_FORMAT_CHANGED)) assertThat(listener.getEvents(EVENT_DOWNSTREAM_FORMAT_CHANGED))
.containsExactly(period0 /* video */, period1 /* audio */); .containsExactly(period0 /* video */, period0 /* audio */, period1 /* audio */);
assertThat(listener.getEvents(EVENT_MEDIA_PERIOD_CREATED)).containsExactly(period0, period1); assertThat(listener.getEvents(EVENT_MEDIA_PERIOD_CREATED)).containsExactly(period0, period1);
assertThat(listener.getEvents(EVENT_MEDIA_PERIOD_RELEASED)).containsExactly(period0); assertThat(listener.getEvents(EVENT_MEDIA_PERIOD_RELEASED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_READING_STARTED)).containsExactly(period0, period1); assertThat(listener.getEvents(EVENT_READING_STARTED)).containsExactly(period0, period1);
assertThat(listener.getEvents(EVENT_DECODER_ENABLED)) assertThat(listener.getEvents(EVENT_DECODER_ENABLED))
.containsExactly(period0 /* video */, period1 /* audio */, period1 /* audio */); .containsExactly(period0 /* video */, period0 /* audio */, period1 /* audio */);
assertThat(listener.getEvents(EVENT_DECODER_INIT)) assertThat(listener.getEvents(EVENT_DECODER_INIT))
.containsExactly(period0 /* video */, period1 /* audio */); .containsExactly(period0 /* video */, period0 /* audio */, period1 /* audio */);
assertThat(listener.getEvents(EVENT_DECODER_FORMAT_CHANGED)) assertThat(listener.getEvents(EVENT_DECODER_FORMAT_CHANGED))
.containsExactly(period0 /* video */, period1 /* audio */); .containsExactly(period0 /* video */, period0 /* audio */, period1 /* audio */);
assertThat(listener.getEvents(EVENT_DECODER_DISABLED)) assertThat(listener.getEvents(EVENT_DECODER_DISABLED))
.containsExactly(period0 /* video */, period0 /* audio */); .containsExactly(period0 /* video */, period0 /* audio */);
assertThat(listener.getEvents(EVENT_AUDIO_SESSION_ID)).containsExactly(period1); assertThat(listener.getEvents(EVENT_AUDIO_SESSION_ID)).containsExactly(period0, period1);
assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)).containsExactly(period0); assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_RENDERED_FIRST_FRAME)).containsExactly(period0); assertThat(listener.getEvents(EVENT_RENDERED_FIRST_FRAME)).containsExactly(period0);
listener.assertNoMoreEvents(); listener.assertNoMoreEvents();
@ -1669,6 +1671,16 @@ public final class AnalyticsCollectorTest {
this.eventWindowAndPeriodId = this.eventWindowAndPeriodId =
new EventWindowAndPeriodId(eventTime.windowIndex, eventTime.mediaPeriodId); new EventWindowAndPeriodId(eventTime.windowIndex, eventTime.mediaPeriodId);
} }
@Override
public String toString() {
return "ReportedEvent{"
+ "type="
+ eventType
+ ", windowAndPeriodId="
+ eventWindowAndPeriodId
+ '}';
}
} }
} }
} }