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, zero_out_layout) {
12 const YGNodeRef root = YGNodeNew();
13 YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
14 YGNodeStyleSetWidth(root, 200);
15 YGNodeStyleSetHeight(root, 200);
17 const YGNodeRef child = YGNodeNew();
18 YGNodeInsertChild(root, child, 0);
19 YGNodeStyleSetWidth(child, 100);
20 YGNodeStyleSetHeight(child, 100);
21 YGNodeStyleSetMargin(child, YGEdgeTop, 10);
22 YGNodeStyleSetPadding(child, YGEdgeTop, 10);
24 YGNodeCalculateLayout(root, 100, 100, YGDirectionLTR);
26 ASSERT_FLOAT_EQ(10, YGNodeLayoutGetMargin(child, YGEdgeTop));
27 ASSERT_FLOAT_EQ(10, YGNodeLayoutGetPadding(child, YGEdgeTop));
29 YGNodeStyleSetDisplay(child, YGDisplayNone);
31 YGNodeCalculateLayout(root, 100, 100, YGDirectionLTR);
33 ASSERT_FLOAT_EQ(0, YGNodeLayoutGetMargin(child, YGEdgeTop));
34 ASSERT_FLOAT_EQ(0, YGNodeLayoutGetPadding(child, YGEdgeTop));
36 YGNodeFreeRecursive(root);