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 interfaceDummyMainThread.TestRunnableRunnablevariant which can throw a checked exception.
-
Field Summary
Fields Modifier and Type Field Description static intTIMEOUT_MSDefault timeout value used forrunOnMainThread(Runnable).
-
Constructor Summary
Constructors Constructor Description DummyMainThread()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidrelease()voidrunOnMainThread(int timeoutMs, Runnable runnable)Runs the providedRunnableon the main thread, blocking until execution completes or until timeout milliseconds have passed.voidrunOnMainThread(Runnable runnable)Runs the providedRunnableon the main thread, blocking until execution completes or untilTIMEOUT_MSmilliseconds have passed.voidrunTestOnMainThread(int timeoutMs, DummyMainThread.TestRunnable runnable)Runs the providedDummyMainThread.TestRunnableon the main thread, blocking until execution completes or until timeout milliseconds have passed.voidrunTestOnMainThread(DummyMainThread.TestRunnable runnable)Runs the providedDummyMainThread.TestRunnableon the main thread, blocking until execution completes or untilTIMEOUT_MSmilliseconds 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 providedRunnableon the main thread, blocking until execution completes or untilTIMEOUT_MSmilliseconds have passed.- Parameters:
runnable- TheRunnableto run.
-
runOnMainThread
public void runOnMainThread(int timeoutMs, Runnable runnable)Runs the providedRunnableon the main thread, blocking until execution completes or until timeout milliseconds have passed.- Parameters:
timeoutMs- The maximum time to wait in milliseconds.runnable- TheRunnableto run.
-
runTestOnMainThread
public void runTestOnMainThread(DummyMainThread.TestRunnable runnable)
Runs the providedDummyMainThread.TestRunnableon the main thread, blocking until execution completes or untilTIMEOUT_MSmilliseconds have passed.- Parameters:
runnable- TheDummyMainThread.TestRunnableto run.
-
runTestOnMainThread
public void runTestOnMainThread(int timeoutMs, DummyMainThread.TestRunnable runnable)Runs the providedDummyMainThread.TestRunnableon the main thread, blocking until execution completes or until timeout milliseconds have passed.- Parameters:
timeoutMs- The maximum time to wait in milliseconds.runnable- TheDummyMainThread.TestRunnableto run.
-
release
public void release()
-
-