2022-10-13 08:18:49 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// @Generated by gentest/gentest.rb from gentest/fixtures/YGGapTest.html
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
namespace Facebook.Yoga
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public class YGGapTest
|
|
|
|
{
|
|
|
|
[Test]
|
|
|
|
public void Test_column_gap_flexable()
|
|
|
|
{
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
|
|
root.Width = 80;
|
|
|
|
root.Height = 100;
|
|
|
|
root.ColumnGap = 10;
|
|
|
|
root.RowGap = 20;
|
|
|
|
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
|
|
root_child0.FlexGrow = 1;
|
|
|
|
root_child0.FlexShrink = 1;
|
|
|
|
root_child0.FlexBasis = 0.Percent();
|
|
|
|
root.Insert(0, root_child0);
|
|
|
|
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
|
|
root_child1.FlexGrow = 1;
|
|
|
|
root_child1.FlexShrink = 1;
|
|
|
|
root_child1.FlexBasis = 0.Percent();
|
|
|
|
root.Insert(1, root_child1);
|
|
|
|
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
|
|
root_child2.FlexGrow = 1;
|
|
|
|
root_child2.FlexShrink = 1;
|
|
|
|
root_child2.FlexBasis = 0.Percent();
|
|
|
|
root.Insert(2, root_child2);
|
|
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(80f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(80f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_column_gap_inflexbale()
|
|
|
|
{
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
|
|
root.Width = 80;
|
|
|
|
root.Height = 100;
|
|
|
|
root.ColumnGap = 10;
|
|
|
|
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
|
|
root_child0.Width = 20;
|
|
|
|
root.Insert(0, root_child0);
|
|
|
|
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
|
|
root_child1.Width = 20;
|
|
|
|
root.Insert(1, root_child1);
|
|
|
|
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
|
|
root_child2.Width = 20;
|
|
|
|
root.Insert(2, root_child2);
|
|
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(80f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(80f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_column_gap_mixed_flexable()
|
|
|
|
{
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
|
|
root.Width = 80;
|
|
|
|
root.Height = 100;
|
|
|
|
root.ColumnGap = 10;
|
|
|
|
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
|
|
root_child0.Width = 20;
|
|
|
|
root.Insert(0, root_child0);
|
|
|
|
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
|
|
root_child1.FlexGrow = 1;
|
|
|
|
root_child1.FlexShrink = 1;
|
|
|
|
root_child1.FlexBasis = 0.Percent();
|
|
|
|
root.Insert(1, root_child1);
|
|
|
|
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
|
|
root_child2.Width = 20;
|
|
|
|
root.Insert(2, root_child2);
|
|
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(80f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(80f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_column_row_gap_wrapping()
|
|
|
|
{
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
|
|
root.Wrap = YogaWrap.Wrap;
|
|
|
|
root.Width = 80;
|
|
|
|
root.ColumnGap = 10;
|
|
|
|
root.RowGap = 20;
|
|
|
|
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
|
|
root_child0.Width = 20;
|
|
|
|
root_child0.Height = 20;
|
|
|
|
root.Insert(0, root_child0);
|
|
|
|
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
|
|
root_child1.Width = 20;
|
|
|
|
root_child1.Height = 20;
|
|
|
|
root.Insert(1, root_child1);
|
|
|
|
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
|
|
root_child2.Width = 20;
|
|
|
|
root_child2.Height = 20;
|
|
|
|
root.Insert(2, root_child2);
|
|
|
|
|
|
|
|
YogaNode root_child3 = new YogaNode(config);
|
|
|
|
root_child3.Width = 20;
|
|
|
|
root_child3.Height = 20;
|
|
|
|
root.Insert(3, root_child3);
|
|
|
|
|
|
|
|
YogaNode root_child4 = new YogaNode(config);
|
|
|
|
root_child4.Width = 20;
|
|
|
|
root_child4.Height = 20;
|
|
|
|
root.Insert(4, root_child4);
|
|
|
|
|
|
|
|
YogaNode root_child5 = new YogaNode(config);
|
|
|
|
root_child5.Width = 20;
|
|
|
|
root_child5.Height = 20;
|
|
|
|
root.Insert(5, root_child5);
|
|
|
|
|
|
|
|
YogaNode root_child6 = new YogaNode(config);
|
|
|
|
root_child6.Width = 20;
|
|
|
|
root_child6.Height = 20;
|
|
|
|
root.Insert(6, root_child6);
|
|
|
|
|
|
|
|
YogaNode root_child7 = new YogaNode(config);
|
|
|
|
root_child7.Width = 20;
|
|
|
|
root_child7.Height = 20;
|
|
|
|
root.Insert(7, root_child7);
|
|
|
|
|
|
|
|
YogaNode root_child8 = new YogaNode(config);
|
|
|
|
root_child8.Width = 20;
|
|
|
|
root_child8.Height = 20;
|
|
|
|
root.Insert(8, root_child8);
|
|
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(80f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child3.LayoutX);
|
|
|
|
Assert.AreEqual(40f, root_child3.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child4.LayoutX);
|
|
|
|
Assert.AreEqual(40f, root_child4.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child5.LayoutX);
|
|
|
|
Assert.AreEqual(40f, root_child5.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child6.LayoutX);
|
|
|
|
Assert.AreEqual(80f, root_child6.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child6.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child6.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child7.LayoutX);
|
|
|
|
Assert.AreEqual(80f, root_child7.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child7.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child7.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child8.LayoutX);
|
|
|
|
Assert.AreEqual(80f, root_child8.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child8.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child8.LayoutHeight);
|
|
|
|
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(80f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child3.LayoutX);
|
|
|
|
Assert.AreEqual(40f, root_child3.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child4.LayoutX);
|
|
|
|
Assert.AreEqual(40f, root_child4.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child5.LayoutX);
|
|
|
|
Assert.AreEqual(40f, root_child5.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child6.LayoutX);
|
|
|
|
Assert.AreEqual(80f, root_child6.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child6.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child6.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child7.LayoutX);
|
|
|
|
Assert.AreEqual(80f, root_child7.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child7.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child7.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child8.LayoutX);
|
|
|
|
Assert.AreEqual(80f, root_child8.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child8.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child8.LayoutHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_column_gap_justify_flex_start()
|
|
|
|
{
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
|
|
root.Width = 100;
|
|
|
|
root.Height = 100;
|
|
|
|
root.ColumnGap = 10;
|
|
|
|
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
|
|
root_child0.Width = 20;
|
|
|
|
root.Insert(0, root_child0);
|
|
|
|
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
|
|
root_child1.Width = 20;
|
|
|
|
root.Insert(1, root_child1);
|
|
|
|
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
|
|
root_child2.Width = 20;
|
|
|
|
root.Insert(2, root_child2);
|
|
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(80f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(50f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_column_gap_justify_center()
|
|
|
|
{
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
|
|
root.JustifyContent = YogaJustify.Center;
|
|
|
|
root.Width = 100;
|
|
|
|
root.Height = 100;
|
|
|
|
root.ColumnGap = 10;
|
|
|
|
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
|
|
root_child0.Width = 20;
|
|
|
|
root.Insert(0, root_child0);
|
|
|
|
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
|
|
root_child1.Width = 20;
|
|
|
|
root.Insert(1, root_child1);
|
|
|
|
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
|
|
root_child2.Width = 20;
|
|
|
|
root.Insert(2, root_child2);
|
|
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(10f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(40f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(70f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(70f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(40f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(10f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_column_gap_justify_flex_end()
|
|
|
|
{
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
|
|
root.JustifyContent = YogaJustify.FlexEnd;
|
|
|
|
root.Width = 100;
|
|
|
|
root.Height = 100;
|
|
|
|
root.ColumnGap = 10;
|
|
|
|
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
|
|
root_child0.Width = 20;
|
|
|
|
root.Insert(0, root_child0);
|
|
|
|
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
|
|
root_child1.Width = 20;
|
|
|
|
root.Insert(1, root_child1);
|
|
|
|
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
|
|
root_child2.Width = 20;
|
|
|
|
root.Insert(2, root_child2);
|
|
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(50f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(80f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_column_gap_justify_space_between()
|
|
|
|
{
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
|
|
root.JustifyContent = YogaJustify.SpaceBetween;
|
|
|
|
root.Width = 100;
|
|
|
|
root.Height = 100;
|
|
|
|
root.ColumnGap = 10;
|
|
|
|
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
|
|
root_child0.Width = 20;
|
|
|
|
root.Insert(0, root_child0);
|
|
|
|
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
|
|
root_child1.Width = 20;
|
|
|
|
root.Insert(1, root_child1);
|
|
|
|
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
|
|
root_child2.Width = 20;
|
|
|
|
root.Insert(2, root_child2);
|
|
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(40f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(80f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(80f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(40f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_column_gap_justify_space_around()
|
|
|
|
{
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
|
|
root.JustifyContent = YogaJustify.SpaceAround;
|
|
|
|
root.Width = 100;
|
|
|
|
root.Height = 100;
|
|
|
|
root.ColumnGap = 10;
|
|
|
|
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
|
|
root_child0.Width = 20;
|
|
|
|
root.Insert(0, root_child0);
|
|
|
|
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
|
|
root_child1.Width = 20;
|
|
|
|
root.Insert(1, root_child1);
|
|
|
|
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
|
|
root_child2.Width = 20;
|
|
|
|
root.Insert(2, root_child2);
|
|
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(3f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(40f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(77f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(77f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(40f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(3f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_column_gap_justify_space_evenly()
|
|
|
|
{
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
|
|
root.JustifyContent = YogaJustify.SpaceEvenly;
|
|
|
|
root.Width = 100;
|
|
|
|
root.Height = 100;
|
|
|
|
root.ColumnGap = 10;
|
|
|
|
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
|
|
root_child0.Width = 20;
|
|
|
|
root.Insert(0, root_child0);
|
|
|
|
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
|
|
root_child1.Width = 20;
|
|
|
|
root.Insert(1, root_child1);
|
|
|
|
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
|
|
root_child2.Width = 20;
|
|
|
|
root.Insert(2, root_child2);
|
|
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(5f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(40f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(75f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(75f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(40f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(5f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_column_gap_wrap_align_flex_start()
|
|
|
|
{
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
|
|
root.Wrap = YogaWrap.Wrap;
|
|
|
|
root.Width = 100;
|
|
|
|
root.Height = 100;
|
|
|
|
root.ColumnGap = 10;
|
|
|
|
root.RowGap = 20;
|
|
|
|
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
|
|
root_child0.Width = 20;
|
|
|
|
root_child0.Height = 20;
|
|
|
|
root.Insert(0, root_child0);
|
|
|
|
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
|
|
root_child1.Width = 20;
|
|
|
|
root_child1.Height = 20;
|
|
|
|
root.Insert(1, root_child1);
|
|
|
|
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
|
|
root_child2.Width = 20;
|
|
|
|
root_child2.Height = 20;
|
|
|
|
root.Insert(2, root_child2);
|
|
|
|
|
|
|
|
YogaNode root_child3 = new YogaNode(config);
|
|
|
|
root_child3.Width = 20;
|
|
|
|
root_child3.Height = 20;
|
|
|
|
root.Insert(3, root_child3);
|
|
|
|
|
|
|
|
YogaNode root_child4 = new YogaNode(config);
|
|
|
|
root_child4.Width = 20;
|
|
|
|
root_child4.Height = 20;
|
|
|
|
root.Insert(4, root_child4);
|
|
|
|
|
|
|
|
YogaNode root_child5 = new YogaNode(config);
|
|
|
|
root_child5.Width = 20;
|
|
|
|
root_child5.Height = 20;
|
|
|
|
root.Insert(5, root_child5);
|
|
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child3.LayoutX);
|
|
|
|
Assert.AreEqual(40f, root_child3.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child4.LayoutX);
|
|
|
|
Assert.AreEqual(40f, root_child4.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child5.LayoutX);
|
|
|
|
Assert.AreEqual(40f, root_child5.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutHeight);
|
|
|
|
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(80f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(50f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(80f, root_child3.LayoutX);
|
|
|
|
Assert.AreEqual(40f, root_child3.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(50f, root_child4.LayoutX);
|
|
|
|
Assert.AreEqual(40f, root_child4.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutX);
|
|
|
|
Assert.AreEqual(40f, root_child5.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_column_gap_wrap_align_center()
|
|
|
|
{
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
|
|
root.AlignContent = YogaAlign.Center;
|
|
|
|
root.Wrap = YogaWrap.Wrap;
|
|
|
|
root.Width = 100;
|
|
|
|
root.Height = 100;
|
|
|
|
root.ColumnGap = 10;
|
|
|
|
root.RowGap = 20;
|
|
|
|
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
|
|
root_child0.Width = 20;
|
|
|
|
root_child0.Height = 20;
|
|
|
|
root.Insert(0, root_child0);
|
|
|
|
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
|
|
root_child1.Width = 20;
|
|
|
|
root_child1.Height = 20;
|
|
|
|
root.Insert(1, root_child1);
|
|
|
|
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
|
|
root_child2.Width = 20;
|
|
|
|
root_child2.Height = 20;
|
|
|
|
root.Insert(2, root_child2);
|
|
|
|
|
|
|
|
YogaNode root_child3 = new YogaNode(config);
|
|
|
|
root_child3.Width = 20;
|
|
|
|
root_child3.Height = 20;
|
|
|
|
root.Insert(3, root_child3);
|
|
|
|
|
|
|
|
YogaNode root_child4 = new YogaNode(config);
|
|
|
|
root_child4.Width = 20;
|
|
|
|
root_child4.Height = 20;
|
|
|
|
root.Insert(4, root_child4);
|
|
|
|
|
|
|
|
YogaNode root_child5 = new YogaNode(config);
|
|
|
|
root_child5.Width = 20;
|
|
|
|
root_child5.Height = 20;
|
|
|
|
root.Insert(5, root_child5);
|
|
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child3.LayoutX);
|
|
|
|
Assert.AreEqual(60f, root_child3.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child4.LayoutX);
|
|
|
|
Assert.AreEqual(60f, root_child4.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child5.LayoutX);
|
|
|
|
Assert.AreEqual(60f, root_child5.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutHeight);
|
|
|
|
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(80f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(50f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(80f, root_child3.LayoutX);
|
|
|
|
Assert.AreEqual(60f, root_child3.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(50f, root_child4.LayoutX);
|
|
|
|
Assert.AreEqual(60f, root_child4.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutX);
|
|
|
|
Assert.AreEqual(60f, root_child5.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_column_gap_wrap_align_flex_end()
|
|
|
|
{
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
|
|
root.AlignContent = YogaAlign.FlexEnd;
|
|
|
|
root.Wrap = YogaWrap.Wrap;
|
|
|
|
root.Width = 100;
|
|
|
|
root.Height = 100;
|
|
|
|
root.ColumnGap = 10;
|
|
|
|
root.RowGap = 20;
|
|
|
|
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
|
|
root_child0.Width = 20;
|
|
|
|
root_child0.Height = 20;
|
|
|
|
root.Insert(0, root_child0);
|
|
|
|
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
|
|
root_child1.Width = 20;
|
|
|
|
root_child1.Height = 20;
|
|
|
|
root.Insert(1, root_child1);
|
|
|
|
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
|
|
root_child2.Width = 20;
|
|
|
|
root_child2.Height = 20;
|
|
|
|
root.Insert(2, root_child2);
|
|
|
|
|
|
|
|
YogaNode root_child3 = new YogaNode(config);
|
|
|
|
root_child3.Width = 20;
|
|
|
|
root_child3.Height = 20;
|
|
|
|
root.Insert(3, root_child3);
|
|
|
|
|
|
|
|
YogaNode root_child4 = new YogaNode(config);
|
|
|
|
root_child4.Width = 20;
|
|
|
|
root_child4.Height = 20;
|
|
|
|
root.Insert(4, root_child4);
|
|
|
|
|
|
|
|
YogaNode root_child5 = new YogaNode(config);
|
|
|
|
root_child5.Width = 20;
|
|
|
|
root_child5.Height = 20;
|
|
|
|
root.Insert(5, root_child5);
|
|
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(40f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(40f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(40f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child3.LayoutX);
|
|
|
|
Assert.AreEqual(80f, root_child3.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child4.LayoutX);
|
|
|
|
Assert.AreEqual(80f, root_child4.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child5.LayoutX);
|
|
|
|
Assert.AreEqual(80f, root_child5.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutHeight);
|
|
|
|
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(80f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(40f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(50f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(40f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(40f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(80f, root_child3.LayoutX);
|
|
|
|
Assert.AreEqual(80f, root_child3.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(50f, root_child4.LayoutX);
|
|
|
|
Assert.AreEqual(80f, root_child4.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutX);
|
|
|
|
Assert.AreEqual(80f, root_child5.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_column_gap_wrap_align_space_between()
|
|
|
|
{
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
|
|
root.AlignContent = YogaAlign.SpaceBetween;
|
|
|
|
root.Wrap = YogaWrap.Wrap;
|
|
|
|
root.Width = 100;
|
|
|
|
root.Height = 100;
|
|
|
|
root.ColumnGap = 10;
|
|
|
|
root.RowGap = 20;
|
|
|
|
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
|
|
root_child0.Width = 20;
|
|
|
|
root_child0.Height = 20;
|
|
|
|
root.Insert(0, root_child0);
|
|
|
|
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
|
|
root_child1.Width = 20;
|
|
|
|
root_child1.Height = 20;
|
|
|
|
root.Insert(1, root_child1);
|
|
|
|
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
|
|
root_child2.Width = 20;
|
|
|
|
root_child2.Height = 20;
|
|
|
|
root.Insert(2, root_child2);
|
|
|
|
|
|
|
|
YogaNode root_child3 = new YogaNode(config);
|
|
|
|
root_child3.Width = 20;
|
|
|
|
root_child3.Height = 20;
|
|
|
|
root.Insert(3, root_child3);
|
|
|
|
|
|
|
|
YogaNode root_child4 = new YogaNode(config);
|
|
|
|
root_child4.Width = 20;
|
|
|
|
root_child4.Height = 20;
|
|
|
|
root.Insert(4, root_child4);
|
|
|
|
|
|
|
|
YogaNode root_child5 = new YogaNode(config);
|
|
|
|
root_child5.Width = 20;
|
|
|
|
root_child5.Height = 20;
|
|
|
|
root.Insert(5, root_child5);
|
|
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child3.LayoutX);
|
|
|
|
Assert.AreEqual(80f, root_child3.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child4.LayoutX);
|
|
|
|
Assert.AreEqual(80f, root_child4.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child5.LayoutX);
|
|
|
|
Assert.AreEqual(80f, root_child5.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutHeight);
|
|
|
|
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(80f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(50f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(80f, root_child3.LayoutX);
|
|
|
|
Assert.AreEqual(80f, root_child3.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(50f, root_child4.LayoutX);
|
|
|
|
Assert.AreEqual(80f, root_child4.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutX);
|
|
|
|
Assert.AreEqual(80f, root_child5.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_column_gap_wrap_align_space_around()
|
|
|
|
{
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
|
|
root.AlignContent = YogaAlign.SpaceAround;
|
|
|
|
root.Wrap = YogaWrap.Wrap;
|
|
|
|
root.Width = 100;
|
|
|
|
root.Height = 100;
|
|
|
|
root.ColumnGap = 10;
|
|
|
|
root.RowGap = 20;
|
|
|
|
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
|
|
root_child0.Width = 20;
|
|
|
|
root_child0.Height = 20;
|
|
|
|
root.Insert(0, root_child0);
|
|
|
|
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
|
|
root_child1.Width = 20;
|
|
|
|
root_child1.Height = 20;
|
|
|
|
root.Insert(1, root_child1);
|
|
|
|
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
|
|
root_child2.Width = 20;
|
|
|
|
root_child2.Height = 20;
|
|
|
|
root.Insert(2, root_child2);
|
|
|
|
|
|
|
|
YogaNode root_child3 = new YogaNode(config);
|
|
|
|
root_child3.Width = 20;
|
|
|
|
root_child3.Height = 20;
|
|
|
|
root.Insert(3, root_child3);
|
|
|
|
|
|
|
|
YogaNode root_child4 = new YogaNode(config);
|
|
|
|
root_child4.Width = 20;
|
|
|
|
root_child4.Height = 20;
|
|
|
|
root.Insert(4, root_child4);
|
|
|
|
|
|
|
|
YogaNode root_child5 = new YogaNode(config);
|
|
|
|
root_child5.Width = 20;
|
|
|
|
root_child5.Height = 20;
|
|
|
|
root.Insert(5, root_child5);
|
|
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(10f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(10f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(10f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child3.LayoutX);
|
|
|
|
Assert.AreEqual(70f, root_child3.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child4.LayoutX);
|
|
|
|
Assert.AreEqual(70f, root_child4.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child5.LayoutX);
|
|
|
|
Assert.AreEqual(70f, root_child5.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutHeight);
|
|
|
|
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(80f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(10f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(50f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(10f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(10f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(80f, root_child3.LayoutX);
|
|
|
|
Assert.AreEqual(70f, root_child3.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(50f, root_child4.LayoutX);
|
|
|
|
Assert.AreEqual(70f, root_child4.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutX);
|
|
|
|
Assert.AreEqual(70f, root_child5.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutWidth);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutHeight);
|
|
|
|
}
|
Incorporate gap space into main axis overflow flag (#1173)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1173
In https://github.com/facebook/react-native/issues/35351 we see incorrect child item height when the flex-wrap is enabled, the cross-axis is to be stretched, and main-axis overflow is caused by gap.
In YGDistributeFreeSpaceSecondPass, if we do not have overflow (determined by flexBasisOverflows), we have stretch cross-alignment, and we reason that nothing can add to main axis dimensions, we know we're a single line and want to take full cross dimensions. and can set YGMeasureModeExactly which uses parent dimensions. Guessing an optimization?
If we do have overflow, then we set YGMeasureModeAtMost to find minimum possible cross-axis dimensions instead.
`flexBasisOverflows` incorporates both computed flex basis, and margin, so it is more generally a flag for whether we will wrap. So we should incorporate gap spacing into it. E.g. it is also used for whether we should the match main axis parent dimension of the overall container. This change does just that, and renames the flag to `mainAxisOverflows`.
We will want to cherry-pick the fix for this into RN 0.71 since we have not yet introduced the community to the incorrect behavior, and we expect a lot of usage of flex-gap.
Changelog:
[General][Fixed] - Fix incorrect height when gap causes main axis to overflow and cross-axis is stretched
Reviewed By: yungsters
Differential Revision: D41311424
fbshipit-source-id: bd0c3b5aac478a56878703b6da84fc3993cc14da
2022-11-15 19:51:48 -08:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_column_gap_wrap_align_stretch()
|
|
|
|
{
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
|
|
root.AlignContent = YogaAlign.Stretch;
|
|
|
|
root.Wrap = YogaWrap.Wrap;
|
|
|
|
root.Width = 300;
|
|
|
|
root.Height = 300;
|
|
|
|
root.ColumnGap = 5;
|
|
|
|
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
|
|
root_child0.FlexGrow = 1;
|
|
|
|
root_child0.MinWidth = 60;
|
|
|
|
root.Insert(0, root_child0);
|
|
|
|
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
|
|
root_child1.FlexGrow = 1;
|
|
|
|
root_child1.MinWidth = 60;
|
|
|
|
root.Insert(1, root_child1);
|
|
|
|
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
|
|
root_child2.FlexGrow = 1;
|
|
|
|
root_child2.MinWidth = 60;
|
|
|
|
root.Insert(2, root_child2);
|
|
|
|
|
|
|
|
YogaNode root_child3 = new YogaNode(config);
|
|
|
|
root_child3.FlexGrow = 1;
|
|
|
|
root_child3.MinWidth = 60;
|
|
|
|
root.Insert(3, root_child3);
|
|
|
|
|
|
|
|
YogaNode root_child4 = new YogaNode(config);
|
|
|
|
root_child4.FlexGrow = 1;
|
|
|
|
root_child4.MinWidth = 60;
|
|
|
|
root.Insert(4, root_child4);
|
|
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(300f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(300f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(71f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(150f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(76f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(72f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(150f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(153f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(71f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(150f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(229f, root_child3.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child3.LayoutY);
|
|
|
|
Assert.AreEqual(71f, root_child3.LayoutWidth);
|
|
|
|
Assert.AreEqual(150f, root_child3.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child4.LayoutX);
|
|
|
|
Assert.AreEqual(150f, root_child4.LayoutY);
|
|
|
|
Assert.AreEqual(300f, root_child4.LayoutWidth);
|
|
|
|
Assert.AreEqual(150f, root_child4.LayoutHeight);
|
|
|
|
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(300f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(300f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(229f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(71f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(150f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(153f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(71f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(150f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(76f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(72f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(150f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child3.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child3.LayoutY);
|
|
|
|
Assert.AreEqual(71f, root_child3.LayoutWidth);
|
|
|
|
Assert.AreEqual(150f, root_child3.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child4.LayoutX);
|
|
|
|
Assert.AreEqual(150f, root_child4.LayoutY);
|
|
|
|
Assert.AreEqual(300f, root_child4.LayoutWidth);
|
|
|
|
Assert.AreEqual(150f, root_child4.LayoutHeight);
|
|
|
|
}
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_row_gap_align_items_stretch()
|
|
|
|
{
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
|
|
root.AlignContent = YogaAlign.Stretch;
|
|
|
|
root.Wrap = YogaWrap.Wrap;
|
|
|
|
root.Width = 100;
|
|
|
|
root.Height = 200;
|
|
|
|
root.ColumnGap = 10;
|
|
|
|
root.RowGap = 20;
|
|
|
|
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
|
|
root_child0.Width = 20;
|
|
|
|
root.Insert(0, root_child0);
|
|
|
|
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
|
|
root_child1.Width = 20;
|
|
|
|
root.Insert(1, root_child1);
|
|
|
|
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
|
|
root_child2.Width = 20;
|
|
|
|
root.Insert(2, root_child2);
|
|
|
|
|
|
|
|
YogaNode root_child3 = new YogaNode(config);
|
|
|
|
root_child3.Width = 20;
|
|
|
|
root.Insert(3, root_child3);
|
|
|
|
|
|
|
|
YogaNode root_child4 = new YogaNode(config);
|
|
|
|
root_child4.Width = 20;
|
|
|
|
root.Insert(4, root_child4);
|
|
|
|
|
|
|
|
YogaNode root_child5 = new YogaNode(config);
|
|
|
|
root_child5.Width = 20;
|
|
|
|
root.Insert(5, root_child5);
|
|
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(90f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(90f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(90f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child3.LayoutX);
|
|
|
|
Assert.AreEqual(110f, root_child3.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutWidth);
|
|
|
|
Assert.AreEqual(90f, root_child3.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child4.LayoutX);
|
|
|
|
Assert.AreEqual(110f, root_child4.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutWidth);
|
|
|
|
Assert.AreEqual(90f, root_child4.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child5.LayoutX);
|
|
|
|
Assert.AreEqual(110f, root_child5.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutWidth);
|
|
|
|
Assert.AreEqual(90f, root_child5.LayoutHeight);
|
|
|
|
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(80f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(90f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(50f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(90f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(90f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(80f, root_child3.LayoutX);
|
|
|
|
Assert.AreEqual(110f, root_child3.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutWidth);
|
|
|
|
Assert.AreEqual(90f, root_child3.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(50f, root_child4.LayoutX);
|
|
|
|
Assert.AreEqual(110f, root_child4.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutWidth);
|
|
|
|
Assert.AreEqual(90f, root_child4.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutX);
|
|
|
|
Assert.AreEqual(110f, root_child5.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutWidth);
|
|
|
|
Assert.AreEqual(90f, root_child5.LayoutHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_row_gap_align_items_end()
|
|
|
|
{
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
|
|
root.AlignItems = YogaAlign.FlexEnd;
|
|
|
|
root.Wrap = YogaWrap.Wrap;
|
|
|
|
root.Width = 100;
|
|
|
|
root.Height = 200;
|
|
|
|
root.ColumnGap = 10;
|
|
|
|
root.RowGap = 20;
|
|
|
|
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
|
|
root_child0.Width = 20;
|
|
|
|
root.Insert(0, root_child0);
|
|
|
|
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
|
|
root_child1.Width = 20;
|
|
|
|
root.Insert(1, root_child1);
|
|
|
|
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
|
|
root_child2.Width = 20;
|
|
|
|
root.Insert(2, root_child2);
|
|
|
|
|
|
|
|
YogaNode root_child3 = new YogaNode(config);
|
|
|
|
root_child3.Width = 20;
|
|
|
|
root.Insert(3, root_child3);
|
|
|
|
|
|
|
|
YogaNode root_child4 = new YogaNode(config);
|
|
|
|
root_child4.Width = 20;
|
|
|
|
root.Insert(4, root_child4);
|
|
|
|
|
|
|
|
YogaNode root_child5 = new YogaNode(config);
|
|
|
|
root_child5.Width = 20;
|
|
|
|
root.Insert(5, root_child5);
|
|
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root_child3.LayoutX);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutWidth);
|
|
|
|
Assert.AreEqual(0f, root_child3.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(30f, root_child4.LayoutX);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutWidth);
|
|
|
|
Assert.AreEqual(0f, root_child4.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(60f, root_child5.LayoutX);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutWidth);
|
|
|
|
Assert.AreEqual(0f, root_child5.LayoutHeight);
|
|
|
|
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
|
|
root.CalculateLayout();
|
|
|
|
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(80f, root_child0.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(50f, root_child1.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutX);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child2.LayoutWidth);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(80f, root_child3.LayoutX);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child3.LayoutWidth);
|
|
|
|
Assert.AreEqual(0f, root_child3.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(50f, root_child4.LayoutX);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child4.LayoutWidth);
|
|
|
|
Assert.AreEqual(0f, root_child4.LayoutHeight);
|
|
|
|
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutX);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutY);
|
|
|
|
Assert.AreEqual(20f, root_child5.LayoutWidth);
|
|
|
|
Assert.AreEqual(0f, root_child5.LayoutHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|