File tree Expand file tree Collapse file tree
compose/ui/ui/src/uikitInstrumentedTest/kotlin/androidx/compose/ui/test Expand file tree Collapse file tree Original file line number Diff line number Diff 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()
You can’t perform that action at this time.
0 commit comments