Added properties to extend tap area

This commit is contained in:
choefele
2014-04-14 20:59:12 +02:00
parent 349c84f060
commit edc9be625d
3 changed files with 58 additions and 0 deletions

View File

@@ -90,6 +90,53 @@
XCTAssertEqual(blockCalled, 1u);
}
- (void)testEnumerateLinkRangesNotContainingPoint
{
NSRange linkRange = NSMakeRange(0, 10);
NSMutableAttributedString *attributedText = [self.linkTextView.attributedText mutableCopy];
[attributedText addAttribute:CCHLinkAttributeName value:@"http://google.de" range:linkRange];
self.linkTextView.attributedText = attributedText;
__block NSUInteger blockCalled = 0;
[self.linkTextView enumerateLinkRangesContainingLocation:CGPointMake(100, 20) usingBlock:^(NSRange range) {
blockCalled++;
XCTAssertTrue(NSEqualRanges(range, linkRange));
}];
XCTAssertEqual(blockCalled, 0u);
}
- (void)testEnumerateLinkRangesContainingPointExtendedTapAreaX
{
NSRange linkRange = NSMakeRange(0, 10);
NSMutableAttributedString *attributedText = [self.linkTextView.attributedText mutableCopy];
[attributedText addAttribute:CCHLinkAttributeName value:@"http://google.de" range:linkRange];
self.linkTextView.attributedText = attributedText;
self.linkTextView.extendedTapAreaX = 50;
__block NSUInteger blockCalled = 0;
[self.linkTextView enumerateLinkRangesContainingLocation:CGPointMake(100, 20) usingBlock:^(NSRange range) {
blockCalled++;
XCTAssertTrue(NSEqualRanges(range, linkRange));
}];
XCTAssertEqual(blockCalled, 1u);
}
- (void)testEnumerateLinkRangesContainingPointExtendedTapAreaY
{
NSRange linkRange = NSMakeRange(0, 10);
NSMutableAttributedString *attributedText = [self.linkTextView.attributedText mutableCopy];
[attributedText addAttribute:CCHLinkAttributeName value:@"http://google.de" range:linkRange];
self.linkTextView.attributedText = attributedText;
self.linkTextView.extendedTapAreaY = 80;
__block NSUInteger blockCalled = 0;
[self.linkTextView enumerateLinkRangesContainingLocation:CGPointMake(50, 100) usingBlock:^(NSRange range) {
blockCalled++;
XCTAssertTrue(NSEqualRanges(range, linkRange));
}];
XCTAssertEqual(blockCalled, 1u);
}
- (void)testEnumerateLinkRangesContainingPointTwice
{
NSRange linkRange = NSMakeRange(0, 20);