Class DummyMainThread
- java.lang.Object
-
- com.google.android.exoplayer2.testutil.DummyMainThread
-
public final class DummyMainThread extends Object
Helper class to simulate main/UI thread in tests.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
DummyMainThread.TestRunnable
Runnable
variant which can throw a checked exception.
-
Field Summary
Fields Modifier and Type Field Description static int
TIMEOUT_MS
Default timeout value used forrunOnMainThread(Runnable)
.
-
Constructor Summary
Constructors Constructor Description DummyMainThread()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
release()
void
runOnMainThread(int timeoutMs, Runnable runnable)
Runs the providedRunnable
on the main thread, blocking until execution completes or until timeout milliseconds have passed.void
runOnMainThread(Runnable runnable)
Runs the providedRunnable
on the main thread, blocking until execution completes or untilTIMEOUT_MS
milliseconds have passed.void
runTestOnMainThread(int timeoutMs, DummyMainThread.TestRunnable runnable)
Runs the providedDummyMainThread.TestRunnable
on the main thread, blocking until execution completes or until timeout milliseconds have passed.void
runTestOnMainThread(DummyMainThread.TestRunnable runnable)
Runs the providedDummyMainThread.TestRunnable
on the main thread, blocking until execution completes or untilTIMEOUT_MS
milliseconds have passed.
-
-
-
Field Detail
-
TIMEOUT_MS
public static final int TIMEOUT_MS
Default timeout value used forrunOnMainThread(Runnable)
.- See Also:
- Constant Field Values
-
-
Method Detail
-
runOnMainThread
public void runOnMainThread(Runnable runnable)
Runs the providedRunnable
on the main thread, blocking until execution completes or untilTIMEOUT_MS
milliseconds have passed.- Parameters:
runnable
- TheRunnable
to run.
-
runOnMainThread
public void runOnMainThread(int timeoutMs, Runnable runnable)
Runs the providedRunnable
on the main thread, blocking until execution completes or until timeout milliseconds have passed.- Parameters:
timeoutMs
- The maximum time to wait in milliseconds.runnable
- TheRunnable
to run.
-
runTestOnMainThread
public void runTestOnMainThread(DummyMainThread.TestRunnable runnable)
Runs the providedDummyMainThread.TestRunnable
on the main thread, blocking until execution completes or untilTIMEOUT_MS
milliseconds have passed.- Parameters:
runnable
- TheDummyMainThread.TestRunnable
to run.
-
runTestOnMainThread
public void runTestOnMainThread(int timeoutMs, DummyMainThread.TestRunnable runnable)
Runs the providedDummyMainThread.TestRunnable
on the main thread, blocking until execution completes or until timeout milliseconds have passed.- Parameters:
timeoutMs
- The maximum time to wait in milliseconds.runnable
- TheDummyMainThread.TestRunnable
to run.
-
release
public void release()
-
-