mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Add a failing unit test for the automatic subnode management range issue (#2826)
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class ASCellNode;
|
||||
@class ASCellNode, ASTextNode;
|
||||
|
||||
typedef NSUInteger ASCellNodeAnimation;
|
||||
|
||||
@@ -205,6 +205,11 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) {
|
||||
*/
|
||||
@property (nonatomic, assign) UIEdgeInsets textInsets;
|
||||
|
||||
/**
|
||||
* The text node used by this cell node.
|
||||
*/
|
||||
@property (nonatomic, strong, readonly) ASTextNode *textNode;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -395,13 +395,6 @@ static NSMutableSet *__cellClassesForVisibilityNotifications = nil; // See +init
|
||||
#pragma mark -
|
||||
#pragma mark ASTextCellNode
|
||||
|
||||
@interface ASTextCellNode ()
|
||||
|
||||
@property (nonatomic, strong) ASTextNode *textNode;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation ASTextCellNode
|
||||
|
||||
static const CGFloat kASTextCellNodeDefaultFontSize = 18.0f;
|
||||
@@ -420,7 +413,7 @@ static const CGFloat kASTextCellNodeDefaultVerticalPadding = 11.0f;
|
||||
_textInsets = textInsets;
|
||||
_textAttributes = [textAttributes copy];
|
||||
_textNode = [[ASTextNode alloc] init];
|
||||
[self addSubnode:_textNode];
|
||||
self.automaticallyManagesSubnodes = YES;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -1024,4 +1024,32 @@
|
||||
XCTAssertEqual([[cn valueForKeyPath:@"rangeController.currentRangeMode"] integerValue], ASLayoutRangeModeMinimum, @"Expected range mode to be minimum before scrolling begins.");
|
||||
}
|
||||
|
||||
/**
|
||||
* This tests an issue where, since subnode insertions aren't applied until the UIKit layout pass,
|
||||
* which we trigger during the display phase, subnodes like network image nodes are not preloading
|
||||
* until this layout pass happens which is too late.
|
||||
*/
|
||||
- (void)DISABLED_testThatAutomaticallyManagedSubnodesGetPreloadCallBeforeDisplay
|
||||
{
|
||||
UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
||||
ASCollectionViewTestController *testController = [[ASCollectionViewTestController alloc] initWithNibName:nil bundle:nil];
|
||||
window.rootViewController = testController;
|
||||
ASCollectionNode *cn = testController.collectionNode;
|
||||
|
||||
__block NSInteger itemCount = 100;
|
||||
testController.asyncDelegate->_itemCounts = {itemCount};
|
||||
[window makeKeyAndVisible];
|
||||
[window layoutIfNeeded];
|
||||
|
||||
[cn waitUntilAllUpdatesAreCommitted];
|
||||
for (NSInteger i = 0; i < itemCount; i++) {
|
||||
ASTextCellNodeWithSetSelectedCounter *node = [cn nodeForItemAtIndexPath:[NSIndexPath indexPathForItem:i inSection:0]];
|
||||
XCTAssert(node.automaticallyManagesSubnodes, @"Expected test cell node to use automatic subnode management. Can modify the test with a different class if needed.");
|
||||
ASDisplayNode *subnode = node.textNode;
|
||||
XCTAssertEqualObjects(NSStringFromASInterfaceState(subnode.interfaceState), NSStringFromASInterfaceState(node.interfaceState), @"Subtree interface state should match cell node interface state for ASM nodes.");
|
||||
XCTAssert(node.inDisplayState || !node.nodeLoaded, @"Only nodes in the display range should be loaded.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user