Skip to content

Commit 8aa1822

Browse files
committed
Fix no window flash on first show test on Windows
1 parent de7f17a commit 8aa1822

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

skiko/src/awtTest/kotlin/org/jetbrains/skiko/FirstWindowShowFlashHelper.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import org.jetbrains.skia.Rect
88
import java.awt.BorderLayout
99
import java.awt.Color
1010
import java.awt.Dimension
11+
import java.awt.Point
1112
import javax.swing.JFrame
1213
import javax.swing.SwingUtilities
1314

@@ -25,10 +26,8 @@ import javax.swing.SwingUtilities
2526
object FirstWindowShowFlashHelper {
2627
// Hard-coded window bounds. The parent (SkiaLayerTest."no window flash on first show") positions its
2728
// background window so that the pixel it samples (the background's center) falls within these bounds.
28-
private const val X = 400
29-
private const val Y = 400
30-
private const val WIDTH = 600
31-
private const val HEIGHT = 600
29+
private val WINDOW_LOCATION = Point(400, 400)
30+
private val WINDOW_SIZE = Dimension(600, 600)
3231

3332
@JvmStatic
3433
fun main(args: Array<String>) {
@@ -57,8 +56,8 @@ object FirstWindowShowFlashHelper {
5756

5857
JFrame().apply {
5958
contentPane.add(layer, BorderLayout.CENTER)
60-
setLocation(X, Y)
61-
size = Dimension(WIDTH, HEIGHT)
59+
location = WINDOW_LOCATION
60+
size = WINDOW_SIZE
6261
// Ensure our window lands above the parent's background window at these coordinates.
6362
isAlwaysOnTop = true
6463
isVisible = true

skiko/src/awtTest/kotlin/org/jetbrains/skiko/SkiaLayerTest.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,8 @@ class SkiaLayerTest {
11341134
// Until the issue is fixed in other redrawers
11351135
// Don't use assumeTrue, as uiTest iterates over multiple renderers,
11361136
// and if one of them is skipped, the whole test is skipped
1137-
if (renderApi != GraphicsApi.METAL) return@uiTest
1137+
val fixedRenderApis = setOf(GraphicsApi.METAL/*, GraphicsApi.DIRECT3D*/)
1138+
if (renderApi !in fixedRenderApis) return@uiTest
11381139

11391140
val bgColor = Color.GREEN
11401141
val fgColor = Color.BLACK
@@ -1147,8 +1148,8 @@ class SkiaLayerTest {
11471148
// child's content) or green (this background) - never a flash of some other color.
11481149

11491150
val backgroundWindow = JFrame().also {
1150-
it.size = Dimension(1000, 1000)
11511151
it.location = Point(200, 200)
1152+
it.size = Dimension(1000, 1000)
11521153
it.contentPane.background = bgColor
11531154
}
11541155
backgroundWindow.isVisible = true
@@ -1196,7 +1197,7 @@ class SkiaLayerTest {
11961197
add("-cp")
11971198
add(System.getProperty("java.class.path"))
11981199
System.getProperties().stringPropertyNames()
1199-
.filter { it.startsWith("skiko.") }
1200+
.filter { it.startsWith("skiko.") || it.startsWith("sun.") }
12001201
.forEach { add("-D$it=${System.getProperty(it)}") }
12011202
add("--add-opens")
12021203
add("java.desktop/sun.font=ALL-UNNAMED")

0 commit comments

Comments
 (0)