iosobjective-cxcodexcode-ui-testingearlgrey

EarlGrey Freezes Animation And Doesn't Call Callback


There is a method with an asynchronous block as a parameter.

The first time the app runs, this method is called, and there is an animation that covers the entire screen. The method is making a network call that can take a pretty long time, around 7 seconds or so. When the block runs, the callback ends the animation and the app is ready to be interacted with again.

When I run the app in the simulator and tap around, everything runs as it should. When I run the EarlGrey test target, the animation freezes, and the test ultimately fails, because there is an element that can't be found. Behind the animation view (a subclass of UIView), some steps are still successfully carried out, even though the elements are not visible.

Lastly, this only happens on the first run of the app, since the network call in subsequent test runs is much shorter.

I've tried changing configurations to disable animations, and nothing seems to work for me. I can't really paste code, since the app is proprietary.

I'm happy to answer any and all clarifying questions, and very much looking forward to some help!


Solution

  • Disclaimer: This was all @khandpur. I joined the Google Open Source Slack channel, and he helped me debug hard.

    The issue was the use of Facebook's Shimmer. I had this line in the setUp method:

    [UIApplication sharedApplication].keyWindow.layer.speed = 100;

    This was speeding up animations, but causing some conflict with shimmer, not too sure why. I'm going to comment in their repo.

    I deleted that line, and while tests are a little slower, they're totally stable now.