public final class RobolectricUtil extends Object
| Modifier and Type | Field | Description |
|---|---|---|
static long |
DEFAULT_TIMEOUT_MS |
The default timeout applied when calling
runMainLooperUntil(Supplier). |
| 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) |
|
static void |
runMainLooperUntil(Supplier<Boolean> condition,
long timeoutMs,
Clock clock) |
public static final long DEFAULT_TIMEOUT_MS
runMainLooperUntil(Supplier). This timeout
should be sufficient for any condition using a Robolectric test.public static ConditionVariable createRobolectricConditionVariable()
ConditionVariable whose ConditionVariable.block(long) method times
out according to wallclock time when used in Robolectric tests.public static void runMainLooperUntil(Supplier<Boolean> condition) throws TimeoutException
Looper until the condition returns
true.
Must be called on the main test thread.
condition - The condition.TimeoutException - If the DEFAULT_TIMEOUT_MS is exceeded.public static void runMainLooperUntil(Supplier<Boolean> condition, long timeoutMs, Clock clock) throws TimeoutException
Looper until the condition returns
true.
Must be called on the main test thread.
condition - The condition.timeoutMs - The timeout in milliseconds.clock - The Clock to measure the timeout.TimeoutException - If the timeoutMs timeout is exceeded.public static void runLooperUntil(Looper looper, Supplier<Boolean> condition) throws TimeoutException
looper until the condition returns true.
Must be called on the thread corresponding to the looper.
looper - The Looper.condition - The condition.TimeoutException - If the DEFAULT_TIMEOUT_MS is exceeded.public static void runLooperUntil(Looper looper, Supplier<Boolean> condition, long timeoutMs, Clock clock) throws TimeoutException
looper until the condition returns true.
Must be called on the thread corresponding to the looper.
looper - The Looper.condition - The condition.timeoutMs - The timeout in milliseconds.clock - The Clock to measure the timeout.TimeoutException - If the timeoutMs timeout is exceeded.