Files
yoga/csharp/tests/Facebook.Yoga/YGGapTest.cs
Nick Gerleman c2a0ccf0d4 Add tests for row-gap and column-gap
Summary:
This adds the fixtures from https://github.com/facebook/yoga/pull/1116 and generates tests.

This adds a good amount of coverage, but I plan to follow up with a diff adding a bit more, e.g. for interactions with flex direction of column when we should no-op, etc. I also discovered the current fixtures do not allow testing shorthand props like "gap" without changes.

This also updates the `webdrivers` gem to respond to a break with chromedriver on m1 macs from 4 days ago https://github.com/titusfortner/webdrivers/pull/239.

Reviewed By: yungsters

Differential Revision: D39922413

fbshipit-source-id: dfc7bda894be8dfcb24e25c19a4df0b09a72ce7e
2022-10-13 08:18:49 -07:00

1645 lines
64 KiB
C#

/*
* 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);
}
[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);
}
}
}