From 45b574d593d07c31247500268af8941f33539891 Mon Sep 17 00:00:00 2001 From: tonihei Date: Tue, 26 May 2020 14:02:19 +0100 Subject: [PATCH] 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 --- .../android/exoplayer2/analytics/AnalyticsCollectorTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/core/src/test/java/com/google/android/exoplayer2/analytics/AnalyticsCollectorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/analytics/AnalyticsCollectorTest.java index 5721212567..74b83d7873 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/analytics/AnalyticsCollectorTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/analytics/AnalyticsCollectorTest.java @@ -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}"; }