Skip to content

Commit e947e54

Browse files
committed
Adapt Test_org_eclipse_swt_events_KeyEvent for Windows Server 2025 #2516
This is WiP to analyze the issue with the Test_org_eclipse_swt_events_KeyEvent tests on Windows Server 2025.
1 parent 35119f0 commit e947e54

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/tests/win32/KeyboardLayoutTest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,20 @@ public void setUp(TestInfo testInfo) {
249249

250250
shell.setSize(100, 100);
251251
shell.open();
252+
shell.forceActive();
252253
shell.forceFocus();
254+
processEvents();
253255
}
254256

255257
@AfterEach
256-
public void tearDown() {
258+
public void tearDown() throws InterruptedException {
257259
if (shell != null) {
258260
shell.dispose();
259261
}
262+
for (int i = 0; i < 10; i++) {
263+
processEvents();
264+
Thread.sleep(50);
265+
}
260266
if (display != null) {
261267
display.dispose();
262268
}
@@ -360,6 +366,11 @@ protected void ensureShellFocused() {
360366
// Note that `Shell.isFocusControl()` still returns `true` even if a
361367
// different app is focused
362368
if (shell.handle != OS.GetForegroundWindow()) {
369+
System.out.println("handle of current shell: " + OS.GetForegroundWindow());
370+
System.out.println("handle of tracked shell: " + shell.handle);
371+
for (Shell shell : display.getShells()) {
372+
System.out.println(shell.handle + ": " + shell.toString());
373+
}
363374
fail("Test Shell lost focus (did you use keyboard/mouse while the test was running?)");
364375
}
365376
}
@@ -501,6 +512,7 @@ protected void onKeyError(AssertionError error) {
501512
}
502513

503514
protected void expectKeyEvents(String testName, Runnable runnable, Event... expectEvents) {
515+
shell.forceActive();
504516
events.clear();
505517
runnable.run();
506518

0 commit comments

Comments
 (0)