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,26 +13,28 @@
#include <yoga/Yoga.h>
TEST(YogaTest, wrap_column) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 30);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 30);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 30);
YGNodeInsertChild(root, root_child3, 3);
@@ -91,30 +93,34 @@ TEST(YogaTest, wrap_column) {
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_row) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 30);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 30);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 30);
YGNodeInsertChild(root, root_child3, 3);
@@ -173,31 +179,35 @@ TEST(YogaTest, wrap_row) {
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_row_align_items_flex_end) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignFlexEnd);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 30);
YGNodeInsertChild(root, root_child3, 3);
@@ -256,31 +266,35 @@ TEST(YogaTest, wrap_row_align_items_flex_end) {
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_row_align_items_center) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 30);
YGNodeInsertChild(root, root_child3, 3);
@@ -339,21 +353,25 @@ TEST(YogaTest, wrap_row_align_items_center) {
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_wrap_children_with_min_main_overriding_flex_basis) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeStyleSetMinWidth(root_child0, 55);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexBasis(root_child1, 50);
YGNodeStyleSetMinWidth(root_child1, 55);
YGNodeStyleSetHeight(root_child1, 50);
@@ -393,27 +411,31 @@ TEST(YogaTest, flex_wrap_children_with_min_main_overriding_flex_basis) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_wrap_wrap_to_child_height) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root_child0, YGAlignFlexStart);
YGNodeStyleSetFlexWrap(root_child0, YGWrapWrap);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0, 100);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child0_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0_child0, 100);
YGNodeStyleSetHeight(root_child0_child0_child0, 100);
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 100);
YGNodeStyleSetHeight(root_child1, 100);
YGNodeInsertChild(root, root_child1, 1);
@@ -472,20 +494,24 @@ TEST(YogaTest, flex_wrap_wrap_to_child_height) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_wrap_align_stretch_fits_one_row) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
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);
@@ -523,35 +549,39 @@ TEST(YogaTest, flex_wrap_align_stretch_fits_one_row) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_reverse_row_align_content_flex_start) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root, YGWrapWrapReverse);
YGNodeStyleSetWidth(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 40);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 30);
YGNodeStyleSetHeight(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
@@ -620,36 +650,40 @@ TEST(YogaTest, wrap_reverse_row_align_content_flex_start) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_reverse_row_align_content_center) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignCenter);
YGNodeStyleSetFlexWrap(root, YGWrapWrapReverse);
YGNodeStyleSetWidth(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 40);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 30);
YGNodeStyleSetHeight(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
@@ -718,35 +752,39 @@ TEST(YogaTest, wrap_reverse_row_align_content_center) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_reverse_row_single_line_different_size) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root, YGWrapWrapReverse);
YGNodeStyleSetWidth(root, 300);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 40);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 30);
YGNodeStyleSetHeight(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
@@ -815,36 +853,40 @@ TEST(YogaTest, wrap_reverse_row_single_line_different_size) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_reverse_row_align_content_stretch) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrapReverse);
YGNodeStyleSetWidth(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 40);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 30);
YGNodeStyleSetHeight(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
@@ -913,36 +955,40 @@ TEST(YogaTest, wrap_reverse_row_align_content_stretch) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_reverse_row_align_content_space_around) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignSpaceAround);
YGNodeStyleSetFlexWrap(root, YGWrapWrapReverse);
YGNodeStyleSetWidth(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 40);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 30);
YGNodeStyleSetHeight(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
@@ -1011,36 +1057,40 @@ TEST(YogaTest, wrap_reverse_row_align_content_space_around) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_reverse_column_fixed_size) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetFlexWrap(root, YGWrapWrapReverse);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 40);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 30);
YGNodeStyleSetHeight(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
@@ -1109,25 +1159,29 @@ TEST(YogaTest, wrap_reverse_column_fixed_size) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrapped_row_within_align_items_center) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root_child0, YGWrapWrap);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0, 150);
YGNodeStyleSetHeight(root_child0_child0, 80);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child0_child1 = YGNodeNew();
const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child1, 80);
YGNodeStyleSetHeight(root_child0_child1, 80);
YGNodeInsertChild(root_child0, root_child0_child1, 1);
@@ -1176,25 +1230,29 @@ TEST(YogaTest, wrapped_row_within_align_items_center) {
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrapped_row_within_align_items_flex_start) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root_child0, YGWrapWrap);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0, 150);
YGNodeStyleSetHeight(root_child0_child0, 80);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child0_child1 = YGNodeNew();
const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child1, 80);
YGNodeStyleSetHeight(root_child0_child1, 80);
YGNodeInsertChild(root_child0, root_child0_child1, 1);
@@ -1243,25 +1301,29 @@ TEST(YogaTest, wrapped_row_within_align_items_flex_start) {
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrapped_row_within_align_items_flex_end) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignFlexEnd);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root_child0, YGWrapWrap);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0, 150);
YGNodeStyleSetHeight(root_child0_child0, 80);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child0_child1 = YGNodeNew();
const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child1, 80);
YGNodeStyleSetHeight(root_child0_child1, 80);
YGNodeInsertChild(root_child0, root_child0_child1, 1);
@@ -1310,4 +1372,6 @@ TEST(YogaTest, wrapped_row_within_align_items_flex_end) {
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}