File tree Expand file tree Collapse file tree 2 files changed +13
-10
lines changed
compose/ui/ui/src/webTest/kotlin/androidx/compose/ui Expand file tree Collapse file tree 2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import kotlin.test.AfterTest
2828import kotlin.test.BeforeTest
2929import kotlin.test.assertEquals
3030import kotlin.test.assertTrue
31+ import kotlin.time.measureTime
3132import kotlinx.browser.document
3233import kotlinx.browser.window
3334import kotlinx.coroutines.CoroutineScope
@@ -174,19 +175,19 @@ internal class WebApplicationScope(
174175) : CoroutineScope by CoroutineScope(scope.coroutineContext + Job ()) {
175176 private val initialRecomposers = Recomposer .runningRecomposers.value
176177
177- suspend fun awaitIdle () {
178+ suspend fun awaitIdle (): Unit = measureTime {
178179 awaitWithYield()
179180
180181 Snapshot .sendApplyNotifications()
181182
182- for (recomposerInfo in Recomposer .runningRecomposers.value - initialRecomposers) {
183+ val recomposers = Recomposer .runningRecomposers.value - initialRecomposers
184+ println (" Recomposers count: ${recomposers.size} \n " )
185+ for (recomposerInfo in recomposers) {
183186 recomposerInfo.state.takeWhile { it > Recomposer .State .Idle }.collect()
184187 }
185188
186189 awaitWithYield()
187-
188- awaitAnimationFrame()
189- }
190+ }.let { println (" Total awaitIdle time: $it \n " ) }
190191
191192 /* *
192193 * awaitAnimationFrame is needed for text input tests,
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ import kotlin.test.assertNotEquals
4141import kotlin.test.assertNotNull
4242import kotlin.test.assertNull
4343import kotlin.test.assertTrue
44+ import kotlin.time.measureTime
4445import kotlinx.browser.document
4546import kotlinx.coroutines.CoroutineScope
4647import kotlinx.coroutines.Dispatchers
@@ -230,19 +231,20 @@ class CfWA11YTest : OnCanvasTests {
230231 }
231232 }
232233 }
234+ suspend fun realDelay (timeMs : Long ) {
235+ withContext(Dispatchers .Default ) {
236+ delay(timeMs)
237+ }
238+ }
233239
234240 awaitIdle()
241+
235242 val a11yContainer = getA11YContainer()!!
236243
237244 println (" making first assets at ${currentTimeMillis()} \n " )
238245 assertEquals(" " ,a11yContainer.innerHTML, " No A11Y tree expected yet. Too early. Time = ${currentTimeMillis()} " )
239246 assertEquals(0 ,a11yContainer.childElementCount, " No A11Y tree expected yet. Too early." )
240247
241- suspend fun realDelay (timeMs : Long ) {
242- withContext(Dispatchers .Default ) {
243- delay(timeMs)
244- }
245- }
246248
247249 repeat(20 ) {
248250 show1 = ! show1
You can’t perform that action at this time.
0 commit comments