Skip to content

Commit

Permalink
Write hover/move tests (MouseMoveTest)
Browse files Browse the repository at this point in the history
  • Loading branch information
igordmn committed Sep 27, 2023
1 parent 2802943 commit 56bebb9
Show file tree
Hide file tree
Showing 3 changed files with 692 additions and 308 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ import java.text.AttributedString
import javax.swing.Icon
import javax.swing.ImageIcon
import kotlin.math.floor
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.yield
import org.jetbrains.skiko.MainUIDispatcher

fun testImage(color: Color): Painter = run {
val bitmap = ImageBitmap(100, 100)
Expand Down Expand Up @@ -210,4 +212,17 @@ fun Dimension.toDpSize() = DpSize(width.dp, height.dp)

fun Point.toWindowPosition() = WindowPosition(x.dp, y.dp)

fun Size.toInt() = IntSize(width.toInt(), height.toInt())
fun Size.toInt() = IntSize(width.toInt(), height.toInt())

// to avoid races between GlobalSnapshotManager and scene.render, we need to run test in UI thread
//
// It is a bug of ImageComposeScene,
// calling scene.render should apply or await all global snapshot changes
// instead, it can skip sometimes applying changes,
// because GlobalSnapshotManager is currently applying them
// this results that scene.render won't recompose anything, event if there are states changed
internal inline fun <R> ImageComposeScene.useInUiThread(
crossinline block: (ImageComposeScene) -> R
): R = runBlocking(MainUIDispatcher) {
use(block)
}

This file was deleted.

0 comments on commit 56bebb9

Please sign in to comment.