Skip to content

ComposeTestClockOverride

Test-only override, installed by the client GameTest harness (AClientGameTestHarness.kt), that swaps ComposeScreen's real-time coroutine dispatcher for a virtual one so a composable's delay(...) (e.g. a dialog's close animation) resolves deterministically against a scheduler the harness drives itself, instead of racing real wall-clock time, real thread scheduling, and the harness's tick-based polling - the same class of flakiness Jetpack Compose's own test tooling (ComposeTestRule/runComposeUiTest) avoids by construction, backing composition with a virtual clock/dispatcher that waitForIdle() drives forward instead of polling real concurrency. null unless a client GameTest explicitly installs one; the running game never touches this.

Deliberately untyped against kotlinx-coroutines-test (CoroutineDispatcher is a kotlinx-coroutines-core type; pump is a plain lambda) - that dependency is dev/test-only (compileOnly in common, runtimeLibrary - present for local runs, never bundled - in the loader modules; see common/build.gradle.kts). ComposeScreen is loaded by every screen in the mod, so its own class file must never reference a symbol that isn't resolvable in a real player's game; only AClientGameTestHarness's method bodies (never invoked outside AGameTestPlatform.isGameTest) construct the actual StandardTestDispatcher/ TestCoroutineScheduler instances installed here.

Properties

dispatcher

@Volatile
var dispatcher: CoroutineDispatcher?

The dispatcher to back new ComposeScreens' coroutine scope with, in place of kotlinx.coroutines.Dispatchers.Default.

pump

@Volatile
var pump: () -> Unit?

Called once per real rendered frame by every live ComposeScreen while installed - drains all outstanding virtual-time work (recomposition, effects, delay(...)) synchronously on the render thread. Set alongside dispatcher to { scheduler.advanceUntilIdle() }.