MainTestClock

sealed interface MainTestClock

Manual control over the frames ComposeSwingTest sends its own composition.

ComposeSwingTest.awaitIdle brings a composition to idle by sending it frames; this clock decides whether those frames happen on their own (autoAdvance true, the default, leaving every gate's behavior unchanged) or only when a test sends one, which is what makes it possible to observe a frame-driven animation partway through rather than only once it has run to completion.

Every call that sends a frame fails the same way ComposeSwingTest.awaitIdle does.

This clock governs only ComposeSwingTest's own off-screen composition. Content composed under a real org.jetbrains.compose.swing.window.Window or org.jetbrains.compose.swing.window.Dialog runs on that window's own recomposer, whose frame-driven work is paced by the display that window is on - this clock has no effect on it.

Properties

Link copied to clipboard
abstract var autoAdvance: Boolean

Whether ComposeSwingTest.awaitIdle sends frames on its own to reach idle. true by default.

Link copied to clipboard
abstract val currentTime: Duration

The composition time reached by the frames sent so far, whichever call sent them.

Link copied to clipboard
abstract val frameDuration: Duration

The duration a single frame advances currentTime by: one frame of a 60Hz display, whichever gate sent it - not the host display's refresh rate.

Functions

Link copied to clipboard
abstract fun advanceTimeBy(duration: Duration, ignoreFrameDuration: Boolean = false)

Advances currentTime by duration.

Link copied to clipboard
abstract fun advanceTimeByFrame()

Sends one frame, advancing currentTime by frameDuration, and returns once the frame's effects have propagated as far as they can without another one.

Link copied to clipboard
abstract suspend fun advanceTimeUntil(timeout: Duration = 1.seconds, condition: () -> Boolean)

Sends frames, one at a time, until condition returns true. A failure is thrown as itself, never as a ComposeTimeoutException.