Skip to content

Commit

Permalink
Add support for exposing accessibility identifier as accessibilityIde…
Browse files Browse the repository at this point in the history
…ntifier on iOS (#48858)

This PR is a sibling of #47961 but for iOS
  • Loading branch information
bartekpacia authored Dec 11, 2023
1 parent d001419 commit c660860
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions shell/platform/darwin/ios/framework/Source/SemanticsObject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,17 @@ - (BOOL)onCustomAccessibilityAction:(FlutterCustomAccessibilityAction*)action {
return YES;
}

- (NSString*)accessibilityIdentifier {
if (![self isAccessibilityBridgeAlive]) {
return nil;
}

if ([self node].identifier.empty()) {
return nil;
}
return @([self node].identifier.data());
}

- (NSString*)accessibilityLabel {
if (![self isAccessibilityBridgeAlive]) {
return nil;
Expand Down
14 changes: 14 additions & 0 deletions shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,20 @@ - (void)testFlutterScrollableSemanticsObjectIsHiddenWhenVoiceOverIsRunning {
XCTAssertFalse(scrollView.isAccessibilityElement);
}

- (void)testFlutterSemanticsObjectHasIdentifier {
flutter::testing::MockAccessibilityBridge* mock = new flutter::testing::MockAccessibilityBridge();
mock->isVoiceOverRunningValue = true;
fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();

flutter::SemanticsNode node;
node.identifier = "identifier";

FlutterSemanticsObject* object = [[FlutterSemanticsObject alloc] initWithBridge:bridge uid:0];
[object setSemanticsNode:&node];
XCTAssertTrue([object.accessibilityIdentifier isEqualToString:@"identifier"]);
}

- (void)testFlutterScrollableSemanticsObjectWithLabelValueHintIsNotHiddenWhenVoiceOverIsRunning {
flutter::testing::MockAccessibilityBridge* mock = new flutter::testing::MockAccessibilityBridge();
mock->isVoiceOverRunningValue = true;
Expand Down

0 comments on commit c660860

Please sign in to comment.