Fixes flaking OverscrollTest

runOnIdle / waitForIdle does not wait for drawing, so we need to wait manually until drawing has happened.

Fixes: b/345296723
Test: OverscrollTest
Change-Id: Ic406e3667d183b4eb6272820f430c5c08928ebbf
diff --git a/compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/OverscrollTest.kt b/compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/OverscrollTest.kt
index c68cb3e..d50153a 100644
--- a/compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/OverscrollTest.kt
+++ b/compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/OverscrollTest.kt
@@ -68,7 +68,6 @@
 import com.google.common.truth.Truth.assertWithMessage
 import kotlin.math.abs
 import kotlinx.coroutines.runBlocking
-import org.junit.Assert.assertEquals
 import org.junit.Before
 import org.junit.Rule
 import org.junit.Test
@@ -1188,7 +1187,8 @@
                         .drawBehind { drawCount++ }
             )
         }
-        rule.runOnIdle { assertEquals(1, drawCount) }
+        // Due to b/302303969 there are no guarantees runOnIdle() will wait for drawing to happen
+        rule.waitUntil { drawCount == 1 }
     }
 
     @OptIn(ExperimentalTestApi::class)