in azure-communication-ui/demo-app/src/calling-test/java/com/azure/android/communication/ui/callingcompositedemoapp/util/ViewIsDisplayedResource.kt [20:38]
fun waitUntilViewIsDisplayed(idlingCheck: ViewMatcherFunctionPtr): ViewInteraction {
var isReady = false
var timeOut = 0L
lateinit var viewInteraction: ViewInteraction
while (!isReady && timeOut < TIMED_OUT_VALUE) {
try {
viewInteraction = idlingCheck()
isReady = true
} catch (ex: Throwable) {
if (ex is AssertionFailedError || ex is NoMatchingViewException) {
SystemClock.sleep(DEFAULT_WAIT_TIME)
timeOut += DEFAULT_WAIT_TIME
} else throw ex
}
}
if (isReady) return viewInteraction
throw IllegalStateException("Timed out waiting for view")
}