teoincontatto / android-test-kit

Automatically exported from code.google.com/p/android-test-kit
0 stars 0 forks source link

Unregistering idling resource causes the Espresso to think we have busy idling resources #135

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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 9 years ago

Original comment by nkors...@google.com on 4 Mar 2015 at 6:38

GoogleCodeExporter commented 9 years ago
Fixed in the next release.

Original comment by vale...@google.com on 30 Mar 2015 at 8:57

GoogleCodeExporter commented 9 years ago
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 9 years ago
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 9 years ago
Fixed in espresso 2.1

Original comment by valera.z...@gmail.com on 21 Apr 2015 at 10:11