Skip to content
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

Add forwarding of UIAccessibilityAction methods #1344

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add forwarding of UIAccessibilityAction methods
  • Loading branch information
smeis committed Feb 20, 2019
commit cc858340f3dc79ad8b769e38797621b94482b6e4
28 changes: 28 additions & 0 deletions Source/Details/_ASDisplayViewAccessiblity.mm
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,32 @@ - (NSArray *)accessibilityElements

@end

@implementation _ASDisplayView (UIAccessibilityAction)

- (BOOL)accessibilityActivate {
return [self.asyncdisplaykit_node accessibilityActivate];
}

- (void)accessibilityIncrement {
[self.asyncdisplaykit_node accessibilityIncrement];
}

- (void)accessibilityDecrement {
[self.asyncdisplaykit_node accessibilityDecrement];
}

- (BOOL)accessibilityScroll:(UIAccessibilityScrollDirection)direction {
return [self.asyncdisplaykit_node accessibilityScroll:direction];
}

- (BOOL)accessibilityPerformEscape {
return [self.asyncdisplaykit_node accessibilityPerformEscape];
}

- (BOOL)accessibilityPerformMagicTap {
return [self.asyncdisplaykit_node accessibilityPerformMagicTap];
}

@end

#endif
64 changes: 64 additions & 0 deletions Tests/ASDisplayViewAccessibilityTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,49 @@
#import <AsyncDisplayKit/ASConfiguration.h>
#import <AsyncDisplayKit/ASConfigurationInternal.h>

@interface ASAccessiblityForwardingTestDisplayNode : ASDisplayNode

@property (nonatomic, readonly) BOOL didReceiveAccessibilityActivate;
@property (nonatomic, readonly) BOOL didReceiveAccessibilityIncrement;
@property (nonatomic, readonly) BOOL didReceiveAccessibilityDecrement;
@property (nonatomic, readonly) BOOL didReceiveAccessibilityScroll;
@property (nonatomic, readonly) BOOL didReceiveAccessibilityPerformEscape;
@property (nonatomic, readonly) BOOL didReceiveAccessibilityPerformMagicTap;

@end

@implementation ASAccessiblityForwardingTestDisplayNode

- (BOOL)accessibilityActivate {
_didReceiveAccessibilityActivate = YES;
return YES;
}

- (void)accessibilityIncrement {
_didReceiveAccessibilityIncrement = YES;
}

- (void)accessibilityDecrement {
_didReceiveAccessibilityDecrement = YES;
}

- (BOOL)accessibilityScroll:(UIAccessibilityScrollDirection)direction {
_didReceiveAccessibilityScroll = YES;
return YES;
}

- (BOOL)accessibilityPerformEscape {
_didReceiveAccessibilityPerformEscape = YES;
return YES;
}

- (BOOL)accessibilityPerformMagicTap {
_didReceiveAccessibilityPerformMagicTap = YES;
return YES;
}

@end

@interface ASDisplayViewAccessibilityTests : XCTestCase
@end

Expand Down Expand Up @@ -269,4 +312,25 @@ - (void)testAccessibilityUpdatesWithElementsChanges
XCTAssertTrue([[elements2.firstObject accessibilityLabel] isEqualToString:@"greeting"]);
}

#pragma mark -
#pragma mark UIAccessibilityAction Forwarding

- (void)testActionForwarding {
ASAccessiblityForwardingTestDisplayNode *node = [ASAccessiblityForwardingTestDisplayNode new];
UIView *view = node.view;

[view accessibilityActivate];
XCTAssertTrue(node.didReceiveAccessibilityActivate);
[view accessibilityIncrement];
XCTAssertTrue(node.didReceiveAccessibilityIncrement);
[view accessibilityDecrement];
XCTAssertTrue(node.didReceiveAccessibilityDecrement);
[view accessibilityScroll:UIAccessibilityScrollDirectionDown];
XCTAssertTrue(node.didReceiveAccessibilityScroll);
[view accessibilityPerformEscape];
XCTAssertTrue(node.didReceiveAccessibilityPerformEscape);
[view accessibilityPerformMagicTap];
XCTAssertTrue(node.didReceiveAccessibilityPerformMagicTap);
smeis marked this conversation as resolved.
Show resolved Hide resolved
}

@end