Skip to content

Commit 290fc87

Browse files
committed
Refactor KeyButtonTest to improve headless environment setup - Added OS
check for software rendering and conditional Monocle platform initialization.
1 parent 3400e29 commit 290fc87

5 files changed

Lines changed: 13 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ jobs:
1919
-Djava.awt.headless=true
2020
-Dprism.order=sw
2121
-Dprism.forceGPU=false
22-
-Dglass.platform=Monocle
23-
-Dmonocle.platform=Headless
2422
steps:
2523
- uses: actions/checkout@v4
2624
- name: Set up JDK ${{ matrix.java-version }}

.github/workflows/maven-deploy.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ jobs:
1212
-Djava.awt.headless=true
1313
-Dprism.order=sw
1414
-Dprism.forceGPU=false
15-
-Dglass.platform=Monocle
16-
-Dmonocle.platform=Headless
1715
environment: OSSRH
1816
steps:
1917
- uses: actions/checkout@v4

.github/workflows/maven-publish.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ jobs:
1414
-Djava.awt.headless=true
1515
-Dprism.order=sw
1616
-Dprism.forceGPU=false
17-
-Dglass.platform=Monocle
18-
-Dmonocle.platform=Headless
1917
environment: OSSRH
2018
name: Publish artifact via Central Portal
2119
steps:

.github/workflows/maven-release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ jobs:
1515
-Djava.awt.headless=true
1616
-Dprism.order=sw
1717
-Dprism.forceGPU=false
18-
-Dglass.platform=Monocle
19-
-Dmonocle.platform=Headless
2018
environment: OSSRH
2119
name: Publish artifact via Central Portal
2220
steps:

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,24 @@ class KeyButtonTest {
2323

2424
@BeforeAll
2525
static void initToolkit() throws Exception {
26-
if (!OS.WINDOWS.isCurrentOs()) {
26+
if (OS.WINDOWS.isCurrentOs()) {
2727
// Ensure headless property is set early in CI via JAVA_TOOL_OPTIONS; this is
2828
// just in case.
2929
System.setProperty("java.awt.headless", System.getProperty("java.awt.headless", "true"));
3030
System.setProperty("prism.order", "sw");
3131
System.setProperty("prism.forceGPU", "false");
32-
System.setProperty("glass.platform", "Monocle");
33-
System.setProperty("monocle.platform", "Headless");
32+
33+
// Monocle platform is not available on all systems (e.g., Linux with JDK 25)
34+
// Only set it if the Glass factory class is available
35+
try {
36+
Class.forName("com.sun.glass.ui.monocle.MonoclePlatformFactory");
37+
System.setProperty("glass.platform", "Monocle");
38+
System.setProperty("monocle.platform", "Headless");
39+
} catch (ClassNotFoundException ex) {
40+
// Monocle not available, use default glass implementation
41+
System.err.println("Monocle platform not available, using default glass implementation");
42+
}
43+
3444
}
3545
// Initialize JavaFX toolkit (safe if already started)
3646
try {

0 commit comments

Comments
 (0)