Search in sources :

Example 1 with RobolectricUtil.createRobolectricConditionVariable

use of androidx.media3.test.utils.robolectric.RobolectricUtil.createRobolectricConditionVariable in project media by androidx.

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(androidx.media3.common.util.ConditionVariable) Test(org.junit.Test)

Example 2 with RobolectricUtil.createRobolectricConditionVariable

use of androidx.media3.test.utils.robolectric.RobolectricUtil.createRobolectricConditionVariable in project media by androidx.

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(androidx.media3.common.util.ConditionVariable) Test(org.junit.Test)

Aggregations

ConditionVariable (androidx.media3.common.util.ConditionVariable)2 Test (org.junit.Test)2