中断后等待 App 空闲
Wait for App to idle after Interruption
我有一个 ViewController 将通过
请求访问 init 上的位置服务
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined)
{
[_locationManager requestWhenInUseAuthorization];
}
这会触发 "Allow app to access your location while you use the app?"-警报。
我用 [self addUIInterruptionMonitorWithDescription:handler:]
对此做出反应。我遇到以下问题:关闭请求对话框后,ui-测试不会继续。警报已解除,但 Xcode 等待应用程序变为空闲状态,但看起来应用程序 处于 空闲状态:
t = 67.35s Wait for app to idle
测试失败,因为应用卡在了这里。如果我进入模拟器,Xcode 日志。
t = 72.27s Synthesize event
并继续测试。
Xcode 尝试等待应用程序有什么原因吗?解决方法似乎是告诉 Xcode UI 已更改或发生了事件。有没有办法触发这个?
显示警报后,您必须与界面进行交互。这是 Xcode 7.2 的一个已知错误。只需点击该应用程序即可正常工作,但这是必需的。
addUIInterruptionMonitorWithDescription("Location Dialog") { (alert) -> Bool in
alert.buttons["Allow"].tap()
return true
}
app.buttons["Find Games Nearby?"].tap()
app.tap() // need to interact with the app for the handler to fire
XCTAssert(app.staticTexts["Authorized"].exists)
有关详细信息,请参阅 my blog post。
我有一个 ViewController 将通过
请求访问 init 上的位置服务if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined)
{
[_locationManager requestWhenInUseAuthorization];
}
这会触发 "Allow app to access your location while you use the app?"-警报。
我用 [self addUIInterruptionMonitorWithDescription:handler:]
对此做出反应。我遇到以下问题:关闭请求对话框后,ui-测试不会继续。警报已解除,但 Xcode 等待应用程序变为空闲状态,但看起来应用程序 处于 空闲状态:
t = 67.35s Wait for app to idle
测试失败,因为应用卡在了这里。如果我进入模拟器,Xcode 日志。
t = 72.27s Synthesize event
并继续测试。
Xcode 尝试等待应用程序有什么原因吗?解决方法似乎是告诉 Xcode UI 已更改或发生了事件。有没有办法触发这个?
显示警报后,您必须与界面进行交互。这是 Xcode 7.2 的一个已知错误。只需点击该应用程序即可正常工作,但这是必需的。
addUIInterruptionMonitorWithDescription("Location Dialog") { (alert) -> Bool in
alert.buttons["Allow"].tap()
return true
}
app.buttons["Find Games Nearby?"].tap()
app.tap() // need to interact with the app for the handler to fire
XCTAssert(app.staticTexts["Authorized"].exists)
有关详细信息,请参阅 my blog post。