Skip to content

Commit

Permalink
Fix CompletionTest to find the completionShell
Browse files Browse the repository at this point in the history
Ignoring the additional Information Shell that may also show up.
  • Loading branch information
EcljpseB0T authored and jukzi committed Mar 5, 2024
1 parent 672a31b commit 39e1bc1
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Hashtable;
import java.util.LinkedList;
Expand Down Expand Up @@ -212,16 +213,19 @@ private static boolean isComputingInfoEntry(TableItem item) {
}

public static Shell findNewShell(Set<Shell> beforeShells, Display display, boolean expectShell) {
Shell[] afterShells = Arrays.stream(display.getShells())
.filter(Shell::isVisible)
.filter(shell -> !beforeShells.contains(shell))
.toArray(Shell[]::new);
Shell[] afterShells = findNewShells(beforeShells, display).toArray(Shell[]::new);
if (expectShell) {
assertEquals("No new shell found", 1, afterShells.length);
}
return afterShells.length > 0 ? afterShells[0] : null;
}

public static Collection<Shell> findNewShells(Set<Shell> beforeShells, Display display) {
List<Shell> result= Arrays.stream(display.getShells())
.filter(Shell::isVisible)
.filter(shell -> !beforeShells.contains(shell))
.toList();
return result;
}
@Test
public void testCompletionFreeze_bug521484() throws Exception {
assumeFalse("test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906", Util.isMac());
Expand All @@ -248,7 +252,7 @@ public void testMoveCaretBackUsesAllProcessors_bug522255() throws Exception {
emulatePressLeftArrowKey();
final Set<Shell> beforeShells = Arrays.stream(editor.getSite().getShell().getDisplay().getShells()).filter(Shell::isVisible).collect(Collectors.toSet());
DisplayHelper.sleep(editor.getSite().getShell().getDisplay(), 200);
this.completionShell= findNewShell(beforeShells, editor.getSite().getShell().getDisplay(), true);
this.completionShell= findNewShells(beforeShells, editor.getSite().getShell().getDisplay()).stream().filter(s->Arrays.stream(s.getChildren()).allMatch(w->w instanceof Table) ).findFirst().get();
final Table completionProposalList = findCompletionSelectionControl(this.completionShell);
checkCompletionContent(completionProposalList);
}
Expand Down

0 comments on commit 39e1bc1

Please sign in to comment.