-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable a11y cache #1274
Merged
Merged
Disable a11y cache #1274
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,12 +14,21 @@ | |
|
||
#import <AsyncDisplayKit/ASDisplayNode.h> | ||
#import <AsyncDisplayKit/ASDisplayNode+Beta.h> | ||
#import <AsyncDisplayKit/ASTextNode.h> | ||
#import "ASConfiguration.h" | ||
#import "ASConfigurationInternal.h" | ||
|
||
@interface ASDisplayViewAccessibilityTests : XCTestCase | ||
@end | ||
|
||
@implementation ASDisplayViewAccessibilityTests | ||
|
||
- (void)setUp { | ||
ASConfiguration *config = [[ASConfiguration alloc] initWithDictionary:nil]; | ||
config.experimentalFeatures = ASExperimentalDisableAccessibilityCache; | ||
[ASConfigurationManager test_resetWithConfiguration:config]; | ||
} | ||
|
||
- (void)testAccessibilityElementsAccessors | ||
{ | ||
// Setup nodes with accessibility info | ||
|
@@ -82,4 +91,173 @@ - (void)testThatContainerAccessibilityLabelOverrideStopsAggregation { | |
[node.view.accessibilityElements.firstObject accessibilityLabel]); | ||
} | ||
|
||
- (void)testAccessibilityLayerbackedNodesOperationInContainer { | ||
ASDisplayNode *contianer = [[ASDisplayNode alloc] init]; | ||
contianer.frame = CGRectMake(50, 50, 200, 400); | ||
contianer.backgroundColor = [UIColor grayColor]; | ||
contianer.isAccessibilityContainer = YES; | ||
// Do any additional setup after loading the view, typically from a nib. | ||
ASTextNode *text1 = [[ASTextNode alloc] init]; | ||
text1.layerBacked = YES; | ||
text1.attributedText = [[NSAttributedString alloc] initWithString:@"hello"]; | ||
text1.frame = CGRectMake(50, 100, 200, 200); | ||
[contianer addSubnode:text1]; | ||
[contianer layoutIfNeeded]; | ||
[contianer.layer displayIfNeeded]; | ||
NSArray<UIAccessibilityElement *> *elements = contianer.view.accessibilityElements; | ||
XCTAssertTrue(elements.count == 1); | ||
XCTAssertTrue([[elements.firstObject accessibilityLabel] isEqualToString:@"hello"]); | ||
ASTextNode *text2 = [[ASTextNode alloc] init]; | ||
text2.layerBacked = YES; | ||
text2.attributedText = [[NSAttributedString alloc] initWithString:@"world"]; | ||
text2.frame = CGRectMake(50, 300, 200, 200); | ||
[contianer addSubnode:text2]; | ||
[contianer layoutIfNeeded]; | ||
[contianer.layer displayIfNeeded]; | ||
NSArray<UIAccessibilityElement *> *updatedElements = contianer.view.accessibilityElements; | ||
XCTAssertTrue(updatedElements.count == 1); | ||
XCTAssertTrue([[updatedElements.firstObject accessibilityLabel] isEqualToString:@"hello, world"]); | ||
ASTextNode *text3 = [[ASTextNode alloc] init]; | ||
text3.attributedText = [[NSAttributedString alloc] initWithString:@"!!!!"]; | ||
text3.frame = CGRectMake(50, 400, 200, 100); | ||
text3.layerBacked = YES; | ||
[text2 addSubnode:text3]; | ||
[contianer layoutIfNeeded]; | ||
[contianer.layer displayIfNeeded]; | ||
NSArray<UIAccessibilityElement *> *updatedElements2 = contianer.view.accessibilityElements; | ||
XCTAssertTrue([[updatedElements2.firstObject accessibilityLabel] isEqualToString:@"hello, world, !!!!"]); | ||
} | ||
- (void)testAccessibilityNonLayerbackedNodesOperationInContainer { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. Also separate these methods by new lines. |
||
ASDisplayNode *contianer = [[ASDisplayNode alloc] init]; | ||
contianer.frame = CGRectMake(50, 50, 200, 600); | ||
contianer.backgroundColor = [UIColor grayColor]; | ||
contianer.isAccessibilityContainer = YES; | ||
// Do any additional setup after loading the view, typically from a nib. | ||
ASTextNode *text1 = [[ASTextNode alloc] init]; | ||
text1.attributedText = [[NSAttributedString alloc] initWithString:@"hello"]; | ||
text1.frame = CGRectMake(50, 100, 200, 200); | ||
[contianer addSubnode:text1]; | ||
[contianer layoutIfNeeded]; | ||
[contianer.layer displayIfNeeded]; | ||
NSArray<UIAccessibilityElement *> *elements = contianer.view.accessibilityElements; | ||
XCTAssertTrue(elements.count == 1); | ||
XCTAssertTrue([[elements.firstObject accessibilityLabel] isEqualToString:@"hello"]); | ||
ASTextNode *text2 = [[ASTextNode alloc] init]; | ||
text2.attributedText = [[NSAttributedString alloc] initWithString:@"world"]; | ||
text2.frame = CGRectMake(50, 300, 200, 200); | ||
[contianer addSubnode:text2]; | ||
[contianer layoutIfNeeded]; | ||
[contianer.layer displayIfNeeded]; | ||
NSArray<UIAccessibilityElement *> *updatedElements = contianer.view.accessibilityElements; | ||
XCTAssertTrue(updatedElements.count == 1); | ||
XCTAssertTrue([[updatedElements.firstObject accessibilityLabel] isEqualToString:@"hello, world"]); | ||
ASTextNode *text3 = [[ASTextNode alloc] init]; | ||
text3.attributedText = [[NSAttributedString alloc] initWithString:@"!!!!"]; | ||
text3.frame = CGRectMake(50, 400, 200, 100); | ||
[text2 addSubnode:text3]; | ||
[contianer layoutIfNeeded]; | ||
[contianer.layer displayIfNeeded]; | ||
NSArray<UIAccessibilityElement *> *updatedElements2 = contianer.view.accessibilityElements; | ||
XCTAssertTrue([[updatedElements2.firstObject accessibilityLabel] isEqualToString:@"hello, world, !!!!"]); | ||
} | ||
- (void)testAccessibilityNonLayerbackedNodesOperationInNonContainer { | ||
ASDisplayNode *contianer = [[ASDisplayNode alloc] init]; | ||
contianer.frame = CGRectMake(50, 50, 200, 600); | ||
contianer.backgroundColor = [UIColor grayColor]; | ||
// Do any additional setup after loading the view, typically from a nib. | ||
ASTextNode *text1 = [[ASTextNode alloc] init]; | ||
text1.attributedText = [[NSAttributedString alloc] initWithString:@"hello"]; | ||
text1.frame = CGRectMake(50, 100, 200, 200); | ||
[contianer addSubnode:text1]; | ||
[contianer layoutIfNeeded]; | ||
[contianer.layer displayIfNeeded]; | ||
NSArray<UIAccessibilityElement *> *elements = contianer.view.accessibilityElements; | ||
XCTAssertTrue(elements.count == 1); | ||
XCTAssertTrue([[elements.firstObject accessibilityLabel] isEqualToString:@"hello"]); | ||
ASTextNode *text2 = [[ASTextNode alloc] init]; | ||
text2.attributedText = [[NSAttributedString alloc] initWithString:@"world"]; | ||
text2.frame = CGRectMake(50, 300, 200, 200); | ||
[contianer addSubnode:text2]; | ||
[contianer layoutIfNeeded]; | ||
[contianer.layer displayIfNeeded]; | ||
NSArray<UIAccessibilityElement *> *updatedElements = contianer.view.accessibilityElements; | ||
XCTAssertTrue(updatedElements.count == 2); | ||
XCTAssertTrue([[updatedElements.firstObject accessibilityLabel] isEqualToString:@"hello"]); | ||
XCTAssertTrue([[updatedElements.lastObject accessibilityLabel] isEqualToString:@"world"]); | ||
ASTextNode *text3 = [[ASTextNode alloc] init]; | ||
text3.attributedText = [[NSAttributedString alloc] initWithString:@"!!!!"]; | ||
text3.frame = CGRectMake(50, 400, 200, 100); | ||
[text2 addSubnode:text3]; | ||
[contianer layoutIfNeeded]; | ||
[contianer.layer displayIfNeeded]; | ||
NSArray<UIAccessibilityElement *> *updatedElements2 = contianer.view.accessibilityElements; | ||
//text3 won't be read out cause it's overshadowed by text2 | ||
XCTAssertTrue(updatedElements2.count == 2); | ||
XCTAssertTrue([[updatedElements2.firstObject accessibilityLabel] isEqualToString:@"hello"]); | ||
XCTAssertTrue([[updatedElements2.lastObject accessibilityLabel] isEqualToString:@"world"]); | ||
} | ||
- (void)testAccessibilityLayerbackedNodesOperationInNonContainer { | ||
ASDisplayNode *contianer = [[ASDisplayNode alloc] init]; | ||
contianer.frame = CGRectMake(50, 50, 200, 600); | ||
contianer.backgroundColor = [UIColor grayColor]; | ||
// Do any additional setup after loading the view, typically from a nib. | ||
ASTextNode *text1 = [[ASTextNode alloc] init]; | ||
text1.layerBacked = YES; | ||
text1.attributedText = [[NSAttributedString alloc] initWithString:@"hello"]; | ||
text1.frame = CGRectMake(50, 0, 100, 100); | ||
[contianer addSubnode:text1]; | ||
[contianer layoutIfNeeded]; | ||
[contianer.layer displayIfNeeded]; | ||
NSArray<UIAccessibilityElement *> *elements = contianer.view.accessibilityElements; | ||
XCTAssertTrue(elements.count == 1); | ||
XCTAssertTrue([[elements.firstObject accessibilityLabel] isEqualToString:@"hello"]); | ||
ASTextNode *text2 = [[ASTextNode alloc] init]; | ||
text2.layerBacked = YES; | ||
text2.attributedText = [[NSAttributedString alloc] initWithString:@"world"]; | ||
text2.frame = CGRectMake(50, 100, 100, 100); | ||
[contianer addSubnode:text2]; | ||
[contianer layoutIfNeeded]; | ||
[contianer.layer displayIfNeeded]; | ||
NSArray<UIAccessibilityElement *> *updatedElements = contianer.view.accessibilityElements; | ||
XCTAssertTrue(updatedElements.count == 2); | ||
XCTAssertTrue([[updatedElements.firstObject accessibilityLabel] isEqualToString:@"hello"]); | ||
XCTAssertTrue([[updatedElements.lastObject accessibilityLabel] isEqualToString:@"world"]); | ||
ASTextNode *text3 = [[ASTextNode alloc] init]; | ||
text3.layerBacked = YES; | ||
text3.attributedText = [[NSAttributedString alloc] initWithString:@"!!!!"]; | ||
text3.frame = CGRectMake(50, 200, 100, 100); | ||
[text2 addSubnode:text3]; | ||
[contianer layoutIfNeeded]; | ||
[contianer.layer displayIfNeeded]; | ||
NSArray<UIAccessibilityElement *> *updatedElements2 = contianer.view.accessibilityElements; | ||
//text3 won't be read out cause it's overshadowed by text2 | ||
XCTAssertTrue(updatedElements2.count == 2); | ||
XCTAssertTrue([[updatedElements2.firstObject accessibilityLabel] isEqualToString:@"hello"]); | ||
XCTAssertTrue([[updatedElements2.lastObject accessibilityLabel] isEqualToString:@"world"]); | ||
} | ||
|
||
- (void)testAccessibilityUpdatesWithElementsChanges { | ||
ASDisplayNode *contianer = [[ASDisplayNode alloc] init]; | ||
contianer.frame = CGRectMake(50, 50, 200, 600); | ||
contianer.backgroundColor = [UIColor grayColor]; | ||
contianer.isAccessibilityContainer = YES; | ||
// Do any additional setup after loading the view, typically from a nib. | ||
ASTextNode *text1 = [[ASTextNode alloc] init]; | ||
text1.layerBacked = YES; | ||
text1.attributedText = [[NSAttributedString alloc] initWithString:@"hello"]; | ||
text1.frame = CGRectMake(50, 0, 100, 100); | ||
[contianer addSubnode:text1]; | ||
[contianer layoutIfNeeded]; | ||
[contianer.layer displayIfNeeded]; | ||
NSArray<UIAccessibilityElement *> *elements = contianer.view.accessibilityElements; | ||
XCTAssertTrue(elements.count == 1); | ||
XCTAssertTrue([[elements.firstObject accessibilityLabel] isEqualToString:@"hello"]); | ||
text1.attributedText = [[NSAttributedString alloc] initWithString:@"greeting"]; | ||
[contianer layoutIfNeeded]; | ||
[contianer.layer displayIfNeeded]; | ||
NSArray<UIAccessibilityElement *> *elements2 = contianer.view.accessibilityElements; | ||
XCTAssertTrue(elements2.count == 1); | ||
XCTAssertTrue([[elements2.firstObject accessibilityLabel] isEqualToString:@"greeting"]); | ||
} | ||
|
||
@end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bracket on the following line please.