mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 11:20:18 +00:00
[ASBridgedPropertiesTest] Make node retention test more reliable.
This commit is contained in:
parent
311c375c4b
commit
0af95c344c
@ -32,6 +32,18 @@
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface ASBridgedPropertiesTestNode : ASDisplayNode
|
||||||
|
@property (nullable, nonatomic, copy) dispatch_block_t onDealloc;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation ASBridgedPropertiesTestNode
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
_onDealloc();
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@interface ASBridgedPropertiesTests : XCTestCase
|
@interface ASBridgedPropertiesTests : XCTestCase
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -60,10 +72,12 @@ static inline void ASDispatchSyncOnOtherThread(dispatch_block_t block) {
|
|||||||
- (void)testThatDirtyNodesAreNotRetained
|
- (void)testThatDirtyNodesAreNotRetained
|
||||||
{
|
{
|
||||||
ASPendingStateController *ctrl = [ASPendingStateController sharedInstance];
|
ASPendingStateController *ctrl = [ASPendingStateController sharedInstance];
|
||||||
__weak ASDisplayNode *weakNode = nil;
|
__block BOOL didDealloc = NO;
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
__attribute__((objc_precise_lifetime)) ASDisplayNode *node = [ASDisplayNode new];
|
__attribute__((objc_precise_lifetime)) ASBridgedPropertiesTestNode *node = [ASBridgedPropertiesTestNode new];
|
||||||
weakNode = node;
|
node.onDealloc = ^{
|
||||||
|
didDealloc = YES;
|
||||||
|
};
|
||||||
[node view];
|
[node view];
|
||||||
XCTAssertEqual(node.alpha, 1);
|
XCTAssertEqual(node.alpha, 1);
|
||||||
ASDispatchSyncOnOtherThread(^{
|
ASDispatchSyncOnOtherThread(^{
|
||||||
@ -71,9 +85,8 @@ static inline void ASDispatchSyncOnOtherThread(dispatch_block_t block) {
|
|||||||
});
|
});
|
||||||
XCTAssertEqual(node.alpha, 1);
|
XCTAssertEqual(node.alpha, 1);
|
||||||
XCTAssert(ctrl.test_isFlushScheduled);
|
XCTAssert(ctrl.test_isFlushScheduled);
|
||||||
XCTAssertNotNil(weakNode);
|
|
||||||
}
|
}
|
||||||
XCTAssertNil(weakNode);
|
XCTAssertTrue(didDealloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatSettingABridgedViewPropertyInBackgroundGetsFlushedOnNextRunLoop
|
- (void)testThatSettingABridgedViewPropertyInBackgroundGetsFlushedOnNextRunLoop
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user