From d53372d2e434ffed950ea9d154b38868d4f19235 Mon Sep 17 00:00:00 2001 From: steven Date: Fri, 21 Sep 2018 11:12:51 +0200 Subject: [PATCH] Adds untracking for state kGREYPendingViewsToDisappear if a UIViewController'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 , , and . This is the series of events: * .viewWillAppear * .viewDidAppear * .view is shown to the user * User performs swipe left * .viewWillAppear * .viewWillDisappear * .viewDidAppear * .viewDidDisappear * .view is shown to the user * User performs swipe left (This swipe does not go far enough to show .view at the end of the swipe) * .viewWillAppear * .viewWillDisappear * .viewWillAppear * .viewDidAppear * .viewWillDisappear * .viewDidDisappear * .view is shown to the user again Without this patch, EarlGrey waits for viewDidDisappear: call on and app state does not become kGREYIdle. With this patch, at the call of .viewDidAppear state kGREYPendingViewsToDisappear is untracked and app state becomes kGREYIdle. --- EarlGrey/Additions/UIViewController+GREYAdditions.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EarlGrey/Additions/UIViewController+GREYAdditions.m b/EarlGrey/Additions/UIViewController+GREYAdditions.m index 1770ebe4c..7bcc655a7 100644 --- a/EarlGrey/Additions/UIViewController+GREYAdditions.m +++ b/EarlGrey/Additions/UIViewController+GREYAdditions.m @@ -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];