如何加快我的动画速度,使我的EarlGrey测试套件运行得更快



我在GREYConfiguration中看到了下面的API,它说EarlGrey默认情况下会截断CALayer动画超过10秒-

/**
 *  Configuration for setting max allowable animation duration (in seconds) for any CALayer based
 *  animation. Animations exceeding the specified time will have their duration truncated to value
 *  specified by this config.
 *
 *  Accepted values: @c double (negative values shouldn't be used)
 *  Default value: 10.0
 */
GREY_EXTERN NSString *const kGREYConfigKeyCALayerMaxAnimationDuration;

我正在开发一个小型游戏应用程序,其中有许多这样的动画。我注意到,当我启用动画时,我的测试需要很长时间才能运行,这是我的UI测试所必需的。我知道我可以使用UIApplication.sharedApplication.keyWindow.layer.speed更改整个应用程序的动画速度。有什么方法可以让我只为我的EarlGrey测试更改它吗?

UIApplication.sharedApplication.keyWindow.layer.speed放在条件语句后面:

#if EARLGREY_ENV
UIApplication.sharedApplication.keyWindow.layer.speed = 100
#endif

只有当应用程序通过Earl Grey运行时,才会执行这行代码。

有关处理伯爵灰动画的更多信息,请参阅我应该如何处理动画在他们的常见问题解答下。

最新更新