Fix flaky test.

The test was flaky because it didn't wait for pending commands to finish
after pausing the test playback.

Also add more debug information to the toString() method because the
expected and actual state only differed in the nextAdGroupIndex in the
flaky case.

PiperOrigin-RevId: 313175919
This commit is contained in:
tonihei 2020-05-26 14:02:19 +01:00 committed by Oliver Woodman
parent 0add067eaa
commit 45b574d593

View file

@ -874,7 +874,9 @@ public final class AnalyticsCollectorTest {
// Wait in each content part to ensure previously triggered events get a chance to be
// delivered. This prevents flakiness caused by playback progressing too fast.
.playUntilPosition(/* windowIndex= */ 0, /* positionMs= */ 3_000)
.waitForPendingPlayerCommands()
.playUntilPosition(/* windowIndex= */ 0, /* positionMs= */ 8_000)
.waitForPendingPlayerCommands()
.play()
.waitForPlaybackState(Player.STATE_ENDED)
// Wait for final timeline change that marks post-roll played.
@ -1361,6 +1363,9 @@ public final class AnalyticsCollectorTest {
: "")
+ ", period.hashCode="
+ mediaPeriodId.periodUid.hashCode()
+ (mediaPeriodId.nextAdGroupIndex != C.INDEX_UNSET
? ", nextAdGroup=" + mediaPeriodId.nextAdGroupIndex
: "")
+ '}'
: "{" + "window=" + windowIndex + ", period = null}";
}