Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,14 @@ public void setUp(TestInfo testInfo) {

shell.setSize(100, 100);
shell.open();
shell.forceActive();
shell.forceFocus();
processEvents();
}

@AfterEach
public void tearDown() {
emulateScanCode(UsScan.Esc);
if (shell != null) {
shell.dispose();
}
Expand Down Expand Up @@ -360,6 +363,11 @@ protected void ensureShellFocused() {
// Note that `Shell.isFocusControl()` still returns `true` even if a
// different app is focused
if (shell.handle != OS.GetForegroundWindow()) {
System.out.println("handle of current shell: " + OS.GetForegroundWindow());
System.out.println("handle of tracked shell: " + shell.handle);
for (Shell shell : display.getShells()) {
System.out.println(shell.handle + ": " + shell.toString());
}
fail("Test Shell lost focus (did you use keyboard/mouse while the test was running?)");
}
}
Expand Down Expand Up @@ -501,6 +509,7 @@ protected void onKeyError(AssertionError error) {
}

protected void expectKeyEvents(String testName, Runnable runnable, Event... expectEvents) {
shell.forceActive();
events.clear();
runnable.run();

Expand Down
Loading