Skip to content

Commit

Permalink
Fabric: AccessibilityProps::testId mapped to testID and implement…
Browse files Browse the repository at this point in the history
…ed for iOS

Summary:
This should make `testID` prop work as it works in pre-Fabric renderer on iOS.
On Android it should already work fine.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D25524890

fbshipit-source-id: 3f25eb427d4449abaab790099546be18ae573f98
  • Loading branch information
shergin authored and facebook-github-bot committed Dec 14, 2020
1 parent ff98005 commit 272ef6b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
#endif
}

// `testId`
if (oldViewProps.testId != newViewProps.testId) {
self.accessibilityIdentifier = RCTNSStringFromString(newViewProps.testId);
}

_needsInvalidateLayer = _needsInvalidateLayer || needsInvalidateLayer;

_props = std::static_pointer_cast<ViewProps const>(props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ AccessibilityProps::AccessibilityProps(
"importantForAccessibility",
sourceProps.importantForAccessibility,
ImportantForAccessibility::Auto)),
testId(convertRawProp(rawProps, "testId", sourceProps.testId, "")) {}
testId(convertRawProp(rawProps, "testID", sourceProps.testId, "")) {}

#pragma mark - DebugStringConvertible

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ void ViewShadowNode::initialize() noexcept {

bool formsView = isColorMeaningful(viewProps.backgroundColor) ||
isColorMeaningful(viewProps.foregroundColor) ||
!(viewProps.yogaStyle.border() == YGStyle::Edges{});
!(viewProps.yogaStyle.border() == YGStyle::Edges{}) ||
!viewProps.testId.empty();

formsView = formsView || formsStackingContext;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ TEST(UITemplateProcessorTest, testSimpleBytecode) {
auto nativeModuleRegistry = buildNativeModuleRegistry();

auto bytecode = R"delim({"version":0.1,"commands":[
["createNode",2,"RCTView",-1,{"opacity": 0.5, "testId": "root"}],
["createNode",4,"RCTView",2,{"testId": "child"}],
["createNode",2,"RCTView",-1,{"opacity": 0.5, "testID": "root"}],
["createNode",4,"RCTView",2,{"testID": "child"}],
["returnRoot",2]
]})delim";

Expand Down Expand Up @@ -124,11 +124,11 @@ TEST(UITemplateProcessorTest, testConditionalBytecode) {
auto nativeModuleRegistry = buildNativeModuleRegistry();

auto bytecode = R"delim({"version":0.1,"commands":[
["createNode",2,"RCTView",-1,{"testId": "root"}],
["createNode",2,"RCTView",-1,{"testID": "root"}],
["loadNativeBool",1,"MobileConfig","getBool",["qe:simple_test"]],
["conditional",1,
[["createNode",4,"RCTView",2,{"testId": "cond_true"}]],
[["createNode",4,"RCTView",2,{"testId": "cond_false"}]]
[["createNode",4,"RCTView",2,{"testID": "cond_true"}]],
[["createNode",4,"RCTView",2,{"testID": "cond_false"}]]
],
["returnRoot",2]
]})delim";
Expand Down

0 comments on commit 272ef6b

Please sign in to comment.