docs/doc/reference/com/google/android/exoplayer2/robolectric/RobolectricUtil.html
Package com.google.android.exoplayer2.robolectric
public final classRobolectricUtilextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")
Utility methods for Robolectric-based tests.
Fields | Modifier and Type | Field | Description |
| --- | --- | --- |
| static long | DEFAULT_TIMEOUT_MS |
The default timeout applied when calling runMainLooperUntil(Supplier).
|
All Methods Static Methods Concrete Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| static ConditionVariable | createRobolectricConditionVariable() |
Creates a ConditionVariable whose ConditionVariable.block(long) method times out according to wallclock time when used in Robolectric tests.
|
| static void | runLooperUntil(Looper looper, Supplier<Boolean> condition) |
Runs tasks of the looper until the condition returns true.
|
| static void | runLooperUntil(Looper looper, Supplier<Boolean> condition, long timeoutMs, Clock clock) |
Runs tasks of the looper until the condition returns true.
|
| static void | runMainLooperUntil(Supplier<Boolean> condition) |
Runs tasks of the main Robolectric Looper until the condition returns true.
|
| static void | runMainLooperUntil(Supplier<Boolean> condition, long timeoutMs, Clock clock) |
Runs tasks of the main Robolectric Looper until the condition returns true.
|
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
public static final long DEFAULT_TIMEOUT_MS
The default timeout applied when calling runMainLooperUntil(Supplier). This timeout should be sufficient for any condition using a Robolectric test.
See Also:Constant Field Values
-
public static[ConditionVariable](../util/ConditionVariable.html "class in com.google.android.exoplayer2.util")createRobolectricConditionVariable()
Creates a ConditionVariable whose ConditionVariable.block(long) method times out according to wallclock time when used in Robolectric tests.
-
public static void runMainLooperUntil([Supplier](https://guava.dev/releases/31.1-android/api/docs/com/google/common/base/Supplier.html?is-external=true "class or interface in com.google.common.base")<[Boolean](https://developer.android.com/reference/java/lang/Boolean.html "class or interface in java.lang")> condition)
throws[TimeoutException](https://developer.android.com/reference/java/util/concurrent/TimeoutException.html "class or interface in java.util.concurrent")
Runs tasks of the main Robolectric Looper until the condition returns true.
Must be called on the main test thread.
Parameters:condition - The condition.Throws:TimeoutException - If the DEFAULT_TIMEOUT_MS is exceeded.
-
public static void runMainLooperUntil([Supplier](https://guava.dev/releases/31.1-android/api/docs/com/google/common/base/Supplier.html?is-external=true "class or interface in com.google.common.base")<[Boolean](https://developer.android.com/reference/java/lang/Boolean.html "class or interface in java.lang")> condition,
long timeoutMs,[Clock](../util/Clock.html "interface in com.google.android.exoplayer2.util")clock)
throws[TimeoutException](https://developer.android.com/reference/java/util/concurrent/TimeoutException.html "class or interface in java.util.concurrent")
Runs tasks of the main Robolectric Looper until the condition returns true.
Must be called on the main test thread.
Parameters:condition - The condition.timeoutMs - The timeout in milliseconds.clock - The Clock to measure the timeout.Throws:TimeoutException - If the timeoutMs timeout is exceeded.
-
public static void runLooperUntil([Looper](https://developer.android.com/reference/android/os/Looper.html "class or interface in android.os")looper,[Supplier](https://guava.dev/releases/31.1-android/api/docs/com/google/common/base/Supplier.html?is-external=true "class or interface in com.google.common.base")<[Boolean](https://developer.android.com/reference/java/lang/Boolean.html "class or interface in java.lang")> condition)
throws[TimeoutException](https://developer.android.com/reference/java/util/concurrent/TimeoutException.html "class or interface in java.util.concurrent")
Runs tasks of the looper until the condition returns true.
Must be called on the thread corresponding to the looper.
Parameters:looper - The Looper.condition - The condition.Throws:TimeoutException - If the DEFAULT_TIMEOUT_MS is exceeded.
-
public static void runLooperUntil([Looper](https://developer.android.com/reference/android/os/Looper.html "class or interface in android.os")looper,[Supplier](https://guava.dev/releases/31.1-android/api/docs/com/google/common/base/Supplier.html?is-external=true "class or interface in com.google.common.base")<[Boolean](https://developer.android.com/reference/java/lang/Boolean.html "class or interface in java.lang")> condition,
long timeoutMs,[Clock](../util/Clock.html "interface in com.google.android.exoplayer2.util")clock)
throws[TimeoutException](https://developer.android.com/reference/java/util/concurrent/TimeoutException.html "class or interface in java.util.concurrent")
Runs tasks of the looper until the condition returns true.
Must be called on the thread corresponding to the looper.
Parameters:looper - The Looper.condition - The condition.timeoutMs - The timeout in milliseconds.clock - The Clock to measure the timeout.Throws:TimeoutException - If the timeoutMs timeout is exceeded.