mirror of
https://github.com/samsonjs/media.git
synced 2026-03-29 10:05:48 +00:00
Fix flaky unit tests
PiperOrigin-RevId: 290910992
This commit is contained in:
parent
d64388a075
commit
78fe1afa85
2 changed files with 8 additions and 2 deletions
|
|
@ -290,11 +290,14 @@ public class DedicatedThreadAsyncMediaCodecAdapterTest {
|
|||
AtomicInteger onCodecStartCount = new AtomicInteger(0);
|
||||
adapter.setCodecStartRunnable(() -> onCodecStartCount.incrementAndGet());
|
||||
adapter.start();
|
||||
// Grab reference to Looper before shutting down the adapter otherwise handlerThread.getLooper()
|
||||
// might return null.
|
||||
Looper looper = handlerThread.getLooper();
|
||||
adapter.flush();
|
||||
adapter.shutdown();
|
||||
|
||||
// Wait until all tasks have been handled.
|
||||
Shadows.shadowOf(handlerThread.getLooper()).idle();
|
||||
Shadows.shadowOf(looper).idle();
|
||||
// Only adapter.start() calls onCodecStart.
|
||||
assertThat(onCodecStartCount.get()).isEqualTo(1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,10 +290,13 @@ public class MultiLockAsyncMediaCodecAdapterTest {
|
|||
AtomicInteger codecStartCalls = new AtomicInteger(0);
|
||||
adapter.setCodecStartRunnable(() -> codecStartCalls.incrementAndGet());
|
||||
adapter.start();
|
||||
// Grab reference to Looper before shutting down the adapter otherwise handlerThread.getLooper()
|
||||
// might return null.
|
||||
Looper looper = handlerThread.getLooper();
|
||||
adapter.flush();
|
||||
adapter.shutdown();
|
||||
|
||||
Shadows.shadowOf(handlerThread.getLooper()).idle();
|
||||
Shadows.shadowOf(looper).idle();
|
||||
// Only adapter.start() called codec#start()
|
||||
assertThat(codecStartCalls.get()).isEqualTo(1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue