ProgressManager - more tests for contracts IDEA-241785

GitOrigin-RevId: 2cf2fa4d9f28987133847571ae92c5fdb453a1d9
This commit is contained in:
Eugene Petrenko
2020-05-26 22:42:37 +03:00
committed by intellij-monorepo-bot
parent 7ca844e3e2
commit 9efbf9499d
@@ -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`() }