Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ public class Policy {
*/
public static boolean DEBUG_OPERATIONS = DEFAULT;

/**
* Whether to print debugging information for quick access processing.
*/
public static boolean DEBUG_QUICK_ACCESS = DEFAULT;

/**
* Whether to print out verbose information about the operation histories,
* including all notifications sent.
Expand Down Expand Up @@ -178,6 +183,7 @@ public class Policy {
DEBUG_HANDLERS_PERFORMANCE = getDebugOption("/trace/handlers.performance"); //$NON-NLS-1$
DEBUG_HANDLERS_VERBOSE = getDebugOption("/trace/handlers.verbose"); //$NON-NLS-1$
DEBUG_OPERATIONS = getDebugOption("/trace/operations"); //$NON-NLS-1$
DEBUG_QUICK_ACCESS = getDebugOption("/trace/quickaccess"); //$NON-NLS-1$
DEBUG_OPERATIONS_VERBOSE = getDebugOption("/trace/operations.verbose"); //$NON-NLS-1$
DEBUG_SHOW_ALL_JOBS = getDebugOption("/debug/showAllJobs"); //$NON-NLS-1$
DEBUG_STALE_JOBS = getDebugOption("/debug/job.stale"); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.eclipse.core.commands.internal.util.Tracing;
import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
Expand Down Expand Up @@ -81,6 +83,7 @@
import org.eclipse.ui.IWorkbenchPreferenceConstants;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.internal.misc.Policy;
import org.eclipse.ui.keys.IBindingService;
import org.eclipse.ui.progress.UIJob;
import org.eclipse.ui.quickaccess.QuickAccessElement;
Expand Down Expand Up @@ -183,6 +186,12 @@ public void done(IJobChangeEvent event) {
computingFeedbackJob.cancel();
if (computeProposalsJob == currentComputeEntriesJob && event.getResult().isOK()
&& !table.isDisposed()) {
if (Policy.DEBUG_QUICK_ACCESS) {
Tracing.printTrace(QuickAccessContents.class.getName(),
"[" + Thread.currentThread().getName() + "] Setting quick access contents: " + //$NON-NLS-1$ //$NON-NLS-2$
Stream.of(entries.get()).flatMap(List::stream).map(e -> e.element.getId())
.toList());
}
display.asyncExec(() -> {
computingFeedbackJob.cancel();
refreshTable(perfectMatch, entries.get(), filter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
*******************************************************************************/
package org.eclipse.ui.tests.harness.util;

import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;

Expand All @@ -34,23 +37,7 @@ public final class TestRunLogUtil {
*
* Note: field must be public or JUnit4 will complain.
*/
public static TestWatcher LOG_TESTRUN = new TestWatcher() {
@Override
protected void starting(Description description) {
System.out.println(formatTestStartMessage(description.getMethodName()));
}

@Override
protected void failed(Throwable e, Description description) {
System.out.println(description.getMethodName() + " failed:");
e.printStackTrace(System.out);
}

@Override
protected void finished(Description description) {
System.out.println(formatTestFinishedMessage(description.getMethodName()));
}
};
public static TestWatcher LOG_TESTRUN = new LogTestWatcher();

/**
* Create message used to log start of a test.
Expand All @@ -72,6 +59,34 @@ public static String formatTestFinishedMessage(String testName) {
return testName + ": tearDown...\n"; //$NON-NLS-1$
}

private static class LogTestWatcher extends TestWatcher implements BeforeEachCallback, AfterEachCallback {
@Override
protected void starting(Description description) {
System.out.println(formatTestStartMessage(description.getMethodName()));
}

@Override
protected void failed(Throwable e, Description description) {
System.out.println(description.getMethodName() + " failed:");
e.printStackTrace(System.out);
}

@Override
protected void finished(Description description) {
System.out.println(formatTestFinishedMessage(description.getMethodName()));
}

@Override
public void beforeEach(ExtensionContext context) throws Exception {
System.out.println(formatTestStartMessage(context.getDisplayName()));
}

@Override
public void afterEach(ExtensionContext context) throws Exception {
System.out.println(formatTestFinishedMessage(context.getDisplayName()));
}
};

private TestRunLogUtil() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,20 @@
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.internal.misc.Policy;
import org.eclipse.ui.internal.quickaccess.QuickAccessDialog;
import org.eclipse.ui.internal.quickaccess.QuickAccessMessages;
import org.eclipse.ui.tests.harness.util.CloseTestWindowsExtension;
import org.eclipse.ui.tests.harness.util.DisplayHelper;
import org.eclipse.ui.tests.harness.util.TestRunLogUtil;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.rules.TestWatcher;

/**
* Tests the quick access UI
Expand All @@ -63,6 +69,8 @@ public class QuickAccessDialogTest {

private class TestQuickAccessDialog extends QuickAccessDialog {

private volatile String infoText;

public TestQuickAccessDialog(IWorkbenchWindow activeWorkbenchWindow, Command command) {
super(activeWorkbenchWindow, command);
}
Expand All @@ -71,6 +79,12 @@ public TestQuickAccessDialog(IWorkbenchWindow activeWorkbenchWindow, Command com
protected IDialogSettings getDialogSettings() {
return dialogSettings;
}

@Override
protected void setInfoText(String text) {
super.setInfoText(text);
infoText = text;
}
}

private static final int TIMEOUT = 5000;
Expand All @@ -81,6 +95,18 @@ protected IDialogSettings getDialogSettings() {
private IDialogSettings dialogSettings;
private IWorkbenchWindow activeWorkbenchWindow;

@RegisterExtension
public TestWatcher LOG_TESTRUN = TestRunLogUtil.LOG_TESTRUN;

@BeforeAll
public static void enableDebugOutputs() {
Policy.DEBUG_QUICK_ACCESS = true;
}

@AfterAll
public static void disableDebugOutputs() {
Policy.DEBUG_QUICK_ACCESS = false;
}

@BeforeEach
public void setUp() throws Exception {
Expand Down Expand Up @@ -294,17 +320,16 @@ private void activateCurrentElement(QuickAccessDialog dialog) {
@Test
public void testPreviousChoicesAvailableForExtension() {
// add one selection to history
QuickAccessDialog dialog = new TestQuickAccessDialog(activeWorkbenchWindow, null);
TestQuickAccessDialog dialog = new TestQuickAccessDialog(activeWorkbenchWindow, null);
Text text = dialog.getQuickAccessContents().getFilterText();
text.setText("initial test");
dialog.open();
/*
* wait for the initial dialog contents, to avoid race conditions later on in the test, see:
* wait for the dialog initialization, to avoid race conditions later on in the test, see:
* https://github.com/eclipse-platform/eclipse.platform.ui/issues/4009
*/
assertTrue(DisplayHelper.waitForCondition(text.getDisplay(), TIMEOUT,
() -> dialogContains(dialog, "initial test")),
"Unexpected dialog contents: " + getAllEntries(dialog.getQuickAccessContents().getTable()));
assertTrue(DisplayHelper.waitForCondition(text.getDisplay(), TIMEOUT * 1000,
() -> dialog.infoText != null),
"Unexpected dialog info: " + dialog.infoText);
text.setText(TestQuickAccessComputer.TEST_QUICK_ACCESS_PROPOSAL_LABEL);
final Table firstTable = dialog.getQuickAccessContents().getTable();
assertTrue(DisplayHelper.waitForCondition(text.getDisplay(), TIMEOUT,
Expand Down
Loading