@UnstableApi
class DummyMainThread


Helper class to simulate main/UI thread in tests.

Summary

Nested types

Runnable variant which can throw a checked exception.

Constants

const Int
TIMEOUT_MS = 10000

Default timeout value used for runOnMainThread.

Public constructors

Public functions

Unit
Unit

Runs the provided Runnable on the main thread, blocking until execution completes or until TIMEOUT_MS milliseconds have passed.

Unit
runOnMainThread(timeoutMs: Int, runnable: Runnable!)

Runs the provided Runnable on the main thread, blocking until execution completes or until timeout milliseconds have passed.

Unit

Runs the provided TestRunnable on the main thread, blocking until execution completes or until TIMEOUT_MS milliseconds have passed.

Unit
runTestOnMainThread(
    timeoutMs: Int,
    runnable: DummyMainThread.TestRunnable!
)

Runs the provided TestRunnable on the main thread, blocking until execution completes or until timeout milliseconds have passed.

Constants

TIMEOUT_MS

const val TIMEOUT_MS = 10000: Int

Default timeout value used for runOnMainThread.

Public constructors

DummyMainThread

DummyMainThread()

Public functions

release

fun release(): Unit

runOnMainThread

fun runOnMainThread(runnable: Runnable!): Unit

Runs the provided Runnable on the main thread, blocking until execution completes or until TIMEOUT_MS milliseconds have passed.

Parameters
runnable: Runnable!

The Runnable to run.

runOnMainThread

fun runOnMainThread(timeoutMs: Int, runnable: Runnable!): Unit

Runs the provided Runnable on the main thread, blocking until execution completes or until timeout milliseconds have passed.

Parameters
timeoutMs: Int

The maximum time to wait in milliseconds.

runnable: Runnable!

The Runnable to run.

runTestOnMainThread

fun runTestOnMainThread(runnable: DummyMainThread.TestRunnable!): Unit

Runs the provided TestRunnable on the main thread, blocking until execution completes or until TIMEOUT_MS milliseconds have passed.

Parameters
runnable: DummyMainThread.TestRunnable!

The TestRunnable to run.

runTestOnMainThread

fun runTestOnMainThread(
    timeoutMs: Int,
    runnable: DummyMainThread.TestRunnable!
): Unit

Runs the provided TestRunnable on the main thread, blocking until execution completes or until timeout milliseconds have passed.

Parameters
timeoutMs: Int

The maximum time to wait in milliseconds.

runnable: DummyMainThread.TestRunnable!

The TestRunnable to run.