mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Fix isTruncated logic in ASTextNode2 (#1259)
* Fix isTruncated logic in ASTextNode2 * Add truncation tests
This commit is contained in:
committed by
GitHub
parent
fb844c3252
commit
758afabde3
@@ -1145,7 +1145,7 @@ static NSAttributedString *DefaultTruncationAttributedString()
|
||||
|
||||
- (BOOL)isTruncated
|
||||
{
|
||||
return ASLockedSelf([self locked_textLayoutForSize:[self _locked_threadSafeBounds].size].truncatedLine == nil);
|
||||
return ASLockedSelf([self locked_textLayoutForSize:[self _locked_threadSafeBounds].size].truncatedLine != nil);
|
||||
}
|
||||
|
||||
- (BOOL)shouldTruncateForConstrainedSize:(ASSizeRange)constrainedSize
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#import <AsyncDisplayKit/ASDisplayNode+Beta.h>
|
||||
#import <AsyncDisplayKit/ASTextNode2.h>
|
||||
#import <AsyncDisplayKit/ASTextNode+Beta.h>
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
@@ -63,6 +64,14 @@
|
||||
_textNode.attributedText = _attributedText;
|
||||
}
|
||||
|
||||
- (void)testTruncation
|
||||
{
|
||||
XCTAssertTrue([(ASTextNode *)_textNode shouldTruncateForConstrainedSize:ASSizeRangeMake(CGSizeMake(100, 100))], @"Text Node should truncate");
|
||||
|
||||
_textNode.frame = CGRectMake(0, 0, 100, 100);
|
||||
XCTAssertTrue(_textNode.isTruncated, @"Text Node should be truncated");
|
||||
}
|
||||
|
||||
- (void)testAccessibility
|
||||
{
|
||||
XCTAssertTrue(_textNode.isAccessibilityElement, @"Should be an accessibility element");
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#import <AsyncDisplayKit/ASAvailability.h>
|
||||
#import <AsyncDisplayKit/ASLayout.h>
|
||||
#import <AsyncDisplayKit/ASTextNode.h>
|
||||
#import <AsyncDisplayKit/ASTextNode+Beta.h>
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
#import <AsyncDisplayKit/CoreGraphics+ASConvenience.h>
|
||||
@@ -102,6 +103,14 @@
|
||||
|
||||
#pragma mark - ASTextNode
|
||||
|
||||
- (void)testTruncation
|
||||
{
|
||||
XCTAssertTrue([_textNode shouldTruncateForConstrainedSize:ASSizeRangeMake(CGSizeMake(100, 100))], @"");
|
||||
|
||||
_textNode.frame = CGRectMake(0, 0, 100, 100);
|
||||
XCTAssertTrue(_textNode.isTruncated, @"Text Node should be truncated");
|
||||
}
|
||||
|
||||
- (void)testSettingTruncationMessage
|
||||
{
|
||||
NSAttributedString *truncation = [[NSAttributedString alloc] initWithString:@"..." attributes:nil];
|
||||
|
||||
Reference in New Issue
Block a user