@@ -1589,6 +1589,73 @@ public void test_column_gap_wrap_align_stretch() {
15891589 assertEquals (150f , root_child4 .getLayoutHeight (), 0.0f );
15901590 }
15911591
1592+ @ Test
1593+ public void test_column_gap_determines_parent_width () {
1594+ YogaConfig config = YogaConfigFactory .create ();
1595+
1596+ final YogaNode root = createNode (config );
1597+ root .setFlexDirection (YogaFlexDirection .ROW );
1598+ root .setHeight (100f );
1599+ root .setGap (YogaGutter .COLUMN , 10f );
1600+
1601+ final YogaNode root_child0 = createNode (config );
1602+ root_child0 .setWidth (10f );
1603+ root .addChildAt (root_child0 , 0 );
1604+
1605+ final YogaNode root_child1 = createNode (config );
1606+ root_child1 .setWidth (20f );
1607+ root .addChildAt (root_child1 , 1 );
1608+
1609+ final YogaNode root_child2 = createNode (config );
1610+ root_child2 .setWidth (30f );
1611+ root .addChildAt (root_child2 , 2 );
1612+ root .setDirection (YogaDirection .LTR );
1613+ root .calculateLayout (YogaConstants .UNDEFINED , YogaConstants .UNDEFINED );
1614+
1615+ assertEquals (0f , root .getLayoutX (), 0.0f );
1616+ assertEquals (0f , root .getLayoutY (), 0.0f );
1617+ assertEquals (80f , root .getLayoutWidth (), 0.0f );
1618+ assertEquals (100f , root .getLayoutHeight (), 0.0f );
1619+
1620+ assertEquals (0f , root_child0 .getLayoutX (), 0.0f );
1621+ assertEquals (0f , root_child0 .getLayoutY (), 0.0f );
1622+ assertEquals (10f , root_child0 .getLayoutWidth (), 0.0f );
1623+ assertEquals (100f , root_child0 .getLayoutHeight (), 0.0f );
1624+
1625+ assertEquals (20f , root_child1 .getLayoutX (), 0.0f );
1626+ assertEquals (0f , root_child1 .getLayoutY (), 0.0f );
1627+ assertEquals (20f , root_child1 .getLayoutWidth (), 0.0f );
1628+ assertEquals (100f , root_child1 .getLayoutHeight (), 0.0f );
1629+
1630+ assertEquals (50f , root_child2 .getLayoutX (), 0.0f );
1631+ assertEquals (0f , root_child2 .getLayoutY (), 0.0f );
1632+ assertEquals (30f , root_child2 .getLayoutWidth (), 0.0f );
1633+ assertEquals (100f , root_child2 .getLayoutHeight (), 0.0f );
1634+
1635+ root .setDirection (YogaDirection .RTL );
1636+ root .calculateLayout (YogaConstants .UNDEFINED , YogaConstants .UNDEFINED );
1637+
1638+ assertEquals (0f , root .getLayoutX (), 0.0f );
1639+ assertEquals (0f , root .getLayoutY (), 0.0f );
1640+ assertEquals (80f , root .getLayoutWidth (), 0.0f );
1641+ assertEquals (100f , root .getLayoutHeight (), 0.0f );
1642+
1643+ assertEquals (70f , root_child0 .getLayoutX (), 0.0f );
1644+ assertEquals (0f , root_child0 .getLayoutY (), 0.0f );
1645+ assertEquals (10f , root_child0 .getLayoutWidth (), 0.0f );
1646+ assertEquals (100f , root_child0 .getLayoutHeight (), 0.0f );
1647+
1648+ assertEquals (40f , root_child1 .getLayoutX (), 0.0f );
1649+ assertEquals (0f , root_child1 .getLayoutY (), 0.0f );
1650+ assertEquals (20f , root_child1 .getLayoutWidth (), 0.0f );
1651+ assertEquals (100f , root_child1 .getLayoutHeight (), 0.0f );
1652+
1653+ assertEquals (0f , root_child2 .getLayoutX (), 0.0f );
1654+ assertEquals (0f , root_child2 .getLayoutY (), 0.0f );
1655+ assertEquals (30f , root_child2 .getLayoutWidth (), 0.0f );
1656+ assertEquals (100f , root_child2 .getLayoutHeight (), 0.0f );
1657+ }
1658+
15921659 @ Test
15931660 public void test_row_gap_align_items_stretch () {
15941661 YogaConfig config = YogaConfigFactory .create ();
@@ -1969,6 +2036,72 @@ public void test_row_gap_row_wrap_child_margins() {
19692036 assertEquals (0f , root_child2 .getLayoutHeight (), 0.0f );
19702037 }
19712038
2039+ @ Test
2040+ public void test_row_gap_determines_parent_height () {
2041+ YogaConfig config = YogaConfigFactory .create ();
2042+
2043+ final YogaNode root = createNode (config );
2044+ root .setWidth (100f );
2045+ root .setGap (YogaGutter .ROW , 10f );
2046+
2047+ final YogaNode root_child0 = createNode (config );
2048+ root_child0 .setHeight (10f );
2049+ root .addChildAt (root_child0 , 0 );
2050+
2051+ final YogaNode root_child1 = createNode (config );
2052+ root_child1 .setHeight (20f );
2053+ root .addChildAt (root_child1 , 1 );
2054+
2055+ final YogaNode root_child2 = createNode (config );
2056+ root_child2 .setHeight (30f );
2057+ root .addChildAt (root_child2 , 2 );
2058+ root .setDirection (YogaDirection .LTR );
2059+ root .calculateLayout (YogaConstants .UNDEFINED , YogaConstants .UNDEFINED );
2060+
2061+ assertEquals (0f , root .getLayoutX (), 0.0f );
2062+ assertEquals (0f , root .getLayoutY (), 0.0f );
2063+ assertEquals (100f , root .getLayoutWidth (), 0.0f );
2064+ assertEquals (80f , root .getLayoutHeight (), 0.0f );
2065+
2066+ assertEquals (0f , root_child0 .getLayoutX (), 0.0f );
2067+ assertEquals (0f , root_child0 .getLayoutY (), 0.0f );
2068+ assertEquals (100f , root_child0 .getLayoutWidth (), 0.0f );
2069+ assertEquals (10f , root_child0 .getLayoutHeight (), 0.0f );
2070+
2071+ assertEquals (0f , root_child1 .getLayoutX (), 0.0f );
2072+ assertEquals (20f , root_child1 .getLayoutY (), 0.0f );
2073+ assertEquals (100f , root_child1 .getLayoutWidth (), 0.0f );
2074+ assertEquals (20f , root_child1 .getLayoutHeight (), 0.0f );
2075+
2076+ assertEquals (0f , root_child2 .getLayoutX (), 0.0f );
2077+ assertEquals (50f , root_child2 .getLayoutY (), 0.0f );
2078+ assertEquals (100f , root_child2 .getLayoutWidth (), 0.0f );
2079+ assertEquals (30f , root_child2 .getLayoutHeight (), 0.0f );
2080+
2081+ root .setDirection (YogaDirection .RTL );
2082+ root .calculateLayout (YogaConstants .UNDEFINED , YogaConstants .UNDEFINED );
2083+
2084+ assertEquals (0f , root .getLayoutX (), 0.0f );
2085+ assertEquals (0f , root .getLayoutY (), 0.0f );
2086+ assertEquals (100f , root .getLayoutWidth (), 0.0f );
2087+ assertEquals (80f , root .getLayoutHeight (), 0.0f );
2088+
2089+ assertEquals (0f , root_child0 .getLayoutX (), 0.0f );
2090+ assertEquals (0f , root_child0 .getLayoutY (), 0.0f );
2091+ assertEquals (100f , root_child0 .getLayoutWidth (), 0.0f );
2092+ assertEquals (10f , root_child0 .getLayoutHeight (), 0.0f );
2093+
2094+ assertEquals (0f , root_child1 .getLayoutX (), 0.0f );
2095+ assertEquals (20f , root_child1 .getLayoutY (), 0.0f );
2096+ assertEquals (100f , root_child1 .getLayoutWidth (), 0.0f );
2097+ assertEquals (20f , root_child1 .getLayoutHeight (), 0.0f );
2098+
2099+ assertEquals (0f , root_child2 .getLayoutX (), 0.0f );
2100+ assertEquals (50f , root_child2 .getLayoutY (), 0.0f );
2101+ assertEquals (100f , root_child2 .getLayoutWidth (), 0.0f );
2102+ assertEquals (30f , root_child2 .getLayoutHeight (), 0.0f );
2103+ }
2104+
19722105 private YogaNode createNode (YogaConfig config ) {
19732106 return mNodeFactory .create (config );
19742107 }
0 commit comments