Created
May 6, 2014 17:05
-
-
Save steipete/dd58d4629d8a48f15bda to your computer and use it in GitHub Desktop.
Test cases with Aspects! https://github.com/steipete/Aspects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)testRelativeURLs { | |
PSPDFDocument *document = [[PSPDFTestAssetLoader new] documentWithName:@"Testcase-relative-links.pdf"]; | |
NSArray *annotations = [document annotationsForPage:0 type:PSPDFAnnotationTypeLink]; | |
PSPDFLinkAnnotation *link = annotations[0]; | |
NSString *const referenceString = @"Testcase-relative-links/Simple.txt"; | |
XCTAssertEqualObjects(link.URL.absoluteString, referenceString, @"URL should be correct"); | |
PSPDFViewController *pdfController = [[PSPDFViewController alloc] initWithDocument:document]; | |
__block NSURL *showPreviewURL = nil; | |
[pdfController aspect_hookSelector:@selector(showPreviewForURL:animated:title:options:sender:) withOptions:AspectOptionAutomaticRemoval usingBlock:^(id instance, NSArray *args) { | |
showPreviewURL = args.firstObject; | |
} error:NULL]; | |
[pdfController executePDFAction:link.action inTargetRect:CGRectZero forPage:0 animated:NO actionContainer:link]; | |
NSURL *referenceURL = [document.fileURL.URLByDeletingLastPathComponent URLByAppendingPathComponent:referenceString]; | |
XCTAssertEqualObjects(showPreviewURL, referenceURL, @"URL must be correct"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment