From 87cde1274c9ea2440347ce88db3080249e7fcfd9 Mon Sep 17 00:00:00 2001 From: Konstantin Nisht Date: Tue, 24 Feb 2026 15:55:01 +0100 Subject: [PATCH] [cancellation] IJPL-236372: Add tests (cherry picked from commit e1df8f4ccf18b61ef3fc2f42e6c9a82d30b15f2b) IJ-CR-193221 GitOrigin-RevId: 1247bf9e4569bf49f84ae9edb83eec91541a5416 --- .../application/impl/PlatformUtilitiesTest.kt | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/PlatformUtilitiesTest.kt b/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/PlatformUtilitiesTest.kt index a385ce6e416a..9e04464c61c8 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/PlatformUtilitiesTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/PlatformUtilitiesTest.kt @@ -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() + } } \ No newline at end of file