@@ -973,4 +973,83 @@ public void test_percentage_width_height_undefined_parent_size() {
973973 assertEquals (0f , root_child0 .getLayoutHeight (), 0.0f );
974974 }
975975
976+ @ Test
977+ public void test_percent_within_flex_grow () {
978+ final YogaNode root = new YogaNode ();
979+ root .setFlexDirection (YogaFlexDirection .ROW );
980+ root .setWidth (350f );
981+ root .setHeight (100f );
982+
983+ final YogaNode root_child0 = new YogaNode ();
984+ root_child0 .setWidth (100f );
985+ root .addChildAt (root_child0 , 0 );
986+
987+ final YogaNode root_child1 = new YogaNode ();
988+ root_child1 .setFlexGrow (1f );
989+ root .addChildAt (root_child1 , 1 );
990+
991+ final YogaNode root_child1_child0 = new YogaNode ();
992+ root_child1_child0 .setWidthPercent (100f );
993+ root_child1 .addChildAt (root_child1_child0 , 0 );
994+
995+ final YogaNode root_child2 = new YogaNode ();
996+ root_child2 .setWidth (100f );
997+ root .addChildAt (root_child2 , 2 );
998+ root .setDirection (YogaDirection .LTR );
999+ root .calculateLayout (YogaConstants .UNDEFINED , YogaConstants .UNDEFINED );
1000+
1001+ assertEquals (0f , root .getLayoutX (), 0.0f );
1002+ assertEquals (0f , root .getLayoutY (), 0.0f );
1003+ assertEquals (350f , root .getLayoutWidth (), 0.0f );
1004+ assertEquals (100f , root .getLayoutHeight (), 0.0f );
1005+
1006+ assertEquals (0f , root_child0 .getLayoutX (), 0.0f );
1007+ assertEquals (0f , root_child0 .getLayoutY (), 0.0f );
1008+ assertEquals (100f , root_child0 .getLayoutWidth (), 0.0f );
1009+ assertEquals (100f , root_child0 .getLayoutHeight (), 0.0f );
1010+
1011+ assertEquals (100f , root_child1 .getLayoutX (), 0.0f );
1012+ assertEquals (0f , root_child1 .getLayoutY (), 0.0f );
1013+ assertEquals (150f , root_child1 .getLayoutWidth (), 0.0f );
1014+ assertEquals (100f , root_child1 .getLayoutHeight (), 0.0f );
1015+
1016+ assertEquals (0f , root_child1_child0 .getLayoutX (), 0.0f );
1017+ assertEquals (0f , root_child1_child0 .getLayoutY (), 0.0f );
1018+ assertEquals (150f , root_child1_child0 .getLayoutWidth (), 0.0f );
1019+ assertEquals (0f , root_child1_child0 .getLayoutHeight (), 0.0f );
1020+
1021+ assertEquals (250f , root_child2 .getLayoutX (), 0.0f );
1022+ assertEquals (0f , root_child2 .getLayoutY (), 0.0f );
1023+ assertEquals (100f , root_child2 .getLayoutWidth (), 0.0f );
1024+ assertEquals (100f , root_child2 .getLayoutHeight (), 0.0f );
1025+
1026+ root .setDirection (YogaDirection .RTL );
1027+ root .calculateLayout (YogaConstants .UNDEFINED , YogaConstants .UNDEFINED );
1028+
1029+ assertEquals (0f , root .getLayoutX (), 0.0f );
1030+ assertEquals (0f , root .getLayoutY (), 0.0f );
1031+ assertEquals (350f , root .getLayoutWidth (), 0.0f );
1032+ assertEquals (100f , root .getLayoutHeight (), 0.0f );
1033+
1034+ assertEquals (250f , root_child0 .getLayoutX (), 0.0f );
1035+ assertEquals (0f , root_child0 .getLayoutY (), 0.0f );
1036+ assertEquals (100f , root_child0 .getLayoutWidth (), 0.0f );
1037+ assertEquals (100f , root_child0 .getLayoutHeight (), 0.0f );
1038+
1039+ assertEquals (100f , root_child1 .getLayoutX (), 0.0f );
1040+ assertEquals (0f , root_child1 .getLayoutY (), 0.0f );
1041+ assertEquals (150f , root_child1 .getLayoutWidth (), 0.0f );
1042+ assertEquals (100f , root_child1 .getLayoutHeight (), 0.0f );
1043+
1044+ assertEquals (0f , root_child1_child0 .getLayoutX (), 0.0f );
1045+ assertEquals (0f , root_child1_child0 .getLayoutY (), 0.0f );
1046+ assertEquals (150f , root_child1_child0 .getLayoutWidth (), 0.0f );
1047+ assertEquals (0f , root_child1_child0 .getLayoutHeight (), 0.0f );
1048+
1049+ assertEquals (0f , root_child2 .getLayoutX (), 0.0f );
1050+ assertEquals (0f , root_child2 .getLayoutY (), 0.0f );
1051+ assertEquals (100f , root_child2 .getLayoutWidth (), 0.0f );
1052+ assertEquals (100f , root_child2 .getLayoutHeight (), 0.0f );
1053+ }
1054+
9761055}
0 commit comments