Commit 83b8a6f
committed
Clarify IdlingResource.ResourceCallback usage.
Adds javadoc to IdlingResource.ResourceCallback.onTransitionToIdle() to warn that it should be called before isIdleNow() returns true to avoid race conditions.
If the order is inverted a race can cause consistency error to be thrown:
```
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Resource MyIdlingResource isIdleNow() is returning true, but a message indicating that the resource has transitioned from busy to idle was never sent.
at androidx.test.espresso.Espresso.onIdle(Espresso.java:356)
at androidx.test.espresso.Espresso.onIdle(Espresso.java:376)
```
If the `IdlingResource` changes its `isIdleNow()` to true on a thread other than the main thread, Espresso may observe that change from the main thread and subsequently complete a consistency check to verify that it did not observe a call to `onTransitionToIdle()` before the other thread has proceeded to call it.
PiperOrigin-RevId: 9088881811 parent 1144878 commit 83b8a6f
1 file changed
Lines changed: 8 additions & 1 deletion
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
64 | 71 | | |
65 | 72 | | |
66 | 73 | | |
0 commit comments