gentest support for position: static + initial test

Summary:
I am about to embark on supporting `position: static` in Yoga. The enum exists already (and is the default position type, lol) but does not actually do anything and just behaves like `position: relative`.

My approach here is to write a bunch of tests to test for the various behaviors of static positions and then develop on Yoga afterwards to get those tests passing. To do this, we need to make a few changes to the gentest files as there is not support for adding `position: static` at the moment:

* Make it so that the gentest code can physically write `YGPositionTypeStatic` if it encounters `position: static` in the style
* Make it so that gentest.js knows that Yoga's default is actually static. This way the code generated in the tests will actually label nodes for non default values
* Explicitly label the position type even when it is not declared in the style prop (with the exception of the default)
* Regenerate all the tests

Additionally I added the first, basic test: making sure insets do nothing on a statically positioned element.

Reviewed By: NickGerleman

Differential Revision: D50437855

fbshipit-source-id: 0e8bbf1c224d477ea4592b7563d0b70d2ffa79c8
This commit is contained in:
Joe Vilches
2023-10-23 18:20:24 -07:00
committed by Facebook GitHub Bot
parent 7e91004b90
commit 2ea4c043fd
70 changed files with 3824 additions and 88 deletions

View File

@@ -17,18 +17,22 @@ TEST(YogaTest, rounding_flex_basis_flex_grow_row_width_of_100) {
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child2, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -86,26 +90,32 @@ TEST(YogaTest, rounding_flex_basis_flex_grow_row_prime_number_width) {
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root, 113);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child2, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child3, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child3, 1);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child4, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child4, 1);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -183,19 +193,23 @@ TEST(YogaTest, rounding_flex_basis_flex_shrink_row) {
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root, 101);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative);
YGNodeStyleSetFlexShrink(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1, YGPositionTypeRelative);
YGNodeStyleSetFlexBasis(root_child1, 25);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child2, YGPositionTypeRelative);
YGNodeStyleSetFlexBasis(root_child2, 25);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -252,21 +266,25 @@ TEST(YogaTest, rounding_flex_basis_overrides_main_size) {
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 113);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 20);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child2, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
@@ -324,21 +342,25 @@ TEST(YogaTest, rounding_total_fractial) {
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root, 87.4f);
YGNodeStyleSetHeight(root, 113.4f);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child0, 0.7f);
YGNodeStyleSetFlexBasis(root_child0, 50.3f);
YGNodeStyleSetHeight(root_child0, 20.3f);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child1, 1.6f);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child2, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child2, 1.1f);
YGNodeStyleSetHeight(root_child2, 10.7f);
YGNodeInsertChild(root, root_child2, 2);
@@ -396,16 +418,19 @@ TEST(YogaTest, rounding_total_fractial_nested) {
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root, 87.4f);
YGNodeStyleSetHeight(root, 113.4f);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child0, 0.7f);
YGNodeStyleSetFlexBasis(root_child0, 50.3f);
YGNodeStyleSetHeight(root_child0, 20.3f);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child0_child0, 1);
YGNodeStyleSetFlexBasis(root_child0_child0, 0.3f);
YGNodeStyleSetPosition(root_child0_child0, YGEdgeBottom, 13.3f);
@@ -413,6 +438,7 @@ TEST(YogaTest, rounding_total_fractial_nested) {
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child0_child1, 4);
YGNodeStyleSetFlexBasis(root_child0_child1, 0.3f);
YGNodeStyleSetPosition(root_child0_child1, YGEdgeTop, 13.3f);
@@ -420,11 +446,13 @@ TEST(YogaTest, rounding_total_fractial_nested) {
YGNodeInsertChild(root_child0, root_child0_child1, 1);
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child1, 1.6f);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child2, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child2, 1.1f);
YGNodeStyleSetHeight(root_child2, 10.7f);
YGNodeInsertChild(root, root_child2, 2);
@@ -502,21 +530,25 @@ TEST(YogaTest, rounding_fractial_input_1) {
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 113.4f);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 20);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child2, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
@@ -574,21 +606,25 @@ TEST(YogaTest, rounding_fractial_input_2) {
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 113.6f);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 20);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child2, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
@@ -646,22 +682,26 @@ TEST(YogaTest, rounding_fractial_input_3) {
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root, YGEdgeTop, 0.3f);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 113.4f);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 20);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child2, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
@@ -719,22 +759,26 @@ TEST(YogaTest, rounding_fractial_input_4) {
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root, YGEdgeTop, 0.7f);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 113.4f);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 20);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child2, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
@@ -793,24 +837,29 @@ TEST(YogaTest, rounding_inner_node_controversy_horizontal) {
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root, 320);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1_child0, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child1_child0, 1);
YGNodeStyleSetHeight(root_child1_child0, 10);
YGNodeInsertChild(root_child1, root_child1_child0, 0);
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child2, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
@@ -878,24 +927,29 @@ TEST(YogaTest, rounding_inner_node_controversy_vertical) {
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
YGNodeStyleSetHeight(root, 320);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetWidth(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1_child0, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child1_child0, 1);
YGNodeStyleSetWidth(root_child1_child0, 10);
YGNodeInsertChild(root_child1, root_child1_child0, 0);
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child2, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeStyleSetWidth(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
@@ -964,40 +1018,48 @@ TEST(YogaTest, rounding_inner_node_controversy_combined) {
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root, 640);
YGNodeStyleSetHeight(root, 320);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetHeightPercent(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetHeightPercent(root_child1, 100);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1_child0, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child1_child0, 1);
YGNodeStyleSetWidthPercent(root_child1_child0, 100);
YGNodeInsertChild(root_child1, root_child1_child0, 0);
const YGNodeRef root_child1_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1_child1, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child1_child1, 1);
YGNodeStyleSetWidthPercent(root_child1_child1, 100);
YGNodeInsertChild(root_child1, root_child1_child1, 1);
const YGNodeRef root_child1_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1_child1_child0, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child1_child1_child0, 1);
YGNodeStyleSetWidthPercent(root_child1_child1_child0, 100);
YGNodeInsertChild(root_child1_child1, root_child1_child1_child0, 0);
const YGNodeRef root_child1_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1_child2, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child1_child2, 1);
YGNodeStyleSetWidthPercent(root_child1_child2, 100);
YGNodeInsertChild(root_child1, root_child1_child2, 2);
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child2, YGPositionTypeRelative);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeStyleSetHeightPercent(root_child2, 100);
YGNodeInsertChild(root, root_child2, 2);