mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-196231 Add Unconfined+launchOnShow test
This covers the recent fix of the issue when a long-running unconfined EDT coroutine would prevent executing the job. The test can be checked by setting ide.ui.coroutine.scopes.unconfined.fix to false, it fails then. GitOrigin-RevId: c448be818a87daf888b438a6ab1a8b71b46ae6ae
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6f568e1cd5
commit
7e61ee8dbd
+19
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user