Move configuration to new YGConfig and pass them down to CalculateLayout

Summary:
Move configuration to new ```YGConfig``` and pass them down to CalculateLayout. See #418 .

Adds ```YGConfigNew()``` + ```YGConfigFree```, and changed ```YGSetExperimentalFeatureEnabled``` to use the config.

New function for calculation is ```YGNodeCalculateLayoutWithConfig```.
Closes https://github.com/facebook/yoga/pull/432

Reviewed By: astreet

Differential Revision: D4611359

Pulled By: emilsjolander

fbshipit-source-id: a1332f0e1b21cec02129dd021ee57408449e10b0
This commit is contained in:
Lukas Wöhrl
2017-03-01 09:19:55 -08:00
committed by Facebook Github Bot
parent 8668e43f6d
commit 37c48257ae
89 changed files with 4536 additions and 3049 deletions

View File

@@ -13,33 +13,35 @@
#include <yoga/Yoga.h>
TEST(YogaTest, align_content_flex_start) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 130);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeStyleSetHeight(root_child3, 10);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeStyleSetHeight(root_child4, 10);
YGNodeInsertChild(root, root_child4, 4);
@@ -108,33 +110,37 @@ TEST(YogaTest, align_content_flex_start) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_flex_start_without_height_on_children) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeStyleSetHeight(root_child3, 10);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -202,39 +208,43 @@ TEST(YogaTest, align_content_flex_start_without_height_on_children) {
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_flex_start_with_flex) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 120);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 0);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetFlexBasisPercent(root_child1, 0);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child3, 1);
YGNodeStyleSetFlexShrink(root_child3, 1);
YGNodeStyleSetFlexBasisPercent(root_child3, 0);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -302,36 +312,40 @@ TEST(YogaTest, align_content_flex_start_with_flex) {
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_flex_end) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignContent(root, YGAlignFlexEnd);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeStyleSetHeight(root_child3, 10);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeStyleSetHeight(root_child4, 10);
YGNodeInsertChild(root, root_child4, 4);
@@ -400,32 +414,36 @@ TEST(YogaTest, align_content_flex_end) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -493,37 +511,41 @@ TEST(YogaTest, align_content_stretch) {
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_spacebetween) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignSpaceBetween);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 130);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeStyleSetHeight(root_child3, 10);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeStyleSetHeight(root_child4, 10);
YGNodeInsertChild(root, root_child4, 4);
@@ -592,37 +614,41 @@ TEST(YogaTest, align_content_spacebetween) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_spacearound) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignSpaceAround);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 140);
YGNodeStyleSetHeight(root, 120);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeStyleSetHeight(root_child3, 10);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeStyleSetHeight(root_child4, 10);
YGNodeInsertChild(root, root_child4, 4);
@@ -691,33 +717,37 @@ TEST(YogaTest, align_content_spacearound) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -785,39 +815,43 @@ TEST(YogaTest, align_content_stretch_row) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row_with_children) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0_child0, 1);
YGNodeStyleSetFlexShrink(root_child0_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0_child0, 0);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -895,39 +929,43 @@ TEST(YogaTest, align_content_stretch_row_with_children) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row_with_flex) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetFlexShrink(root_child1, 1);
YGNodeStyleSetFlexBasisPercent(root_child1, 0);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child3, 1);
YGNodeStyleSetFlexShrink(root_child3, 1);
YGNodeStyleSetFlexBasisPercent(root_child3, 0);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -995,38 +1033,42 @@ TEST(YogaTest, align_content_stretch_row_with_flex) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row_with_flex_no_shrink) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetFlexShrink(root_child1, 1);
YGNodeStyleSetFlexBasisPercent(root_child1, 0);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child3, 1);
YGNodeStyleSetFlexBasisPercent(root_child3, 0);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -1094,21 +1136,25 @@ TEST(YogaTest, align_content_stretch_row_with_flex_no_shrink) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row_with_margin) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetMargin(root_child1, YGEdgeLeft, 10);
YGNodeStyleSetMargin(root_child1, YGEdgeTop, 10);
YGNodeStyleSetMargin(root_child1, YGEdgeRight, 10);
@@ -1116,11 +1162,11 @@ TEST(YogaTest, align_content_stretch_row_with_margin) {
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetMargin(root_child3, YGEdgeLeft, 10);
YGNodeStyleSetMargin(root_child3, YGEdgeTop, 10);
YGNodeStyleSetMargin(root_child3, YGEdgeRight, 10);
@@ -1128,7 +1174,7 @@ TEST(YogaTest, align_content_stretch_row_with_margin) {
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -1196,21 +1242,25 @@ TEST(YogaTest, align_content_stretch_row_with_margin) {
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row_with_padding) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPadding(root_child1, YGEdgeLeft, 10);
YGNodeStyleSetPadding(root_child1, YGEdgeTop, 10);
YGNodeStyleSetPadding(root_child1, YGEdgeRight, 10);
@@ -1218,11 +1268,11 @@ TEST(YogaTest, align_content_stretch_row_with_padding) {
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetPadding(root_child3, YGEdgeLeft, 10);
YGNodeStyleSetPadding(root_child3, YGEdgeTop, 10);
YGNodeStyleSetPadding(root_child3, YGEdgeRight, 10);
@@ -1230,7 +1280,7 @@ TEST(YogaTest, align_content_stretch_row_with_padding) {
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -1298,21 +1348,25 @@ TEST(YogaTest, align_content_stretch_row_with_padding) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row_with_single_row) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -1350,34 +1404,38 @@ TEST(YogaTest, align_content_stretch_row_with_single_row) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row_with_fixed_height) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 60);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -1445,34 +1503,38 @@ TEST(YogaTest, align_content_stretch_row_with_fixed_height) {
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row_with_max_height) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetMaxHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -1540,34 +1602,38 @@ TEST(YogaTest, align_content_stretch_row_with_max_height) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row_with_min_height) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetMinHeight(root_child1, 80);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -1635,41 +1701,45 @@ TEST(YogaTest, align_content_stretch_row_with_min_height) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_column) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 150);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0_child0, 1);
YGNodeStyleSetFlexShrink(root_child0_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0_child0, 0);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetFlexShrink(root_child1, 1);
YGNodeStyleSetFlexBasisPercent(root_child1, 0);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -1747,13 +1817,17 @@ TEST(YogaTest, align_content_stretch_column) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_is_not_overriding_align_items) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root_child0, YGAlignStretch);
YGNodeStyleSetAlignItems(root_child0, YGAlignCenter);
@@ -1761,7 +1835,7 @@ TEST(YogaTest, align_content_stretch_is_not_overriding_align_items) {
YGNodeStyleSetHeight(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignContent(root_child0_child0, YGAlignStretch);
YGNodeStyleSetWidth(root_child0_child0, 10);
YGNodeStyleSetHeight(root_child0_child0, 10);
@@ -1801,4 +1875,6 @@ TEST(YogaTest, align_content_stretch_is_not_overriding_align_items) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}