[WIP] Fix strong reference cycles for STPRedirectContext, Improve tests #804
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixing test failures found in: #802
Summary
I think the
STPRedirectContext
was failing tests quietly in our previousXcode 8, iOS 10.x
testing but shows up when we enable the other Xcode / iOS versions.The first problem is some of the tests were intended to never call the
unsubscribeFromUrlAndForegroundNotifications
. In particular, because theSTPURLCallbackHandler
held a strong reference, theSTPRedirectContext<STPURLCallbackListener>
ended up staying alive between tests leading to unexpected results.The second problem is the
startRedirectFlowFromViewController
was implicitly holding a strong reference to itself in its completion block. Reproducing this is similar to the first problem, either put a breakpoint indealloc
and make sure it's called after every test, or send a valid url scheme to theSTPURLCallbackHandler
and see if any listener picks up.Finally, we needed to adjust the test cases so that they're compatible with all tested iOS versions
I took a broader stroke in the second commit because I was often getting lost/confused when trying to understand the implementation of
STPRedirectContext
. I think some key method renaming is sufficient to solve that but definitely want to avoid introducing new bugs.The tests are still really tricky to maintain but the implementation itself is good so a refactoring just to simplify tests is probably a bad idea right now.
TODO: Update documentation, add
CHANGELOG
andMIGRATING
entry to warn about holding a strong reference toSTPRedirectContext
which was not needed before