Commit 24517bb6 authored by Anna.Kozlova's avatar Anna.Kozlova
Browse files

tests tree -> async: remove redundant EDT relocation

parent 78b40d63
Showing with 5 additions and 53 deletions
+5 -53
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework.sm;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.ui.UIUtil;
/**
* @author Roman Chernyatchik
*/
public class SMRunnerUtil {
private static final Logger LOG = Logger.getInstance(SMRunnerUtil.class.getName());
private SMRunnerUtil() {
}
/**
* Adds runnable to Event Dispatch Queue
* if we aren't in UnitTest of Headless environment mode
* @param runnable Runnable
*/
public static void addToInvokeLater(final Runnable runnable) {
final Application application = ApplicationManager.getApplication();
if (application.isHeadlessEnvironment() && !application.isUnitTestMode()) {
runnable.run();
} else {
UIUtil.invokeLaterIfNeeded(runnable);
}
}
public static void runInEventDispatchThread(final Runnable runnable, final ModalityState state) {
try {
ApplicationManager.getApplication().invokeAndWait(runnable, state);
}
catch (Exception e) {
LOG.warn(e);
}
}
}
......@@ -19,12 +19,10 @@ import com.intellij.execution.filters.HyperlinkInfo;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.testframework.*;
import com.intellij.execution.testframework.sm.SMRunnerUtil;
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
import com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView;
import com.intellij.execution.testframework.ui.TestResultsPanel;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.openapi.application.ModalityState;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......@@ -98,7 +96,7 @@ public class SMTRunnerConsoleView extends BaseTestsOutputConsoleView {
}
// print selected content
SMRunnerUtil.runInEventDispatchThread(() -> getPrinter().updateOnTestSelected(selectedTestProxy), ModalityState.NON_MODAL);
getPrinter().updateOnTestSelected(selectedTestProxy);
}
});
}
......
......@@ -25,7 +25,6 @@ import com.intellij.execution.process.ProcessOutputTypes;
import com.intellij.execution.testframework.*;
import com.intellij.execution.testframework.actions.ScrollToTestSourceAction;
import com.intellij.execution.testframework.export.TestResultsXmlFormatter;
import com.intellij.execution.testframework.sm.SMRunnerUtil;
import com.intellij.execution.testframework.sm.TestHistoryConfiguration;
import com.intellij.execution.testframework.sm.runner.*;
import com.intellij.execution.testframework.sm.runner.history.ImportedTestConsoleProperties;
......@@ -38,7 +37,6 @@ import com.intellij.ide.util.treeView.IndexComparator;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.progress.ProcessCanceledException;
......@@ -622,12 +620,10 @@ public class SMTestRunnerResultsForm extends TestResultsPanel
return;
}
SMRunnerUtil.runInEventDispatchThread(() -> {
if (myTreeBuilder.isDisposed()) {
return;
}
myTreeBuilder.select(testProxy, onDone);
}, ModalityState.NON_MODAL);
if (myTreeBuilder.isDisposed()) {
return;
}
myTreeBuilder.select(testProxy, onDone);
}
private void updateStatusLabel(final boolean testingFinished) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment