Search in sources :

Example 1 with RobolectricUtil.createRobolectricConditionVariable

use of com.google.android.exoplayer2.robolectric.RobolectricUtil.createRobolectricConditionVariable in project ExoPlayer by google.

the class RobolectricUtilTest method createRobolectricConditionVariable_blockWithTimeout_blocksForAtLeastTimeout.

@Test
public void createRobolectricConditionVariable_blockWithTimeout_blocksForAtLeastTimeout() throws InterruptedException {
    ConditionVariable conditionVariable = RobolectricUtil.createRobolectricConditionVariable();
    long startTimeMs = System.currentTimeMillis();
    assertThat(conditionVariable.block(/* timeoutMs= */
    500)).isFalse();
    long endTimeMs = System.currentTimeMillis();
    assertThat(endTimeMs - startTimeMs).isAtLeast(500);
}
Also used : ConditionVariable(com.google.android.exoplayer2.util.ConditionVariable) Test(org.junit.Test)

Example 2 with RobolectricUtil.createRobolectricConditionVariable

use of com.google.android.exoplayer2.robolectric.RobolectricUtil.createRobolectricConditionVariable in project ExoPlayer by google.

the class RobolectricUtilTest method createRobolectricConditionVariable_blockWithTimeout_timesOut.

@Test
public void createRobolectricConditionVariable_blockWithTimeout_timesOut() throws InterruptedException {
    ConditionVariable conditionVariable = RobolectricUtil.createRobolectricConditionVariable();
    assertThat(conditionVariable.block(/* timeoutMs= */
    1)).isFalse();
    assertThat(conditionVariable.isOpen()).isFalse();
}
Also used : ConditionVariable(com.google.android.exoplayer2.util.ConditionVariable) Test(org.junit.Test)

Aggregations

ConditionVariable (com.google.android.exoplayer2.util.ConditionVariable)2 Test (org.junit.Test)2