Execute action without writeActionPriority in tests

This commit is contained in:
Nikolay Krasko
2017-09-19 11:23:11 +03:00
parent c05c359703
commit 1b447a0231
@@ -41,16 +41,20 @@ fun <T : Any> runInReadActionWithWriteActionPriorityWithPCE(f: () -> T): T {
fun <T : Any> runInReadActionWithWriteActionPriority(f: () -> T): T? { fun <T : Any> runInReadActionWithWriteActionPriority(f: () -> T): T? {
var r: T? = null var r: T? = null
val complete = ProgressIndicatorUtils.runInReadActionWithWriteActionPriority { if (!with(ApplicationManager.getApplication()) { isDispatchThread && isUnitTestMode }) {
val complete = ProgressIndicatorUtils.runInReadActionWithWriteActionPriority {
r = f()
}
if (!complete) return null
}
else {
r = f() r = f()
} }
if (!complete) return null
return r return r
} }
fun <T : Any> Project.runSynchronouslyWithProgress(progressTitle: String, canBeCanceled: Boolean, action: () -> T): T? { fun <T : Any> Project.runSynchronouslyWithProgress(progressTitle: String, canBeCanceled: Boolean, action: () -> T): T? {
var result: T? = null var result: T? = null
ProgressManager.getInstance().runProcessWithProgressSynchronously({ result = action() }, progressTitle, canBeCanceled, this) ProgressManager.getInstance().runProcessWithProgressSynchronously({ result = action() }, progressTitle, canBeCanceled, this)