Hi,
I was wondering how we can test opening a custom url within an XCTestCase while performing UI testing. I am trying:
// this custom url is registered within the application
let customURL = NSURL(string: "foo://localhost/doSomething"
let sharedApp = UIApplication.sharedApplication()
let fileURL = // an NSURL file path
UIPasteboard.generalPasteboard().setValue(fileURL, forPasteboardType: "com.foo")
XCTAssert(sharedApp.canOpenURL(customURL!), "cannot open url") // this passes
let status = sharedApp.openURL(customURL!)
XCTAssert(status, "did not open url") // this does NOT passcanOpenURL passes, but openURL does not succeed. Furthermore, the openURL delegate method in my application is never called.
In the above snippet, I am also pasting a URL to the paste board because I am trying to open this test data file which was why I decided to try this with a custom URL.
Any one have any ideas? Am I not approaching this correctly? I was trying to use an .xcappdata file but since that file loads in the testing unit instead of the application being tested, I'm not sure how to place it within the data directory of the real app.
Thanks,
Jaime