In my user interface tests, I use the method addUIInterruptionMonitorWithDescriptionas indicated in different places ( 1 , 2 , 3 ), as shown below:
var systemAlertMonitorToken: NSObjectProtocol?
override func setUp() {
super.setUp()
SDStatusBarManager.sharedInstance().enableOverrides()
continueAfterFailure = false
let app = XCUIApplication()
setupSnapshot(app)
app.launchEnvironment["UITests"] = "true"
if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
XCUIDevice.sharedDevice().orientation = .LandscapeLeft
} else {
XCUIDevice.sharedDevice().orientation = .Portrait
}
app.launch()
systemAlertMonitorToken = addUIInterruptionMonitorWithDescription("Photos Permission Alert") { (alert) -> Bool in
if alert.buttons.matchingIdentifier("OK").count > 0 {
alert.buttons["OK"].tap()
app.tap()
return true
} else {
return false
}
}
}
override func tearDown() {
if let systemAlertMonitorToken = systemAlertMonitorToken {
removeUIInterruptionMonitor(systemAlertMonitorToken)
}
super.tearDown()
}
func testSomethingWithPhotos() {
let app = XCUIApplication()
app.tabBars.buttons["Scan"].tap()
}
It’s expected that these features (“App Name” will want to access your photos “on the iPhone, and when launched on the iPad, a warning is displayed, but it is not canceled, and if I put a breakpoint in the callback it never starts. Is there a way to use this feature on the iPad?
:
- app.tap() testSomethingWithPhotos app.tabBars.buttons["Scan"].tap(), .
- addUIInterruptionMonitorWithDescription super.setup().
- addUIInterruptionMonitorWithDescription testSomethingWithPhotos, ,