Commit 851218ac by tonihei Committed by Oliver Woodman

Fix AnalyticsCollectorTest flakiness.

Two tests have very low propability flakiness (1:1000) due to not waiting for
a seek in one case and the chance of already being ended in another case.

Fix these and also adjust wrong comments about state changes.

PiperOrigin-RevId: 261309976
parent 4482db40
...@@ -368,8 +368,7 @@ public final class AnalyticsCollectorTest { ...@@ -368,8 +368,7 @@ public final class AnalyticsCollectorTest {
.pause() .pause()
.waitForPlaybackState(Player.STATE_READY) .waitForPlaybackState(Player.STATE_READY)
.playUntilPosition(/* windowIndex= */ 0, periodDurationMs) .playUntilPosition(/* windowIndex= */ 0, periodDurationMs)
.seek(/* positionMs= */ 0) .seekAndWait(/* positionMs= */ 0)
.waitForPlaybackState(Player.STATE_READY)
.play() .play()
.build(); .build();
TestAnalyticsListener listener = runAnalyticsTest(mediaSource, actionSchedule); TestAnalyticsListener listener = runAnalyticsTest(mediaSource, actionSchedule);
...@@ -378,8 +377,8 @@ public final class AnalyticsCollectorTest { ...@@ -378,8 +377,8 @@ public final class AnalyticsCollectorTest {
assertThat(listener.getEvents(EVENT_PLAYER_STATE_CHANGED)) assertThat(listener.getEvents(EVENT_PLAYER_STATE_CHANGED))
.containsExactly( .containsExactly(
WINDOW_0 /* setPlayWhenReady=true */, WINDOW_0 /* setPlayWhenReady=true */,
WINDOW_0 /* BUFFERING */,
WINDOW_0 /* setPlayWhenReady=false */, WINDOW_0 /* setPlayWhenReady=false */,
WINDOW_0 /* BUFFERING */,
period0 /* READY */, period0 /* READY */,
period0 /* setPlayWhenReady=true */, period0 /* setPlayWhenReady=true */,
period0 /* setPlayWhenReady=false */, period0 /* setPlayWhenReady=false */,
...@@ -505,6 +504,7 @@ public final class AnalyticsCollectorTest { ...@@ -505,6 +504,7 @@ public final class AnalyticsCollectorTest {
.waitForPlaybackState(Player.STATE_READY) .waitForPlaybackState(Player.STATE_READY)
.throwPlaybackException(ExoPlaybackException.createForSource(new IOException())) .throwPlaybackException(ExoPlaybackException.createForSource(new IOException()))
.waitForPlaybackState(Player.STATE_IDLE) .waitForPlaybackState(Player.STATE_IDLE)
.seek(/* positionMs= */ 0)
.prepareSource(mediaSource, /* resetPosition= */ false, /* resetState= */ false) .prepareSource(mediaSource, /* resetPosition= */ false, /* resetState= */ false)
.waitForPlaybackState(Player.STATE_ENDED) .waitForPlaybackState(Player.STATE_ENDED)
.build(); .build();
...@@ -522,6 +522,9 @@ public final class AnalyticsCollectorTest { ...@@ -522,6 +522,9 @@ public final class AnalyticsCollectorTest {
period0Seq0 /* ENDED */); period0Seq0 /* ENDED */);
assertThat(listener.getEvents(EVENT_TIMELINE_CHANGED)) assertThat(listener.getEvents(EVENT_TIMELINE_CHANGED))
.containsExactly(WINDOW_0 /* prepared */, WINDOW_0 /* prepared */); .containsExactly(WINDOW_0 /* prepared */, WINDOW_0 /* prepared */);
assertThat(listener.getEvents(EVENT_POSITION_DISCONTINUITY)).containsExactly(WINDOW_0);
assertThat(listener.getEvents(EVENT_SEEK_STARTED)).containsExactly(WINDOW_0);
assertThat(listener.getEvents(EVENT_SEEK_PROCESSED)).containsExactly(WINDOW_0);
assertThat(listener.getEvents(EVENT_LOADING_CHANGED)) assertThat(listener.getEvents(EVENT_LOADING_CHANGED))
.containsExactly(period0Seq0, period0Seq0, period0Seq0, period0Seq0); .containsExactly(period0Seq0, period0Seq0, period0Seq0, period0Seq0);
assertThat(listener.getEvents(EVENT_PLAYER_ERROR)).containsExactly(period0Seq0); assertThat(listener.getEvents(EVENT_PLAYER_ERROR)).containsExactly(period0Seq0);
...@@ -585,8 +588,8 @@ public final class AnalyticsCollectorTest { ...@@ -585,8 +588,8 @@ public final class AnalyticsCollectorTest {
assertThat(listener.getEvents(EVENT_PLAYER_STATE_CHANGED)) assertThat(listener.getEvents(EVENT_PLAYER_STATE_CHANGED))
.containsExactly( .containsExactly(
WINDOW_0 /* setPlayWhenReady=true */, WINDOW_0 /* setPlayWhenReady=true */,
WINDOW_0 /* BUFFERING */,
WINDOW_0 /* setPlayWhenReady=false */, WINDOW_0 /* setPlayWhenReady=false */,
WINDOW_0 /* BUFFERING */,
window0Period1Seq0 /* READY */, window0Period1Seq0 /* READY */,
window0Period1Seq0 /* setPlayWhenReady=true */, window0Period1Seq0 /* setPlayWhenReady=true */,
window0Period1Seq0 /* setPlayWhenReady=false */, window0Period1Seq0 /* setPlayWhenReady=false */,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment