Skip to content

Commit

Permalink
Correct waiting condition in CompletionTest eclipse-platform#906 ecli…
Browse files Browse the repository at this point in the history
…pse-platform#907

In the CompletionTest, the check for the completion proposals waits for
the full list of proposal items to be calculated. The condition is never
fulfilled because it checks for the first proposal item to change while
only its data will be replaced. In consequence, waiting for the
condition always runs into a timeout.

This change corrects the conditions and refactors the logic for checking
for the "computing" entry into a separate method.

Contributes to
eclipse-platform#906 and
eclipse-platform#907
  • Loading branch information
HeikoKlare committed Jul 25, 2023
1 parent b423b06 commit 30b4fc7
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ protected boolean condition() {
return completionProposalList.getItemCount() == 2;
}
}.waitForCondition(completionProposalList.getDisplay(), 200));
final TableItem computingItem = completionProposalList.getItem(0);
assertTrue("Missing computing info entry", computingItem.getText().contains("Computing")); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("Missing computing info entry", isComputingInfoEntry(completionProposalList.getItem(0)));
TableItem completionProposalItem = completionProposalList.getItem(1);
final ICompletionProposal selectedProposal = (ICompletionProposal)completionProposalItem.getData();
assertTrue("Incorrect proposal content", BarContentAssistProcessor.PROPOSAL.endsWith(selectedProposal .getDisplayString()));
Expand All @@ -181,7 +180,7 @@ protected boolean condition() {
new DisplayHelper() {
@Override
protected boolean condition() {
return completionProposalList.getItem(0) != computingItem && completionProposalList.getItemCount() == 2;
return !isComputingInfoEntry(completionProposalList.getItem(0)) && completionProposalList.getItemCount() == 2;
}
}.waitForCondition(completionProposalList.getDisplay(), LongRunningBarContentAssistProcessor.DELAY + 200);
completionProposalItem = completionProposalList.getItem(0);
Expand All @@ -190,6 +189,11 @@ protected boolean condition() {
assertTrue("Proposal content seems incorrect", LongRunningBarContentAssistProcessor.PROPOSAL.endsWith(((ICompletionProposal)otherProposalItem.getData()).getDisplayString()));
assertEquals("Addition of completion proposal should keep selection", selectedProposal, completionProposalList.getSelection()[0].getData());
}

private static boolean isComputingInfoEntry(TableItem item) {
final String expectedComputingEntrySubstring = "Computing";
return item.getText().contains(expectedComputingEntrySubstring);
}

public static Shell findNewShell(Set<Shell> beforeShells, Display display, boolean expectShell) {
Shell[] afterShells = Arrays.stream(display.getShells())
Expand All @@ -215,8 +219,7 @@ protected boolean condition() {
}
}.waitForCondition(completionShell.getDisplay(), 200);
assertEquals(2, completionProposalList.getItemCount());
final TableItem computingItem = completionProposalList.getItem(0);
assertTrue("Missing computing info entry", computingItem.getText().contains("Computing")); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("Missing computing info entry", isComputingInfoEntry(completionProposalList.getItem(0)));
// Some processors are long running, moving cursor can cause freeze (bug 521484)
// asynchronous
long timestamp = System.currentTimeMillis();
Expand Down

0 comments on commit 30b4fc7

Please sign in to comment.