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, dont_cache_computed_flex_basis_between_layouts) {
12 const YGConfigRef config = YGConfigNew();
13 YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureWebFlexBasis, true);
15 const YGNodeRef root = YGNodeNewWithConfig(config);
16 YGNodeStyleSetHeightPercent(root, 100);
17 YGNodeStyleSetWidthPercent(root, 100);
19 const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
20 YGNodeStyleSetFlexBasisPercent(root_child0, 100);
21 YGNodeInsertChild(root, root_child0, 0);
23 YGNodeCalculateLayout(root, 100, YGUndefined, YGDirectionLTR);
24 YGNodeCalculateLayout(root, 100, 100, YGDirectionLTR);
26 ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
28 YGNodeFreeRecursive(root);
33 TEST(YogaTest, recalculate_resolvedDimonsion_onchange) {
34 const YGNodeRef root = YGNodeNew();
36 const YGNodeRef root_child0 = YGNodeNew();
37 YGNodeStyleSetMinHeight(root_child0, 10);
38 YGNodeStyleSetMaxHeight(root_child0, 10);
39 YGNodeInsertChild(root, root_child0, 0);
41 YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
42 ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
44 YGNodeStyleSetMinHeight(root_child0, YGUndefined);
45 YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
47 ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0));
49 YGNodeFreeRecursive(root);