mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
b2dbde36b8
Summary: Changelog: [internal] Add unit tests to prevent bug with `RootShadowNode::clone`. Reviewed By: mdvacca Differential Revision: D28378456 fbshipit-source-id: 8564835e5dfe677b17111162ccad40d975615cf9
43 lines
1.4 KiB
C++
43 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include <react/renderer/components/root/RootComponentDescriptor.h>
|
|
#include <react/renderer/element/ComponentBuilder.h>
|
|
#include <react/renderer/element/Element.h>
|
|
#include <react/renderer/element/testUtils.h>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
namespace facebook::react {
|
|
|
|
TEST(RootShadowNodeTest, cloneWithLayoutConstraints) {
|
|
auto builder = simpleComponentBuilder();
|
|
std::shared_ptr<RootShadowNode> rootShadowNode;
|
|
LayoutConstraints defaultLayoutConstraints = {};
|
|
|
|
auto element =
|
|
Element<RootShadowNode>().reference(rootShadowNode).tag(1).props([&] {
|
|
auto sharedProps = std::make_shared<RootProps>();
|
|
sharedProps->layoutConstraints = defaultLayoutConstraints;
|
|
return sharedProps;
|
|
});
|
|
|
|
builder.build(element);
|
|
|
|
EXPECT_FALSE(rootShadowNode->getIsLayoutClean());
|
|
EXPECT_TRUE(rootShadowNode->layoutIfNeeded());
|
|
EXPECT_TRUE(rootShadowNode->getIsLayoutClean());
|
|
|
|
auto clonedWithDiffentLayoutConstraints =
|
|
rootShadowNode->clone(LayoutConstraints{{0, 0}, {10, 10}}, {});
|
|
|
|
EXPECT_FALSE(clonedWithDiffentLayoutConstraints->getIsLayoutClean());
|
|
EXPECT_TRUE(clonedWithDiffentLayoutConstraints->layoutIfNeeded());
|
|
}
|
|
|
|
} // namespace facebook::react
|