Update ASTextNode tests for iOS 8 (fixes #10).

This commit is contained in:
Nadine Salter
2014-08-06 17:21:46 -07:00
parent 07a538a2dc
commit aafd0f3514
2 changed files with 19 additions and 9 deletions

View File

@@ -20,18 +20,18 @@
- (void)testAttributeCleansing
{
NSMutableAttributedString *testString = [[NSMutableAttributedString alloc] initWithString:@"Test" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12.0]}];
UIFont *font = [UIFont systemFontOfSize:12.0];
NSMutableAttributedString *testString = [[NSMutableAttributedString alloc] initWithString:@"Test" attributes:@{NSFontAttributeName:font}];
CFRange cfRange = CFRangeMake(0, testString.length);
CGColorRef blueColor = CGColorRetain([UIColor blueColor].CGColor);
CFAttributedStringSetAttribute((CFMutableAttributedStringRef)testString,
cfRange,
kCTForegroundColorAttributeName,
blueColor);
NSAttributedString *expectedCleansedString = [[NSAttributedString alloc] initWithString:@"Test" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12.0],
NSForegroundColorAttributeName:[UIColor colorWithCGColor:blueColor]}];
UIColor *color = [UIColor colorWithCGColor:blueColor];
NSAttributedString *actualCleansedString = ASCleanseAttributedStringOfCoreTextAttributes(testString);
XCTAssertTrue([expectedCleansedString isEqualToAttributedString:actualCleansedString], @"Expected the %@ core text attribute to be cleansed from the string %@", kCTForegroundColorFromContextAttributeName, actualCleansedString);
XCTAssertTrue([[actualCleansedString attribute:NSForegroundColorAttributeName atIndex:0 effectiveRange:NULL] isEqual:color], @"Expected the %@ core text attribute to be cleansed from the string %@\n Should match %@", kCTForegroundColorFromContextAttributeName, actualCleansedString, color);
CGColorRelease(blueColor);
}