Skip to content

Commit

Permalink
Add tests for accessibility (TextureGroup#1205)
Browse files Browse the repository at this point in the history
  • Loading branch information
wiseoldduck authored and mikezucc committed Nov 7, 2018
1 parent d3d23a2 commit 23a7516
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Tests/ASDisplayViewAccessibilityTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,47 @@ - (void)testAccessibilityElementsAccessors
XCTAssertEqual([node.view indexOfAccessibilityElement:node.view.accessibilityElements.firstObject], 0);*/
}

- (void)testThatSubnodeAccessibilityLabelAggregationWorks {
// Setup nodes
ASDisplayNode *node = nil;
ASDisplayNode *innerNode1 = nil;
ASDisplayNode *innerNode2 = nil;
node = [[ASDisplayNode alloc] init];
innerNode1 = [[ASDisplayNode alloc] init];
innerNode2 = [[ASDisplayNode alloc] init];

// Initialize nodes with relevant accessibility data
node.isAccessibilityContainer = YES;
innerNode1.accessibilityLabel = @"hello";
innerNode2.accessibilityLabel = @"world";

// Attach the subnodes to the parent node, then ensure their accessibility labels have been'
// aggregated to the parent's accessibility label
[node addSubnode:innerNode1];
[node addSubnode:innerNode2];
XCTAssertEqualObjects([node.view.accessibilityElements.firstObject accessibilityLabel],
@"hello, world", @"Subnode accessibility label aggregation broken %@",
[node.view.accessibilityElements.firstObject accessibilityLabel]);
}

- (void)testThatContainerAccessibilityLabelOverrideStopsAggregation {
// Setup nodes
ASDisplayNode *node = nil;
ASDisplayNode *innerNode = nil;
node = [[ASDisplayNode alloc] init];
innerNode = [[ASDisplayNode alloc] init];

// Initialize nodes with relevant accessibility data
node.isAccessibilityContainer = YES;
node.accessibilityLabel = @"hello";
innerNode.accessibilityLabel = @"world";

// Attach the subnode to the parent node, then ensure the parent's accessibility label does not
// get aggregated with the subnode's label
[node addSubnode:innerNode];
XCTAssertEqualObjects([node.view.accessibilityElements.firstObject accessibilityLabel], @"hello",
@"Container accessibility label override broken %@",
[node.view.accessibilityElements.firstObject accessibilityLabel]);
}

@end

0 comments on commit 23a7516

Please sign in to comment.