mirror of
https://github.com/HackPlan/AsyncDisplayKit.git
synced 2026-04-23 19:31:21 +08:00
Merge branch 'master' into update-objc
Conflicts: AsyncDisplayKit/Private/ASDisplayNode+FrameworkPrivate.h
This commit is contained in:
@@ -16,8 +16,9 @@
|
||||
|
||||
@implementation ASBasicImageDownloaderTests
|
||||
|
||||
- (void)testAsynchronouslyDownloadTheSameURLTwice {
|
||||
ASBasicImageDownloader *downloader = [ASBasicImageDownloader new];
|
||||
- (void)testAsynchronouslyDownloadTheSameURLTwice
|
||||
{
|
||||
ASBasicImageDownloader *downloader = [ASBasicImageDownloader sharedImageDownloader];
|
||||
|
||||
NSURL *URL = [NSURL URLWithString:@"http://wrongPath/wrongResource.png"];
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ static dispatch_block_t modifyMethodByAddingPrologueBlockAndReturnCleanupBlock(C
|
||||
|
||||
@interface ASDisplayNode (PrivateStuffSoWeDontPullInCPPInternalH)
|
||||
- (BOOL)__visibilityNotificationsDisabled;
|
||||
- (BOOL)__selfOrParentHasVisibilityNotificationsDisabled;
|
||||
- (id)initWithViewClass:(Class)viewClass;
|
||||
- (id)initWithLayerClass:(Class)layerClass;
|
||||
@end
|
||||
@@ -360,6 +361,7 @@ static UIView *viewWithName(NSString *name) {
|
||||
}
|
||||
if (useManualDisable) {
|
||||
XCTAssertTrue([child __visibilityNotificationsDisabled], @"Should not have re-enabled yet");
|
||||
XCTAssertTrue([child __selfOrParentHasVisibilityNotificationsDisabled], @"Should not have re-enabled yet");
|
||||
ASDisplayNodeEnableHierarchyNotifications(child);
|
||||
}
|
||||
|
||||
@@ -377,6 +379,7 @@ static UIView *viewWithName(NSString *name) {
|
||||
}
|
||||
if (useManualDisable) {
|
||||
XCTAssertTrue([child __visibilityNotificationsDisabled], @"Should not have re-enabled yet");
|
||||
XCTAssertTrue([child __selfOrParentHasVisibilityNotificationsDisabled], @"Should not have re-enabled yet");
|
||||
ASDisplayNodeEnableHierarchyNotifications(child);
|
||||
}
|
||||
|
||||
@@ -390,6 +393,7 @@ static UIView *viewWithName(NSString *name) {
|
||||
|
||||
// Make sure that we don't leave these unbalanced
|
||||
XCTAssertFalse([child __visibilityNotificationsDisabled], @"Unbalanced visibility notifications calls");
|
||||
XCTAssertFalse([child __selfOrParentHasVisibilityNotificationsDisabled], @"Should not have re-enabled yet");
|
||||
|
||||
[window release];
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ static CALayer *layerWithName(NSString *name) {
|
||||
}
|
||||
|
||||
static NSString *orderStringFromSublayers(CALayer *l) {
|
||||
return [[l.sublayers valueForKey:@"name"] componentsJoinedByString:@","];
|
||||
return [[[l.sublayers valueForKey:@"asyncdisplaykit_node"] valueForKey:@"name"] componentsJoinedByString:@","];
|
||||
}
|
||||
|
||||
static NSString *orderStringFromSubviews(UIView *v) {
|
||||
return [[v.subviews valueForKey:@"name"] componentsJoinedByString:@","];
|
||||
return [[[v.subviews valueForKey:@"asyncdisplaykit_node"] valueForKey:@"name"] componentsJoinedByString:@","];
|
||||
}
|
||||
|
||||
static NSString *orderStringFromSubnodes(ASDisplayNode *n) {
|
||||
@@ -1343,9 +1343,12 @@ static inline BOOL _CGPointEqualToPointWithEpsilon(CGPoint point1, CGPoint point
|
||||
[parent insertSubnode:c belowSubnode:b];
|
||||
XCTAssertEqualObjects(orderStringFromSublayers(parent.layer), @"a,e,d,c,b", @"Didn't match");
|
||||
|
||||
XCTAssertEqual(3u, parent.subnodes.count, @"Should have the right subnode count");
|
||||
XCTAssertEqual(4u, parent.subnodes.count, @"Should have the right subnode count");
|
||||
XCTAssertEqual(4u, parent.view.subviews.count, @"Should have the right subview count");
|
||||
XCTAssertEqual(5u, parent.layer.sublayers.count, @"Should have the right sublayer count");
|
||||
|
||||
[e removeFromSuperlayer];
|
||||
XCTAssertEqual(4u, parent.layer.sublayers.count, @"Should have the right sublayer count");
|
||||
|
||||
//TODO: assert that things deallocate immediately and don't have latent autoreleases in here
|
||||
[parent release];
|
||||
@@ -1353,6 +1356,7 @@ static inline BOOL _CGPointEqualToPointWithEpsilon(CGPoint point1, CGPoint point
|
||||
[b release];
|
||||
[c release];
|
||||
[d release];
|
||||
[e release];
|
||||
}
|
||||
|
||||
- (void)testAppleBugInsertSubview
|
||||
@@ -1416,11 +1420,11 @@ static inline BOOL _CGPointEqualToPointWithEpsilon(CGPoint point1, CGPoint point
|
||||
[parent.view insertSubview:d aboveSubview:a.view];
|
||||
XCTAssertEqualObjects(orderStringFromSublayers(parent.layer), @"a,d,b", @"Didn't match");
|
||||
|
||||
// (a,e,d,b) => (a,d,>c<,b)
|
||||
// (a,d,b) => (a,d,>c<,b)
|
||||
[parent insertSubnode:c belowSubnode:b];
|
||||
XCTAssertEqualObjects(orderStringFromSublayers(parent.layer), @"a,d,c,b", @"Didn't match");
|
||||
|
||||
XCTAssertEqual(3u, parent.subnodes.count, @"Should have the right subnode count");
|
||||
XCTAssertEqual(4u, parent.subnodes.count, @"Should have the right subnode count");
|
||||
XCTAssertEqual(4u, parent.view.subviews.count, @"Should have the right subview count");
|
||||
XCTAssertEqual(4u, parent.layer.sublayers.count, @"Should have the right sublayer count");
|
||||
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
|
||||
#import "ASTextKitCoreTextAdditions.h"
|
||||
|
||||
BOOL floatsCloseEnough(CGFloat float1, CGFloat float2) {
|
||||
CGFloat epsilon = 0.00001;
|
||||
return (fabs(float1 - float2) < epsilon);
|
||||
}
|
||||
|
||||
@interface ASTextKitCoreTextAdditionsTests : XCTestCase
|
||||
|
||||
@end
|
||||
@@ -44,5 +49,21 @@
|
||||
XCTAssertTrue([testString isEqualToAttributedString:actualCleansedString], @"Expected the output string %@ to be the same as the input %@ if there are no core text attributes", actualCleansedString, testString);
|
||||
}
|
||||
|
||||
- (void)testNSParagraphStyleNoCleansing
|
||||
{
|
||||
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
paragraphStyle.lineSpacing = 10.0;
|
||||
|
||||
//NSUnderlineStyleAttributeName flags the unsupported CT attribute check
|
||||
NSDictionary *attributes = @{NSParagraphStyleAttributeName:paragraphStyle,
|
||||
NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle)};
|
||||
|
||||
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:@"Test" attributes:attributes];
|
||||
NSAttributedString *cleansedString = ASCleanseAttributedStringOfCoreTextAttributes(attributedString);
|
||||
|
||||
NSParagraphStyle *cleansedParagraphStyle = [cleansedString attribute:NSParagraphStyleAttributeName atIndex:0 effectiveRange:NULL];
|
||||
|
||||
XCTAssertTrue(floatsCloseEnough(cleansedParagraphStyle.lineSpacing, paragraphStyle.lineSpacing), @"Expected the output line spacing: %f to be equal to the input line spacing: %f", cleansedParagraphStyle.lineSpacing, paragraphStyle.lineSpacing);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -54,7 +54,7 @@ static BOOL CGSizeEqualToSizeWithIn(CGSize size1, CGSize size2, CGFloat delta)
|
||||
{
|
||||
[super setUp];
|
||||
_textNode = [[ASTextNode alloc] init];
|
||||
|
||||
|
||||
UIFontDescriptor *desc =
|
||||
[UIFontDescriptor fontDescriptorWithName:@"Didot" size:18];
|
||||
NSArray *arr =
|
||||
@@ -69,7 +69,17 @@ static BOOL CGSizeEqualToSizeWithIn(CGSize size1, CGSize size2, CGFloat delta)
|
||||
[[NSMutableAttributedString alloc] initWithString:@"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." attributes:d];
|
||||
NSMutableParagraphStyle *para = [NSMutableParagraphStyle new];
|
||||
para.alignment = NSTextAlignmentCenter;
|
||||
[mas addAttribute:NSParagraphStyleAttributeName value:para range:NSMakeRange(0,mas.length)];
|
||||
para.lineSpacing = 1.0;
|
||||
[mas addAttribute:NSParagraphStyleAttributeName value:para
|
||||
range:NSMakeRange(0, mas.length - 1)];
|
||||
|
||||
// Vary the linespacing on the last line
|
||||
NSMutableParagraphStyle *lastLinePara = [NSMutableParagraphStyle new];
|
||||
lastLinePara.alignment = para.alignment;
|
||||
lastLinePara.lineSpacing = 5.0;
|
||||
[mas addAttribute:NSParagraphStyleAttributeName value:lastLinePara
|
||||
range:NSMakeRange(mas.length - 1, 1)];
|
||||
|
||||
_attributedString = mas;
|
||||
_textNode.attributedString = _attributedString;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user