TestComposeWindow



A virtual window for testing purposes.

After setContent it composes content immediately and draws it on a virtual surface.

It doesn't dispatch frames by default. If frame dispatching is needed, pass appropriate dispatcher as coroutineContext (for example, Dispatchers.Swing)

Summary

Public constructors

TestComposeWindow(
    width: Int,
    height: Int,
    density: Density,
    nanoTime: () -> Long,
    coroutineContext: CoroutineContext
)
android

Public functions

Unit

Clear-up all acquired resources and stop all pending work

android
Boolean

Returns true if there are pending work scheduled by this window

android
Unit

Process mouse enter event

android
Unit

Process mouse exit event

android
Unit
onMouseMoved(x: Int, y: Int)

Process mouse move event

android
Unit
onMouseScroll(x: Int, y: Int, event: MouseScrollEvent)

Process mouse scroll event

android
Unit
android
Unit
setContent(content: @Composable () -> Unit)

Compose content immediately and draw it on a surface

android

Public properties

Cursor
android
Density
android
Int
android
Set<RootForTest>

All currently registered RootForTests

android
Surface

Virtual surface on which the content will be drawn

android
Int
android

Public constructors

TestComposeWindow

TestComposeWindow(
    width: Int,
    height: Int,
    density: Density = Density(1f, 1f),
    nanoTime: () -> Long = System::nanoTime,
    coroutineContext: CoroutineContext = EmptyDispatcher
)

Public functions

dispose

fun dispose(): Unit

Clear-up all acquired resources and stop all pending work

hasInvalidations

fun hasInvalidations(): Boolean

Returns true if there are pending work scheduled by this window

onMouseEntered

fun onMouseEntered(x: Int, y: Int): Unit

Process mouse enter event

onMouseExited

fun onMouseExited(): Unit

Process mouse exit event

onMouseMoved

fun onMouseMoved(x: Int, y: Int): Unit

Process mouse move event

onMouseScroll

fun onMouseScroll(x: Int, y: Int, event: MouseScrollEvent): Unit

Process mouse scroll event

render

fun render(): Unit

setContent

fun setContent(content: @Composable () -> Unit): Unit

Compose content immediately and draw it on a surface

Public properties

currentCursor

val currentCursorCursor

density

val densityDensity

height

val heightInt

roots

val rootsSet<RootForTest>

All currently registered RootForTests

surface

val surfaceSurface

Virtual surface on which the content will be drawn

width

val widthInt