Rebase of facebook flexbox to yoga
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-third-party / yoga / YGRelayoutTest.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, dont_cache_computed_flex_basis_between_layouts) {
12   const YGConfigRef config = YGConfigNew();
13   YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureWebFlexBasis, true);
14
15   const YGNodeRef root = YGNodeNewWithConfig(config);
16   YGNodeStyleSetHeightPercent(root, 100);
17   YGNodeStyleSetWidthPercent(root, 100);
18
19   const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
20   YGNodeStyleSetFlexBasisPercent(root_child0, 100);
21   YGNodeInsertChild(root, root_child0, 0);
22
23   YGNodeCalculateLayout(root, 100, YGUndefined, YGDirectionLTR);
24   YGNodeCalculateLayout(root, 100, 100, YGDirectionLTR);
25
26   ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
27
28   YGNodeFreeRecursive(root);
29
30   YGConfigFree(config);
31 }
32
33 TEST(YogaTest, recalculate_resolvedDimonsion_onchange) {
34   const YGNodeRef root = YGNodeNew();
35
36   const YGNodeRef root_child0 = YGNodeNew();
37   YGNodeStyleSetMinHeight(root_child0, 10);
38   YGNodeStyleSetMaxHeight(root_child0, 10);
39   YGNodeInsertChild(root, root_child0, 0);
40
41   YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
42   ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
43
44   YGNodeStyleSetMinHeight(root_child0, YGUndefined);
45   YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
46
47   ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0));
48
49   YGNodeFreeRecursive(root);
50 }