2 * Copyright (c) 2014-present, Facebook, Inc.
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
8 #include <gtest/gtest.h>
11 TEST(YogaTest, reset_layout_when_child_removed) {
12 const YGNodeRef root = YGNodeNew();
14 const YGNodeRef root_child0 = YGNodeNew();
15 YGNodeStyleSetWidth(root_child0, 100);
16 YGNodeStyleSetHeight(root_child0, 100);
17 YGNodeInsertChild(root, root_child0, 0);
19 YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
21 ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
22 ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
23 ASSERT_EQ(100, YGNodeLayoutGetWidth(root_child0));
24 ASSERT_EQ(100, YGNodeLayoutGetHeight(root_child0));
26 YGNodeRemoveChild(root, root_child0);
28 ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
29 ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
30 ASSERT_TRUE(YGFloatIsUndefined(YGNodeLayoutGetWidth(root_child0)));
31 ASSERT_TRUE(YGFloatIsUndefined(YGNodeLayoutGetHeight(root_child0)));
33 YGNodeFreeRecursive(root);