Closed EDLuke closed 4 years ago
Hi @EDLuke I'm going to take a look at this PR. Thanks for your contribution! If you are interested in the testing part, you can take a look at how you can simulate the activity lifecycle in your tests using this Robolectric API 😃
I spent some time playing with ActivityScenario
and SingleActivityFactory
and so far haven't landed on concrete way to test this without a major refactor.
The scenario I need to test is:
Dexter.with()...check()
DexterActivity
DexterActivity.finish()
Dexter.with()...check()
DexterActivity.onDestroy()
Ok @EDLuke don't worry about the tests. This scenario is not easy to test at all. I've been taking a look at your PR and is just perfect. Thank you so much for your contribution!! I'm going to merge this PR and release a new Dexter version with the fix.
:pushpin: References
Issue:
Steps to reproduce
Launch two activities consecutively, with each activity asking for any new permission(s) in
onCreate
Bug
Callback for second activity's permission request will not be called sometimes
Issue
After the second activity sets up the
DexterInstance
with new callback,DexterActivity
fired from the first activity permission request callsonDestroy
and wipes the callback.:tophat: What is the goal?
Make state clean up synchronous.
:memo: How is it being implemented?
Manually clean up the state by calling
onActivityDestroyed
when there already is aDexterActivity
that is finishing up. Then, whenDexterActivity
callsonDestroyed
, no cleaning is needed.:robot: How can it be tested?
Since testing this requires mocking activity life cycle events. Suggestions are welcome.