Commit 145e923d by tonihei Committed by Andrew Lewis

Fix flakiness in DefaultPlaybackSessionManagerTest

Two of the sessions are finished at the same time in the test
and the order of the corresponding callbacks depends on the randomly
generated session string and the order these strings are stored in a
HashSet.

Update test to assert both callbacks are called and they contain the
right arguments, but don't assert on the order of these two callbacks.

PiperOrigin-RevId: 424548819
parent 73d9728f
...@@ -788,18 +788,16 @@ public final class DefaultPlaybackSessionManagerTest { ...@@ -788,18 +788,16 @@ public final class DefaultPlaybackSessionManagerTest {
inOrder inOrder
.verify(mockListener) .verify(mockListener)
.onSessionCreated(eq(eventTimeFirstTimelineWindowOnly2), thirdId.capture()); .onSessionCreated(eq(eventTimeFirstTimelineWindowOnly2), thirdId.capture());
// The sessions may finish at the same time, so the order of these two callbacks is undefined.
ArgumentCaptor<String> finishedSessions = ArgumentCaptor.forClass(String.class);
inOrder inOrder
.verify(mockListener) .verify(mockListener, times(2))
.onSessionFinished( .onSessionFinished(
eventTimeSecondTimeline, eq(eventTimeSecondTimeline),
firstId.getValue(), finishedSessions.capture(),
/* automaticTransitionToNextPlayback= */ false); /* automaticTransitionToNextPlayback= */ eq(false));
inOrder assertThat(finishedSessions.getAllValues())
.verify(mockListener) .containsExactly(firstId.getValue(), thirdId.getValue());
.onSessionFinished(
eventTimeSecondTimeline,
thirdId.getValue(),
/* automaticTransitionToNextPlayback= */ false);
inOrder.verify(mockListener).onSessionActive(eventTimeSecondTimeline, secondId.getValue()); inOrder.verify(mockListener).onSessionActive(eventTimeSecondTimeline, secondId.getValue());
inOrder.verifyNoMoreInteractions(); inOrder.verifyNoMoreInteractions();
} }
......
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