diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaunchOnShowTest.kt b/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaunchOnShowTest.kt index 2ac3515426c3..4aaa0449ba02 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaunchOnShowTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaunchOnShowTest.kt @@ -5,6 +5,7 @@ import com.intellij.openapi.application.EDT import com.intellij.platform.ide.progress.ModalTaskOwner import com.intellij.platform.ide.progress.TaskCancellation import com.intellij.platform.ide.progress.withModalProgress +import com.intellij.testFramework.PlatformTestUtil import com.intellij.testFramework.common.timeoutRunBlocking import com.intellij.testFramework.junit5.TestApplication import com.intellij.ui.ComponentUtil.forceMarkAsShowing @@ -114,6 +115,24 @@ class LaunchOnShowTest { assertTrue(awaitValue(true) { executed }) } + @Test + fun `launch works in a long-running unconfined EDT coroutine`(): Unit = edtTest { + var executed = false + withContext(Dispatchers.Unconfined) { + container.launchOnShow("test") { + executed = true + } + var eventuallyExecuted = false + // not using awaitValue because it's important to not let go of this unconfined thing, + // and therefore we must not suspend the coroutine + repeat(10) { + PlatformTestUtil.dispatchAllEventsInIdeEventQueue() + eventuallyExecuted = executed + } + assertTrue(eventuallyExecuted) + } + } + @Test fun `launch once without adding it to hierarchy is GCed with component`(): Unit = edtTest { var component: Component? = JLabel()