Rebase of facebook flexbox to yoga
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-third-party / yoga / YGZeroOutLayoutRecursivlyTest.cpp
1 /**
2  * Copyright (c) 2014-present, Facebook, Inc.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7
8 #include <gtest/gtest.h>
9 #include <yoga/Yoga.h>
10
11 TEST(YogaTest, zero_out_layout) {
12   const YGNodeRef root = YGNodeNew();
13   YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
14   YGNodeStyleSetWidth(root, 200);
15   YGNodeStyleSetHeight(root, 200);
16
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);
23
24   YGNodeCalculateLayout(root, 100, 100, YGDirectionLTR);
25
26   ASSERT_FLOAT_EQ(10, YGNodeLayoutGetMargin(child, YGEdgeTop));
27   ASSERT_FLOAT_EQ(10, YGNodeLayoutGetPadding(child, YGEdgeTop));
28
29   YGNodeStyleSetDisplay(child, YGDisplayNone);
30
31   YGNodeCalculateLayout(root, 100, 100, YGDirectionLTR);
32
33   ASSERT_FLOAT_EQ(0, YGNodeLayoutGetMargin(child, YGEdgeTop));
34   ASSERT_FLOAT_EQ(0, YGNodeLayoutGetPadding(child, YGEdgeTop));
35
36   YGNodeFreeRecursive(root);
37 }