Skip to content

Commit ef50023

Browse files
committed
Clear compose container references in tearDown
1 parent 0d529f7 commit ef50023

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

compose/ui/ui/src/uikitInstrumentedTest/kotlin/androidx/compose/ui/test/UIKitInstrumentedTest.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ internal class UIKitInstrumentedTest(
351351
}
352352

353353
fun tearDown() {
354+
clearComposeContainerReferencesIfDetached()
355+
354356
// Stop text editing and hide keyboard if any
355357
viewController.view.endEditing(force = true)
356358
waitForIdle()
@@ -364,6 +366,15 @@ internal class UIKitInstrumentedTest(
364366
hostingViewController?.viewControllerDidLeaveWindowHierarchy()
365367
}
366368

369+
private fun clearComposeContainerReferencesIfDetached() {
370+
if (hostingView != null && hostingView?.window == null) {
371+
hostingView = null
372+
}
373+
if (hostingViewController != null && hostingViewController?.view?.window == null) {
374+
hostingViewController = null
375+
}
376+
}
377+
367378
private val isIdle: Boolean
368379
get() {
369380
val hadSnapshotChanges = Snapshot.current.hasPendingChanges()

0 commit comments

Comments
 (0)