Skip to content

Commit

Permalink
try to fix AsyncContentAssistTest.testCompleteActivationChar() #35
Browse files Browse the repository at this point in the history
forceFocus() seem to be not reliable that the control receives the key
event.
  • Loading branch information
EcljpseB0T committed Sep 30, 2022
1 parent 221f8d2 commit 0842118
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,19 @@ public void testCompleteActivationChar() {
final Set<Shell> 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';
Expand All @@ -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);
}
}
Expand All @@ -185,7 +191,7 @@ protected boolean condition() {
}
return false;
}
}.waitForCondition(display, 4000));
}.waitForCondition(display, 40000));
}

private static Table findCompletionSelectionControl(Widget control) {
Expand Down

0 comments on commit 0842118

Please sign in to comment.