|
| 1 | +diff --git a/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/network/NetworkIdlingResource.kt b/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/network/NetworkIdlingResource.kt |
| 2 | +index be01a0dbeeaebbada21810269e4e30d114bf4476..88af8da4545e4458d340c3b0b4e37f134efc33f7 100644 |
| 3 | +--- a/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/network/NetworkIdlingResource.kt |
| 4 | ++++ b/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/network/NetworkIdlingResource.kt |
| 5 | +@@ -50,23 +50,6 @@ class NetworkIdlingResource(private val dispatcher: Dispatcher) : DetoxIdlingRes |
| 6 | + |
| 7 | + @Synchronized |
| 8 | + override fun checkIdle(): Boolean { |
| 9 | +- busyResources.clear() |
| 10 | +- |
| 11 | +- val calls = dispatcher.runningCalls() |
| 12 | +- for (call in calls) { |
| 13 | +- val url = call.request().url.toString() |
| 14 | +- |
| 15 | +- if (!isUrlBlacklisted(url)) { |
| 16 | +- busyResources.add(url) |
| 17 | +- } |
| 18 | +- } |
| 19 | +- |
| 20 | +- if (busyResources.isNotEmpty()) { |
| 21 | +- Log.i(LOG_TAG, "Network is busy, with " + busyResources.size + " in-flight calls") |
| 22 | +- Choreographer.getInstance().postFrameCallback(this) |
| 23 | +- return false |
| 24 | +- } |
| 25 | +- |
| 26 | + notifyIdle() |
| 27 | + return true |
| 28 | + } |
| 29 | +diff --git a/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt b/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt |
| 30 | +index 462908c3427599bb06bf04ca2d4662d320519ff4..a367e18b34750a4f6d163be343fa3835a8b348ed 100644 |
| 31 | +--- a/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt |
| 32 | ++++ b/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt |
| 33 | +@@ -32,15 +32,8 @@ class TimersIdlingResource @JvmOverloads constructor( |
| 34 | + |
| 35 | + @SuppressLint("VisibleForTests") |
| 36 | + override fun checkIdle(): Boolean { |
| 37 | +- val isIdle = !timingModule.hasActiveTimersInRange(BUSY_WINDOW_THRESHOLD) |
| 38 | +- |
| 39 | +- if (isIdle) { |
| 40 | +- notifyIdle() |
| 41 | +- } else { |
| 42 | +- getChoreographer().postFrameCallback(this) |
| 43 | +- } |
| 44 | +- |
| 45 | +- return isIdle |
| 46 | ++ notifyIdle() |
| 47 | ++ return true |
| 48 | + } |
| 49 | + |
| 50 | + override fun doFrame(frameTimeNanos: Long) { |
| 51 | +diff --git a/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/fabric/FabricUIManagerIdlingResources.kt b/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/fabric/FabricUIManagerIdlingResources.kt |
| 52 | +index d6db5d5d7a4173eae88d97bf06eaeaf8b38c3b94..a85ebdf5a30607459be68463b3238b6ff1caf97a 100644 |
| 53 | +--- a/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/fabric/FabricUIManagerIdlingResources.kt |
| 54 | ++++ b/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/fabric/FabricUIManagerIdlingResources.kt |
| 55 | +@@ -20,47 +20,8 @@ class FabricUIManagerIdlingResources( |
| 56 | + private var isSteadyState: Boolean = false |
| 57 | + |
| 58 | + override fun checkIdle(): Boolean { |
| 59 | +- val mountItemsCount = getMountItemsSize() |
| 60 | +- val viewCommandMountItemsCount = getViewCommandMountItemsSize() |
| 61 | +- |
| 62 | +- if (mountItemsCount == 0 && viewCommandMountItemsCount == 0) { |
| 63 | +- firstBusyTimestamp = 0 |
| 64 | +- isSteadyState = false |
| 65 | +- notifyIdle() |
| 66 | +- return true |
| 67 | +- } |
| 68 | +- |
| 69 | +- // Once we've determined this is a steady-state (a stuck mount item that never |
| 70 | +- // resolves), keep reporting idle as long as the count stays low. |
| 71 | +- if (isSteadyState && mountItemsCount <= 1 && viewCommandMountItemsCount == 0) { |
| 72 | +- notifyIdle() |
| 73 | +- return true |
| 74 | +- } |
| 75 | +- |
| 76 | +- // Count increased beyond steady-state threshold — reset and treat as genuinely busy. |
| 77 | +- if (isSteadyState) { |
| 78 | +- isSteadyState = false |
| 79 | +- firstBusyTimestamp = 0 |
| 80 | +- } |
| 81 | +- |
| 82 | +- val now = SystemClock.uptimeMillis() |
| 83 | +- if (firstBusyTimestamp == 0L) { |
| 84 | +- firstBusyTimestamp = now |
| 85 | +- } |
| 86 | +- |
| 87 | +- // On API 36+, edge-to-edge enforcement can cause a single mount item to remain |
| 88 | +- // permanently in the queue on older RN versions. If the count stays at 1 for over |
| 89 | +- // 1.5s, treat it as a steady-state condition rather than a genuinely busy UI. |
| 90 | +- if (now - firstBusyTimestamp >= BUSY_TOLERANCE_MS |
| 91 | +- && mountItemsCount <= 1 |
| 92 | +- && viewCommandMountItemsCount == 0) { |
| 93 | +- isSteadyState = true |
| 94 | +- notifyIdle() |
| 95 | +- return true |
| 96 | +- } |
| 97 | +- |
| 98 | +- Choreographer.getInstance().postFrameCallback(this) |
| 99 | +- return false |
| 100 | ++ notifyIdle() |
| 101 | ++ return true |
| 102 | + } |
| 103 | + |
| 104 | + override fun registerIdleTransitionCallback(callback: IdlingResource.ResourceCallback?) { |
0 commit comments