Skip to content

Commit 3400e29

Browse files
committed
Refactor headless property setup in KeyButtonTest - Moved software
rendering configuration for non-Windows OS into a conditional block for clarity
1 parent e384c76 commit 3400e29

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

fx-onscreen-keyboard/src/test/java/org/comtel2000/keyboard/control/KeyButtonTest.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,31 @@
77
import java.util.concurrent.CountDownLatch;
88
import java.util.concurrent.TimeUnit;
99
import java.util.concurrent.atomic.AtomicReference;
10-
import javafx.animation.Animation;
11-
import javafx.application.Platform;
12-
import javafx.scene.input.MouseButton;
13-
import javafx.scene.input.MouseEvent;
10+
1411
import org.junit.jupiter.api.AssertionFailureBuilder;
1512
import org.junit.jupiter.api.BeforeAll;
1613
import org.junit.jupiter.api.Test;
1714
import org.junit.jupiter.api.Timeout;
15+
import org.junit.jupiter.api.condition.OS;
16+
17+
import javafx.animation.Animation;
18+
import javafx.application.Platform;
19+
import javafx.scene.input.MouseButton;
20+
import javafx.scene.input.MouseEvent;
1821

1922
class KeyButtonTest {
2023

2124
@BeforeAll
2225
static void initToolkit() throws Exception {
23-
// Ensure headless property is set early in CI via JAVA_TOOL_OPTIONS; this is
24-
// just in case.
25-
System.setProperty("java.awt.headless", System.getProperty("java.awt.headless", "true"));
26-
System.setProperty("prism.order", "sw");
27-
System.setProperty("prism.forceGPU", "false");
28-
System.setProperty("glass.platform", "Monocle");
29-
System.setProperty("monocle.platform", "Headless");
30-
26+
if (!OS.WINDOWS.isCurrentOs()) {
27+
// Ensure headless property is set early in CI via JAVA_TOOL_OPTIONS; this is
28+
// just in case.
29+
System.setProperty("java.awt.headless", System.getProperty("java.awt.headless", "true"));
30+
System.setProperty("prism.order", "sw");
31+
System.setProperty("prism.forceGPU", "false");
32+
System.setProperty("glass.platform", "Monocle");
33+
System.setProperty("monocle.platform", "Headless");
34+
}
3135
// Initialize JavaFX toolkit (safe if already started)
3236
try {
3337
Platform.startup(
@@ -36,7 +40,7 @@ static void initToolkit() throws Exception {
3640
});
3741
} catch (IllegalStateException ex) {
3842
// toolkit already started
39-
} catch (NullPointerException | RuntimeException ex) {
43+
} catch (RuntimeException ex) {
4044
// Handle glass platform initialization failures in JDK 25+
4145
// This can occur when the glass platform factory is not properly initialized
4246
System.err.println("Warning: Failed to initialize JavaFX toolkit: " + ex.getMessage());

0 commit comments

Comments
 (0)