From 9efbf9499da1f56dc8a035b64e97ca1585ae86d6 Mon Sep 17 00:00:00 2001 From: Eugene Petrenko Date: Tue, 26 May 2020 21:24:24 +0200 Subject: [PATCH] ProgressManager - more tests for contracts IDEA-241785 GitOrigin-RevId: 2cf2fa4d9f28987133847571ae92c5fdb453a1d9 --- .../impl/ProgressManagerContractsTest.kt | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/progress/impl/ProgressManagerContractsTest.kt b/platform/platform-tests/testSrc/com/intellij/openapi/progress/impl/ProgressManagerContractsTest.kt index 5924abb8e3d1..e42e526d2b0c 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/progress/impl/ProgressManagerContractsTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/openapi/progress/impl/ProgressManagerContractsTest.kt @@ -3,6 +3,7 @@ package com.intellij.openapi.progress.impl import com.intellij.idea.TestFor import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.diagnostic.DefaultLogger import com.intellij.openapi.progress.ProgressIndicator import com.intellij.openapi.progress.Task import com.intellij.testFramework.LightPlatformTestCase @@ -13,6 +14,42 @@ import org.junit.Ignore import java.util.concurrent.atomic.AtomicInteger class ProgressManagerContractsTest : LightPlatformTestCase() { + @TestFor(issues = ["IDEA-241785"]) + fun `test leaked exception from backgroundable task`() { + DefaultLogger.disableStderrDumping(testRootDisposable) + val message = "this is test exception message to ignore" + try { + object : Task.Backgroundable(project, "foo", true) { + override fun run(indicator: ProgressIndicator) { + throw RuntimeException(message) + } + }.queue() + error("exception was expected") + } + catch (e: Throwable) { + assertThat(e.message).contains(message) + } + } + + @TestFor(issues = ["IDEA-241785"]) + fun `test leaked invokeLater exception from backgroundable task`() { + DefaultLogger.disableStderrDumping(testRootDisposable) + val message = "this is test exception message to ignore" + try { + object : Task.Backgroundable(project, "foo", true) { + override fun run(indicator: ProgressIndicator) { + ApplicationManager.getApplication().invokeAndWait { + throw RuntimeException(message) + } + } + }.queue() + error("exception was expected") + } + catch (e: Throwable) { + assertThat(e.message).contains(message) + } + } + @TestFor(issues = ["IDEA-241785"]) fun `test backgroundable modality in GUI`() = runWithGuiTasksMode { `test backgroundable modality in tests`() }