Skip to content

Commit

Permalink
Fabric: Improvements in Diffing test (messWithLayotableOnlyFlag)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
shergin authored and facebook-github-bot committed Mar 4, 2020
1 parent 903bf2d commit 0baac1c
Showing 1 changed file with 41 additions and 8 deletions.
49 changes: 41 additions & 8 deletions ReactCommon/fabric/mounting/tests/shadowTreeGeneration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>()) {
dynamic["collapsable"] = folly::dynamic{true};
} else {
dynamic["collapsable"] = folly::dynamic{};
auto &viewProps =
const_cast<ViewProps &>(static_cast<ViewProps const &>(*newProps));

if (entropy.random<bool>(0.1)) {
viewProps.nativeId = entropy.random<bool>() ? "42" : "";
}

if (entropy.random<bool>(0.1)) {
viewProps.backgroundColor =
entropy.random<bool>() ? SharedColor() : whiteColor();
}

if (entropy.random<bool>(0.1)) {
viewProps.foregroundColor =
entropy.random<bool>() ? SharedColor() : blackColor();
}

if (entropy.random<bool>(0.1)) {
viewProps.shadowColor =
entropy.random<bool>() ? SharedColor() : blackColor();
}

if (entropy.random<bool>(0.1)) {
viewProps.accessible = entropy.random<bool>();
}

if (entropy.random<bool>(0.1)) {
viewProps.zIndex = entropy.random<bool>() ? 1 : 0;
}

if (entropy.random<bool>(0.1)) {
viewProps.pointerEvents = entropy.random<bool>() ? PointerEventsMode::Auto
: PointerEventsMode::None;
}

if (entropy.random<bool>(0.1)) {
viewProps.transform = entropy.random<bool>() ? Transform::Identity()
: Transform::Perspective(42);
}

auto oldProps = shadowNode.getProps();
auto newProps = shadowNode.getComponentDescriptor().cloneProps(
oldProps, RawProps(dynamic));
return shadowNode.clone({newProps});
}

Expand Down

0 comments on commit 0baac1c

Please sign in to comment.