From 08421180f46bd096cb3c99cff7949d2b4518bf8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Kubitz?= Date: Fri, 30 Sep 2022 13:33:57 +0200 Subject: [PATCH] try to fix AsyncContentAssistTest.testCompleteActivationChar() #35 forceFocus() seem to be not reliable that the control receives the key event. --- .../tests/contentassist/AsyncContentAssistTest.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/contentassist/AsyncContentAssistTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/contentassist/AsyncContentAssistTest.java index 751c1ffb9..83f9c28a5 100644 --- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/contentassist/AsyncContentAssistTest.java +++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/contentassist/AsyncContentAssistTest.java @@ -153,14 +153,19 @@ public void testCompleteActivationChar() { final Set beforeShells= Arrays.stream(display.getShells()).filter(Shell::isVisible).collect(Collectors.toSet()); Event keyEvent= new Event(); Control control= viewer.getTextWidget(); - display.timerExec(200, new Runnable() { + display.timerExec(0, new Runnable() { @Override public void run() { if (control.isDisposed()) { // https://github.com/eclipse-platform/eclipse.platform.text/issues/75#issuecomment-1263429480 return; // do not fail other unit tests } - control.forceFocus(); + control.getShell().forceActive(); + if (!control.forceFocus()) { + display.timerExec(200, this); + System.out.println("no focus"); + return; + } keyEvent.widget= control; keyEvent.type= SWT.KeyDown; keyEvent.character= 'b'; @@ -170,6 +175,7 @@ public void run() { control.getDisplay().post(keyEvent); DisplayHelper.driveEventQueue(control.getDisplay()); if (!document.get().startsWith("bb")) { + System.out.println("character b not added to control"); display.timerExec(200, this); } } @@ -185,7 +191,7 @@ protected boolean condition() { } return false; } - }.waitForCondition(display, 4000)); + }.waitForCondition(display, 40000)); } private static Table findCompletionSelectionControl(Widget control) {