IDEA-354670: IndexingTestUtil.waitNow should wait for indexing even if it was submitted during EDT events pumping

GitOrigin-RevId: 96d306e82d1b6a79c5c6207daca427bfee0f6792
This commit is contained in:
Andrei.Kuznetsov
2024-07-18 17:45:18 +02:00
committed by intellij-monorepo-bot
parent fb737d1fd4
commit 0fb89ef48e

View File

@@ -64,8 +64,10 @@ class IndexingTestUtil(private val project: Project) {
val scope = GlobalScope.childScope("Indexing waiter", Dispatchers.IO)
val waiting = scope.launch { suspendUntilIndexesAreReady() }
try {
PlatformTestUtil.waitWithEventsDispatching("Indexing timeout", { !waiting.isActive }, 600)
PlatformTestUtil.dispatchAllEventsInIdeEventQueue() // make sure that all the scheduled write actions are executed
do {
PlatformTestUtil.waitWithEventsDispatching("Indexing timeout", { !waiting.isActive }, 600)
}
while (dispatchAllEventsInIdeEventQueue()) // make sure that all the scheduled write actions are executed
}
finally {
waiting.cancel()
@@ -78,6 +80,14 @@ class IndexingTestUtil(private val project: Project) {
}
}
private fun dispatchAllEventsInIdeEventQueue(): Boolean {
var hasDispatchedEvents = false
while (PlatformTestUtil.dispatchNextEventIfAny() != null) {
hasDispatchedEvents = true
}
return hasDispatchedEvents
}
private fun shouldWait(): Boolean {
val dumbService = DumbServiceImpl.getInstance(project)