Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds untracking for state kGREYPendingViewsToDisappear in greyswizzled_viewDidAppear #750

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Adds untracking for state kGREYPendingViewsToDisappear if a UIViewCon…
…troller's viewDidAppear has been called.

This is neccessary if the user triggers a transition between UIViewControllers e.g. in the context of a
UIPageViewController. See this example for an explanation:

We show a UIPageViewController with three UIViewControllers <VC1>, <VC2>, and <VC3>.
This is the series of events:

* <VC1>.viewWillAppear
* <VC1>.viewDidAppear
* <VC1>.view is shown to the user
* User performs swipe left
* <VC2>.viewWillAppear
* <VC1>.viewWillDisappear
* <VC2>.viewDidAppear
* <VC1>.viewDidDisappear
* <VC2>.view is shown to the user
* User performs swipe left (This swipe does not go far enough to show <VC3>.view at the end of the swipe)
* <VC3>.viewWillAppear
* <VC2>.viewWillDisappear
* <VC2>.viewWillAppear
* <VC2>.viewDidAppear
* <VC3>.viewWillDisappear
* <VC3>.viewDidDisappear
* <VC2>.view is shown to the user again

Without this patch, EarlGrey waits for viewDidDisappear: call on <VC2> and app state does not become kGREYIdle.
With this patch, at the call of <VC2>.viewDidAppear state kGREYPendingViewsToDisappear is untracked and app state becomes kGREYIdle.
  • Loading branch information
stevenreinisch committed Sep 21, 2018
commit d53372d2e434ffed950ea9d154b38868d4f19235
2 changes: 1 addition & 1 deletion EarlGrey/Additions/UIViewController+GREYAdditions.m
Original file line number Diff line number Diff line change
@@ -166,7 +166,7 @@ - (void)greyswizzled_viewWillAppear:(BOOL)animated {
- (void)greyswizzled_viewDidAppear:(BOOL)animated {
GREYAppStateTrackerObject *object =
objc_getAssociatedObject(self, @selector(greyswizzled_viewWillAppear:));
GREYAppState state = kGREYPendingViewsToAppear | kGREYPendingRootViewControllerToAppear;
GREYAppState state = kGREYPendingViewsToAppear | kGREYPendingRootViewControllerToAppear | kGREYPendingViewsToDisappear;
UNTRACK_STATE_FOR_OBJECT(state, object);

[self grey_setAppeared:YES];