From 7758875955fd51652f8c0efe1a609d7eed66fac8 Mon Sep 17 00:00:00 2001 From: Nicolay Mitropolsky Date: Tue, 24 Oct 2017 17:04:12 +0300 Subject: [PATCH] `EdtTestUtil.runInEdtAndWait` fix for proper user action emulation changed because `com.intellij.ide.IdeEventQueue` doesn't consider events from `SwingUtilities.invokeAndWait` as user interaction --- .../org/jetbrains/kotlin/test/testFramework/EdtTestUtil.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/EdtTestUtil.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/EdtTestUtil.kt index 1ccf51aa3dc..e42071d1ed6 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/EdtTestUtil.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/EdtTestUtil.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.test.testFramework +import com.intellij.openapi.application.ApplicationManager import org.jetbrains.annotations.TestOnly import java.lang.reflect.InvocationTargetException import javax.swing.SwingUtilities @@ -39,7 +40,11 @@ fun runInEdtAndWait(runnable: () -> Unit) { } else { try { - SwingUtilities.invokeAndWait(runnable) + val application = ApplicationManager.getApplication() + if (application != null) + application.invokeAndWait(runnable) + else + SwingUtilities.invokeAndWait(runnable) } catch (e: InvocationTargetException) { throw e.cause ?: e