From 81d6f494b0530d3a56445263a2a39012746aa60e Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Sat, 4 Oct 2025 11:43:16 +0200 Subject: [PATCH] [Win32] Add PrtScr hotkey check for KeyEvent tests #2516 The Win32 KeyEvent tests started to fail on GitHub Actions when the environment was updated to Windows Server 2025. Using the print screen button opens the Windows snipping tools which, for yet unknown reason, now receives the focus and does not close automatically when processing further key events, like it did before and does on Windows 11 systems. To keep the tests working properly, this change excludes the PtrScr key as a system hotkey when not combined with any modifier key. Fixes https://github.com/eclipse-platform/eclipse.platform.swt/issues/2516 Co-authored-by: Jonah Graham --- .../tests/win32/Test_org_eclipse_swt_events_KeyEvent.java | 7 +++++-- tests/org.eclipse.swt.tests.win32/META-INF/MANIFEST.MF | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/tests/win32/Test_org_eclipse_swt_events_KeyEvent.java b/tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/tests/win32/Test_org_eclipse_swt_events_KeyEvent.java index 26c0a5406c3..54faba6a2a9 100644 --- a/tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/tests/win32/Test_org_eclipse_swt_events_KeyEvent.java +++ b/tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/tests/win32/Test_org_eclipse_swt_events_KeyEvent.java @@ -18,7 +18,6 @@ import org.eclipse.swt.widgets.Event; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable; /** * Automated Test Suite for class org.eclipse.swt.events.KeyEvent @@ -26,7 +25,6 @@ * @see org.eclipse.swt.events.KeyEvent */ @SuppressWarnings("restriction") -@DisabledIfEnvironmentVariable(named = "GITHUB_ACTIONS", matches = "true", disabledReason = "Windows Server 2025 incompatibility: https://github.com/eclipse-platform/eclipse.platform.swt/issues/2516") public class Test_org_eclipse_swt_events_KeyEvent extends KeyboardLayoutTest { // Windows layouts suitable for 'LoadKeyboardLayout()', obtained from 'GetKeyboardLayoutName()' static char[] LAYOUT_BENGALI = "00020445\0".toCharArray(); @@ -111,6 +109,11 @@ private boolean isSystemHotkey(int state, UsScan scanCode) { return true; } break; + case PrtScr: + switch (state) { + case ____: // Opens snipping tool + return true; + } case F4: switch (state) { case A___: // Closes current Shell diff --git a/tests/org.eclipse.swt.tests.win32/META-INF/MANIFEST.MF b/tests/org.eclipse.swt.tests.win32/META-INF/MANIFEST.MF index bbafa60bf81..2c3b7b737f1 100644 --- a/tests/org.eclipse.swt.tests.win32/META-INF/MANIFEST.MF +++ b/tests/org.eclipse.swt.tests.win32/META-INF/MANIFEST.MF @@ -9,7 +9,6 @@ Eclipse-BundleShape: dir Bundle-RequiredExecutionEnvironment: JavaSE-17 Automatic-Module-Name: org.eclipse.swt.tests.win32 Import-Package: org.junit.jupiter.api;version="[5.13.0,6.0.0)", - org.junit.jupiter.api.condition;version="[5.13.0,6.0.0)", org.junit.jupiter.params;version="[5.13.0,6.0.0)", org.junit.jupiter.params.provider;version="[5.13.0,6.0.0)", org.junit.platform.suite.api;version="[1.13.0,2.0.0)"