From 0baac1ccfccc392a2e1b44a831daa2cc9bf019c2 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 3 Mar 2020 23:31:35 -0800 Subject: [PATCH] Fabric: Improvements in Diffing test (`messWithLayotableOnlyFlag`) Summary: Now we tweak more props in order to prepare for new flattening algorithm. Changelog: [Internal] Fabric-specific internal change. Reviewed By: JoshuaGross Differential Revision: D20212254 fbshipit-source-id: 7391155072f93046e78fbecf4bb4b42cb1caacdc --- .../mounting/tests/shadowTreeGeneration.h | 49 ++++++++++++++++--- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/ReactCommon/fabric/mounting/tests/shadowTreeGeneration.h b/ReactCommon/fabric/mounting/tests/shadowTreeGeneration.h index b542b5d6744579..6058d9d531353b 100644 --- a/ReactCommon/fabric/mounting/tests/shadowTreeGeneration.h +++ b/ReactCommon/fabric/mounting/tests/shadowTreeGeneration.h @@ -119,17 +119,50 @@ static ShadowNode::Unshared messWithChildren( static ShadowNode::Unshared messWithLayotableOnlyFlag( Entropy const &entropy, ShadowNode const &shadowNode) { - folly::dynamic dynamic = folly::dynamic::object(); + auto oldProps = shadowNode.getProps(); + auto newProps = shadowNode.getComponentDescriptor().cloneProps( + oldProps, RawProps(folly::dynamic::object())); - if (entropy.random()) { - dynamic["collapsable"] = folly::dynamic{true}; - } else { - dynamic["collapsable"] = folly::dynamic{}; + auto &viewProps = + const_cast(static_cast(*newProps)); + + if (entropy.random(0.1)) { + viewProps.nativeId = entropy.random() ? "42" : ""; + } + + if (entropy.random(0.1)) { + viewProps.backgroundColor = + entropy.random() ? SharedColor() : whiteColor(); + } + + if (entropy.random(0.1)) { + viewProps.foregroundColor = + entropy.random() ? SharedColor() : blackColor(); + } + + if (entropy.random(0.1)) { + viewProps.shadowColor = + entropy.random() ? SharedColor() : blackColor(); + } + + if (entropy.random(0.1)) { + viewProps.accessible = entropy.random(); + } + + if (entropy.random(0.1)) { + viewProps.zIndex = entropy.random() ? 1 : 0; + } + + if (entropy.random(0.1)) { + viewProps.pointerEvents = entropy.random() ? PointerEventsMode::Auto + : PointerEventsMode::None; + } + + if (entropy.random(0.1)) { + viewProps.transform = entropy.random() ? Transform::Identity() + : Transform::Perspective(42); } - auto oldProps = shadowNode.getProps(); - auto newProps = shadowNode.getComponentDescriptor().cloneProps( - oldProps, RawProps(dynamic)); return shadowNode.clone({newProps}); }