Remove CountDownLatch from MockPlayer
The MockPlayer has a single CountDownLatch field and multiple boolean flags that track if a player method was called. Upon calling the methods the latch count. Tests set the latch count to match exactly with the number of expected player interactions then block the test thread until the latch reaches zero and assert the respective method flags are true. This is subject to false positives. If the underneath implementation changes and call more player method, then the test thread will unblock as soon as a certain number of interactions is performed, which may be less than what the test expected originally. However, the test may stil pass if the player thread had enough time to update the expected method flag. This change removes the single CountDownLatch and the boolean flags and instead it adds APIs to query the MockPlayer if a method has been called and await until a method is called. Internally, the MockPlayer has a ConditionVariable per method. PiperOrigin-RevId: 432399077 (cherry picked from commit 45d51216)
Showing
with
28 additions
and
36 deletions
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
Please
register
or
sign in
to comment