Skip to content

Commit a745737

Browse files
committed
Adjust wait for dialog contents in QuickAccessDialogTest, enable debug outputs
Adjusted the wait for initial dialog contents in QuickAccessDialogTest.testPreviousChoicesAvailableForExtension(), to rely on QuickAccessDialog.setInfoText() instead of relying on specific dialog contents set during the test. Additionally debug outputs are added when setting dialog contents, the debug outputs are enabled for QuickAccessDialogTest. See: #4009
1 parent de45bf4 commit a745737

3 files changed

Lines changed: 40 additions & 6 deletions

File tree

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/misc/Policy.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ public class Policy {
112112
*/
113113
public static boolean DEBUG_OPERATIONS = DEFAULT;
114114

115+
/**
116+
* Whether to print debugging information for quick access processing.
117+
*/
118+
public static boolean DEBUG_QUICK_ACCESS = DEFAULT;
119+
115120
/**
116121
* Whether to print out verbose information about the operation histories,
117122
* including all notifications sent.
@@ -178,6 +183,7 @@ public class Policy {
178183
DEBUG_HANDLERS_PERFORMANCE = getDebugOption("/trace/handlers.performance"); //$NON-NLS-1$
179184
DEBUG_HANDLERS_VERBOSE = getDebugOption("/trace/handlers.verbose"); //$NON-NLS-1$
180185
DEBUG_OPERATIONS = getDebugOption("/trace/operations"); //$NON-NLS-1$
186+
DEBUG_QUICK_ACCESS = getDebugOption("/trace/quickaccess"); //$NON-NLS-1$
181187
DEBUG_OPERATIONS_VERBOSE = getDebugOption("/trace/operations.verbose"); //$NON-NLS-1$
182188
DEBUG_SHOW_ALL_JOBS = getDebugOption("/debug/showAllJobs"); //$NON-NLS-1$
183189
DEBUG_STALE_JOBS = getDebugOption("/debug/job.stale"); //$NON-NLS-1$

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import java.util.regex.Matcher;
3737
import java.util.regex.Pattern;
3838
import java.util.stream.Collectors;
39+
import java.util.stream.Stream;
40+
import org.eclipse.core.commands.internal.util.Tracing;
3941
import org.eclipse.core.runtime.Adapters;
4042
import org.eclipse.core.runtime.IProgressMonitor;
4143
import org.eclipse.core.runtime.IStatus;
@@ -81,6 +83,7 @@
8183
import org.eclipse.ui.IWorkbenchPreferenceConstants;
8284
import org.eclipse.ui.PlatformUI;
8385
import org.eclipse.ui.internal.WorkbenchPlugin;
86+
import org.eclipse.ui.internal.misc.Policy;
8487
import org.eclipse.ui.keys.IBindingService;
8588
import org.eclipse.ui.progress.UIJob;
8689
import org.eclipse.ui.quickaccess.QuickAccessElement;
@@ -183,6 +186,12 @@ public void done(IJobChangeEvent event) {
183186
computingFeedbackJob.cancel();
184187
if (computeProposalsJob == currentComputeEntriesJob && event.getResult().isOK()
185188
&& !table.isDisposed()) {
189+
if (Policy.DEBUG_QUICK_ACCESS) {
190+
Tracing.printTrace(QuickAccessContents.class.getName(),
191+
"[" + Thread.currentThread().getName() + "] Setting quick access contents: " + //$NON-NLS-1$ //$NON-NLS-2$
192+
Stream.of(entries.get()).flatMap(List::stream).map(e -> e.element.getId())
193+
.toList());
194+
}
186195
display.asyncExec(() -> {
187196
computingFeedbackJob.cancel();
188197
refreshTable(perfectMatch, entries.get(), filter);

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/quickaccess/QuickAccessDialogTest.java

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,14 @@
4545
import org.eclipse.ui.commands.ICommandService;
4646
import org.eclipse.ui.handlers.IHandlerService;
4747
import org.eclipse.ui.ide.IDE;
48+
import org.eclipse.ui.internal.misc.Policy;
4849
import org.eclipse.ui.internal.quickaccess.QuickAccessDialog;
4950
import org.eclipse.ui.internal.quickaccess.QuickAccessMessages;
5051
import org.eclipse.ui.tests.harness.util.CloseTestWindowsExtension;
5152
import org.eclipse.ui.tests.harness.util.DisplayHelper;
53+
import org.junit.jupiter.api.AfterAll;
5254
import org.junit.jupiter.api.AfterEach;
55+
import org.junit.jupiter.api.BeforeAll;
5356
import org.junit.jupiter.api.BeforeEach;
5457
import org.junit.jupiter.api.Test;
5558
import org.junit.jupiter.api.extension.ExtendWith;
@@ -63,6 +66,8 @@ public class QuickAccessDialogTest {
6366

6467
private class TestQuickAccessDialog extends QuickAccessDialog {
6568

69+
private volatile String infoText;
70+
6671
public TestQuickAccessDialog(IWorkbenchWindow activeWorkbenchWindow, Command command) {
6772
super(activeWorkbenchWindow, command);
6873
}
@@ -71,6 +76,12 @@ public TestQuickAccessDialog(IWorkbenchWindow activeWorkbenchWindow, Command com
7176
protected IDialogSettings getDialogSettings() {
7277
return dialogSettings;
7378
}
79+
80+
@Override
81+
protected void setInfoText(String text) {
82+
super.setInfoText(text);
83+
infoText = text;
84+
}
7485
}
7586

7687
private static final int TIMEOUT = 5000;
@@ -81,6 +92,15 @@ protected IDialogSettings getDialogSettings() {
8192
private IDialogSettings dialogSettings;
8293
private IWorkbenchWindow activeWorkbenchWindow;
8394

95+
@BeforeAll
96+
public static void enableDebugOutputs() {
97+
Policy.DEBUG_QUICK_ACCESS = true;
98+
}
99+
100+
@AfterAll
101+
public static void disableDebugOutputs() {
102+
Policy.DEBUG_QUICK_ACCESS = false;
103+
}
84104

85105
@BeforeEach
86106
public void setUp() throws Exception {
@@ -294,17 +314,16 @@ private void activateCurrentElement(QuickAccessDialog dialog) {
294314
@Test
295315
public void testPreviousChoicesAvailableForExtension() {
296316
// add one selection to history
297-
QuickAccessDialog dialog = new TestQuickAccessDialog(activeWorkbenchWindow, null);
317+
TestQuickAccessDialog dialog = new TestQuickAccessDialog(activeWorkbenchWindow, null);
298318
Text text = dialog.getQuickAccessContents().getFilterText();
299-
text.setText("initial test");
300319
dialog.open();
301320
/*
302-
* wait for the initial dialog contents, to avoid race conditions later on in the test, see:
321+
* wait for the dialog initialization, to avoid race conditions later on in the test, see:
303322
* https://github.com/eclipse-platform/eclipse.platform.ui/issues/4009
304323
*/
305-
assertTrue(DisplayHelper.waitForCondition(text.getDisplay(), TIMEOUT,
306-
() -> dialogContains(dialog, "initial test")),
307-
"Unexpected dialog contents: " + getAllEntries(dialog.getQuickAccessContents().getTable()));
324+
assertTrue(DisplayHelper.waitForCondition(text.getDisplay(), TIMEOUT * 1000,
325+
() -> dialog.infoText != null),
326+
"Unexpected dialog info: " + dialog.infoText);
308327
text.setText(TestQuickAccessComputer.TEST_QUICK_ACCESS_PROPOSAL_LABEL);
309328
final Table firstTable = dialog.getQuickAccessContents().getTable();
310329
assertTrue(DisplayHelper.waitForCondition(text.getDisplay(), TIMEOUT,

0 commit comments

Comments
 (0)