mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[cancellation] IJPL-236372: Add tests
(cherry picked from commit e1df8f4ccf18b61ef3fc2f42e6c9a82d30b15f2b) IJ-CR-193221 GitOrigin-RevId: 1247bf9e4569bf49f84ae9edb83eec91541a5416
This commit is contained in:
committed by
intellij-monorepo-bot
parent
09df581bea
commit
87cde1274c
+35
@@ -4,6 +4,7 @@ package com.intellij.openapi.application.impl
|
||||
import com.intellij.concurrency.JobLauncher
|
||||
import com.intellij.concurrency.currentThreadContext
|
||||
import com.intellij.concurrency.installThreadContext
|
||||
import com.intellij.ide.util.DelegatingProgressIndicator
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.actionSystem.ActionManager
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
@@ -32,11 +33,15 @@ import com.intellij.openapi.progress.ProcessCanceledException
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.progress.ProgressManager
|
||||
import com.intellij.openapi.progress.Task
|
||||
import com.intellij.openapi.progress.coroutineToIndicator
|
||||
import com.intellij.openapi.progress.util.ProgressIndicatorUtils
|
||||
import com.intellij.openapi.project.DumbAware
|
||||
import com.intellij.openapi.ui.DialogWrapper
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.platform.ide.progress.withBackgroundProgress
|
||||
import com.intellij.platform.locking.impl.getGlobalThreadingSupport
|
||||
import com.intellij.platform.util.progress.reportProgress
|
||||
import com.intellij.platform.util.progress.reportRawProgress
|
||||
import com.intellij.testFramework.LoggedErrorProcessor
|
||||
import com.intellij.testFramework.common.timeoutRunBlocking
|
||||
import com.intellij.testFramework.junit5.TestApplication
|
||||
@@ -566,4 +571,34 @@ class PlatformUtilitiesTest {
|
||||
j2.complete()
|
||||
job.join()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `runProcess cannot resurrect canceled indicator`(): Unit = timeoutRunBlocking {
|
||||
launch {
|
||||
coroutineToIndicator {
|
||||
val indicator = DelegatingProgressIndicator(ProgressManager.getGlobalProgressIndicator())
|
||||
currentThreadContext().job.cancel()
|
||||
indicator.stop()
|
||||
ProgressManager.getInstance().runProcess({
|
||||
Assertions.assertTrue(indicator.isCanceled, "indicator should be canceled")
|
||||
}, indicator)
|
||||
}
|
||||
}.join()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `runProcess cannot resurrect raw progress reporting indicator`(): Unit = timeoutRunBlocking {
|
||||
launch {
|
||||
reportProgress {
|
||||
coroutineToIndicator {
|
||||
val indicator = DelegatingProgressIndicator(ProgressManager.getGlobalProgressIndicator())
|
||||
currentThreadContext().job.cancel()
|
||||
indicator.stop()
|
||||
ProgressManager.getInstance().runProcess({
|
||||
Assertions.assertTrue(indicator.isCanceled, "indicator should be canceled")
|
||||
}, indicator)
|
||||
}
|
||||
}
|
||||
}.join()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user