Add support for space-between and space-around on align-content
Summary: Adds the two missing alignments ```space-between``` and ```space-around``` for ```align-content``` . Those values are a noop on ```align-items``` in order to prevent a breaking changes for an additional enum. Fix #229 Closes https://github.com/facebook/yoga/pull/364 Reviewed By: gkassabli Differential Revision: D4528561 Pulled By: emilsjolander fbshipit-source-id: ea6291b6dd22cef05d9eec03893250d50371236e
This commit is contained in:
committed by
Facebook Github Bot
parent
247aa26d3e
commit
6a7ad2125d
@@ -19,8 +19,9 @@ public class YGAlignContentTest {
|
||||
@Test
|
||||
public void test_align_content_flex_start() {
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
root.setWrap(YogaWrap.WRAP);
|
||||
root.setWidth(100f);
|
||||
root.setWidth(130f);
|
||||
root.setHeight(100f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
@@ -52,7 +53,7 @@ public class YGAlignContentTest {
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(130f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
@@ -60,23 +61,23 @@ public class YGAlignContentTest {
|
||||
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(10f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(40f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(20f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
|
||||
|
||||
@@ -85,31 +86,31 @@ public class YGAlignContentTest {
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(130f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(80f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(10f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(30f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(10f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(40f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(80f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(20f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
@@ -117,9 +118,10 @@ public class YGAlignContentTest {
|
||||
@Test
|
||||
public void test_align_content_flex_end() {
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
root.setAlignContent(YogaAlign.FLEX_END);
|
||||
root.setWrap(YogaWrap.WRAP);
|
||||
root.setWidth(100f);
|
||||
root.setWidth(130f);
|
||||
root.setHeight(100f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
@@ -151,31 +153,31 @@ public class YGAlignContentTest {
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(130f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(70f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(70f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(80f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(80f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(40f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(90f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
|
||||
|
||||
@@ -184,31 +186,31 @@ public class YGAlignContentTest {
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(130f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(70f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(70f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(80f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(80f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(30f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(80f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(40f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(80f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(90f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
@@ -216,9 +218,10 @@ public class YGAlignContentTest {
|
||||
@Test
|
||||
public void test_align_content_center() {
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
root.setAlignContent(YogaAlign.CENTER);
|
||||
root.setWrap(YogaWrap.WRAP);
|
||||
root.setWidth(100f);
|
||||
root.setWidth(130f);
|
||||
root.setHeight(100f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
@@ -250,31 +253,31 @@ public class YGAlignContentTest {
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(130f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(35f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(35f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(45f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(45f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(40f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(55f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
|
||||
|
||||
@@ -283,31 +286,31 @@ public class YGAlignContentTest {
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(130f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(35f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(35f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(80f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(45f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(30f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(45f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(40f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(80f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(55f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
@@ -317,7 +320,7 @@ public class YGAlignContentTest {
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setAlignContent(YogaAlign.STRETCH);
|
||||
root.setWrap(YogaWrap.WRAP);
|
||||
root.setWidth(100f);
|
||||
root.setWidth(150f);
|
||||
root.setHeight(100f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
@@ -344,7 +347,7 @@ public class YGAlignContentTest {
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(150f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
@@ -377,33 +380,233 @@ public class YGAlignContentTest {
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(150f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(100f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(100f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(100f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(100f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0f, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(100f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0f, root_child4.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_align_content_spacebetween() {
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
root.setAlignContent(YogaAlign.SPACE_BETWEEN);
|
||||
root.setWrap(YogaWrap.WRAP);
|
||||
root.setWidth(130f);
|
||||
root.setHeight(100f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
root_child0.setWidth(50f);
|
||||
root_child0.setHeight(10f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode();
|
||||
root_child1.setWidth(50f);
|
||||
root_child1.setHeight(10f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final YogaNode root_child2 = new YogaNode();
|
||||
root_child2.setWidth(50f);
|
||||
root_child2.setHeight(10f);
|
||||
root.addChildAt(root_child2, 2);
|
||||
|
||||
final YogaNode root_child3 = new YogaNode();
|
||||
root_child3.setWidth(50f);
|
||||
root_child3.setHeight(10f);
|
||||
root.addChildAt(root_child3, 3);
|
||||
|
||||
final YogaNode root_child4 = new YogaNode();
|
||||
root_child4.setWidth(50f);
|
||||
root_child4.setHeight(10f);
|
||||
root.addChildAt(root_child4, 4);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(130f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(45f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(45f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(90f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(130f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(45f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(30f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(45f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(90f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_align_content_spacearound() {
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
root.setAlignContent(YogaAlign.SPACE_AROUND);
|
||||
root.setWrap(YogaWrap.WRAP);
|
||||
root.setWidth(140f);
|
||||
root.setHeight(120f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
root_child0.setWidth(50f);
|
||||
root_child0.setHeight(10f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode();
|
||||
root_child1.setWidth(50f);
|
||||
root_child1.setHeight(10f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final YogaNode root_child2 = new YogaNode();
|
||||
root_child2.setWidth(50f);
|
||||
root_child2.setHeight(10f);
|
||||
root.addChildAt(root_child2, 2);
|
||||
|
||||
final YogaNode root_child3 = new YogaNode();
|
||||
root_child3.setWidth(50f);
|
||||
root_child3.setHeight(10f);
|
||||
root.addChildAt(root_child3, 3);
|
||||
|
||||
final YogaNode root_child4 = new YogaNode();
|
||||
root_child4.setWidth(50f);
|
||||
root_child4.setHeight(10f);
|
||||
root.addChildAt(root_child4, 4);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(140f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(120f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(15f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(15f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(55f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(55f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(95f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(140f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(120f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(90f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(15f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(40f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(15f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(90f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(55f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(40f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(55f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(90f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(95f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user