Unregistering idling resource causes the Espresso to think we have busy idling resources
Closed this issue · 5 comments
GoogleCodeExporter commented
What steps will reproduce the problem?
1. Have some sort of tests that uses custom idling resources and register them
near the beginning of the test
2. Sometimes afterwards, unregister the idling resource
3. After the idling resource is unregistered, have its ResourceCallback call
onTranstitionToIdle(). (This usually happens naturally, but we explicitly call
it here so we can reproduce the bug)
4. Do something with Espresso (ex: closeSoftKeyboard())
What is the expected output? What do you see instead?
I expect Espresso to keep going without being blocked. What actually happens is
that Espresso thinks that we have busy idling resource and idles with the
message "These resources are not idle: [] " and eventually throw an exception
due to timeout. If we manually remove the ResourceCallback from the idling
resources (and thus prevent onTransitionToIdle() from being called) after
unregistering, then we won't run into this problem.
What version of the product are you using? On what operating system?
Espresso 2.0, ran it on Nexus 7 with Kitkat
Please provide any additional information below.
My theory is that Espresso keeps track of the total number of idling resources
and the number of idling resources that are idle. If those two number matches,
then Espresso keeps going. Otherwise, it blocks. When we call
unregisterIdlingResource, the total count goes to 0. When we call
onTranstitionToIdle() afterwards, the idle count end up being greater than 0.
Thus, those two count doesn't match and Espresso blocks. If this is the case,
then I think Espresso should either remove the ResourceCallback when we
unregister or prevent onTransitionToIdle from doing anything.
Original issue reported on code.google.com by dav...@intrepid.io
on 26 Feb 2015 at 5:33
GoogleCodeExporter commented
Original comment by nkors...@google.com
on 4 Mar 2015 at 6:38
- Changed state: Accepted
GoogleCodeExporter commented
Fixed in the next release.
Original comment by vale...@google.com
on 30 Mar 2015 at 8:57
GoogleCodeExporter commented
Did I understand correctly and the workaround is something like:
myIdlingResource.registerIdleTransitionCallback(null);
Espresso.unregisterIdlingResources(myIdlingResource);
? I'm asking because this doesn't work for me, still running into the issue you
described.
Original comment by stefano....@gmail.com
on 15 Apr 2015 at 2:50
GoogleCodeExporter commented
I think we had the order of those two swapped. We ended not bothering with
unregisterIdlingResources() and just manually reset each idlingResource.
Original comment by dav...@intrepid.io
on 15 Apr 2015 at 6:22
GoogleCodeExporter commented
Fixed in espresso 2.1
Original comment by valera.z...@gmail.com
on 21 Apr 2015 at 10:11
- Changed state: Fixed