mirror of
https://github.com/HackPlan/AsyncDisplayKit.git
synced 2026-04-23 11:27:56 +08:00
Check if subnodes where modified during layoutSpecThatFits: (#2164)
This commit is contained in:
committed by
Adlai Holler
parent
578ac4c48d
commit
ba5dc984d7
@@ -34,4 +34,35 @@
|
||||
ASXCTAssertEqualSizes(displayNode.calculatedSize, CGSizeMake(100, 100), @"Automatic measurement pass should be happened in layout");
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
- (void)testNotAllowAddingSubnodesInLayoutSpecThatFits
|
||||
{
|
||||
ASDisplayNode *displayNode = [ASDisplayNode new];
|
||||
ASDisplayNode *someOtherNode = [ASDisplayNode new];
|
||||
|
||||
displayNode.layoutSpecBlock = ^(ASDisplayNode * _Nonnull node, ASSizeRange constrainedSize) {
|
||||
[node addSubnode:someOtherNode];
|
||||
return [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsZero child:someOtherNode];
|
||||
};
|
||||
|
||||
XCTAssertThrows([displayNode measure:CGSizeMake(100, 100)], @"Should throw if subnode was added in layoutSpecThatFits:");
|
||||
}
|
||||
|
||||
- (void)testNotAllowModifyingSubnodesInLayoutSpecThatFits
|
||||
{
|
||||
ASDisplayNode *displayNode = [ASDisplayNode new];
|
||||
ASDisplayNode *someOtherNode = [ASDisplayNode new];
|
||||
|
||||
[displayNode addSubnode:someOtherNode];
|
||||
|
||||
displayNode.layoutSpecBlock = ^(ASDisplayNode * _Nonnull node, ASSizeRange constrainedSize) {
|
||||
[someOtherNode removeFromSupernode];
|
||||
[node addSubnode:[ASDisplayNode new]];
|
||||
return [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsZero child:someOtherNode];
|
||||
};
|
||||
|
||||
XCTAssertThrows([displayNode measure:CGSizeMake(100, 100)], @"Should throw if subnodes where modified in layoutSpecThatFits:");
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user