Summary: @public This gets flagged by the linter. Remove it. Reviewed By: SidharthGuglani Differential Revision: D14682386 fbshipit-source-id: 612508b0906285e6420a553ac7a96d1024f1eac6
1725 lines
64 KiB
C#
1725 lines
64 KiB
C#
/**
|
|
* Copyright (c) Facebook, Inc. and its 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/YGMarginTest.html
|
|
|
|
using System;
|
|
using NUnit.Framework;
|
|
|
|
namespace Facebook.Yoga
|
|
{
|
|
[TestFixture]
|
|
public class YGMarginTest
|
|
{
|
|
[Test]
|
|
public void Test_margin_start()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
root.Width = 100;
|
|
root.Height = 100;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginStart = 10;
|
|
root_child0.Width = 10;
|
|
root.Insert(0, root_child0);
|
|
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(10f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(100f, root_child0.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(10f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_top()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.Width = 100;
|
|
root.Height = 100;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginTop = 10;
|
|
root_child0.Height = 10;
|
|
root.Insert(0, root_child0);
|
|
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(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(10f, root_child0.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(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(10f, root_child0.LayoutY);
|
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_end()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
root.JustifyContent = YogaJustify.FlexEnd;
|
|
root.Width = 100;
|
|
root.Height = 100;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginEnd = 10;
|
|
root_child0.Width = 10;
|
|
root.Insert(0, root_child0);
|
|
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(80f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(100f, root_child0.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(10f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_bottom()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.JustifyContent = YogaJustify.FlexEnd;
|
|
root.Width = 100;
|
|
root.Height = 100;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginBottom = 10;
|
|
root_child0.Height = 10;
|
|
root.Insert(0, root_child0);
|
|
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(80f, root_child0.LayoutY);
|
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(10f, root_child0.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(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(80f, root_child0.LayoutY);
|
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_and_flex_row()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
root.Width = 100;
|
|
root.Height = 100;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.FlexGrow = 1;
|
|
root_child0.MarginStart = 10;
|
|
root_child0.MarginEnd = 10;
|
|
root.Insert(0, root_child0);
|
|
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(80f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(100f, root_child0.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(10f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(80f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_and_flex_column()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.Width = 100;
|
|
root.Height = 100;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.FlexGrow = 1;
|
|
root_child0.MarginTop = 10;
|
|
root_child0.MarginBottom = 10;
|
|
root.Insert(0, root_child0);
|
|
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(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(80f, root_child0.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(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(10f, root_child0.LayoutY);
|
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(80f, root_child0.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_and_stretch_row()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
root.Width = 100;
|
|
root.Height = 100;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.FlexGrow = 1;
|
|
root_child0.MarginTop = 10;
|
|
root_child0.MarginBottom = 10;
|
|
root.Insert(0, root_child0);
|
|
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(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(80f, root_child0.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(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(10f, root_child0.LayoutY);
|
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(80f, root_child0.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_and_stretch_column()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.Width = 100;
|
|
root.Height = 100;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.FlexGrow = 1;
|
|
root_child0.MarginStart = 10;
|
|
root_child0.MarginEnd = 10;
|
|
root.Insert(0, root_child0);
|
|
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(80f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(100f, root_child0.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(10f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(80f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_with_sibling_row()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
root.Width = 100;
|
|
root.Height = 100;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.FlexGrow = 1;
|
|
root_child0.MarginEnd = 10;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.FlexGrow = 1;
|
|
root.Insert(1, root_child1);
|
|
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(45f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(55f, root_child1.LayoutX);
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
Assert.AreEqual(45f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(100f, root_child1.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(55f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(45f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutX);
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
Assert.AreEqual(45f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_with_sibling_column()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.Width = 100;
|
|
root.Height = 100;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.FlexGrow = 1;
|
|
root_child0.MarginBottom = 10;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.FlexGrow = 1;
|
|
root.Insert(1, root_child1);
|
|
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(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(45f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutX);
|
|
Assert.AreEqual(55f, root_child1.LayoutY);
|
|
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(45f, root_child1.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(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(45f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutX);
|
|
Assert.AreEqual(55f, root_child1.LayoutY);
|
|
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(45f, root_child1.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_bottom()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.AlignItems = YogaAlign.Center;
|
|
root.Width = 200;
|
|
root.Height = 200;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginBottom = YogaValue.Auto();
|
|
root_child0.Width = 50;
|
|
root_child0.Height = 50;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.Width = 50;
|
|
root_child1.Height = 50;
|
|
root.Insert(1, root_child1);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(150f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(150f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_top()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.AlignItems = YogaAlign.Center;
|
|
root.Width = 200;
|
|
root.Height = 200;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginTop = YogaValue.Auto();
|
|
root_child0.Width = 50;
|
|
root_child0.Height = 50;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.Width = 50;
|
|
root_child1.Height = 50;
|
|
root.Insert(1, root_child1);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child0.LayoutX);
|
|
Assert.AreEqual(100f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(150f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child0.LayoutX);
|
|
Assert.AreEqual(100f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(150f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_bottom_and_top()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.AlignItems = YogaAlign.Center;
|
|
root.Width = 200;
|
|
root.Height = 200;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginTop = YogaValue.Auto();
|
|
root_child0.MarginBottom = YogaValue.Auto();
|
|
root_child0.Width = 50;
|
|
root_child0.Height = 50;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.Width = 50;
|
|
root_child1.Height = 50;
|
|
root.Insert(1, root_child1);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child0.LayoutX);
|
|
Assert.AreEqual(50f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(150f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child0.LayoutX);
|
|
Assert.AreEqual(50f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(150f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_bottom_and_top_justify_center()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.JustifyContent = YogaJustify.Center;
|
|
root.Width = 200;
|
|
root.Height = 200;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginTop = YogaValue.Auto();
|
|
root_child0.MarginBottom = YogaValue.Auto();
|
|
root_child0.Width = 50;
|
|
root_child0.Height = 50;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.Width = 50;
|
|
root_child1.Height = 50;
|
|
root.Insert(1, root_child1);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(50f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutX);
|
|
Assert.AreEqual(150f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(150f, root_child0.LayoutX);
|
|
Assert.AreEqual(50f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(150f, root_child1.LayoutX);
|
|
Assert.AreEqual(150f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_mutiple_children_column()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.AlignItems = YogaAlign.Center;
|
|
root.Width = 200;
|
|
root.Height = 200;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginTop = YogaValue.Auto();
|
|
root_child0.Width = 50;
|
|
root_child0.Height = 50;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.MarginTop = YogaValue.Auto();
|
|
root_child1.Width = 50;
|
|
root_child1.Height = 50;
|
|
root.Insert(1, root_child1);
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
root_child2.Width = 50;
|
|
root_child2.Height = 50;
|
|
root.Insert(2, root_child2);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child0.LayoutX);
|
|
Assert.AreEqual(25f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(100f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child2.LayoutX);
|
|
Assert.AreEqual(150f, root_child2.LayoutY);
|
|
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child2.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child0.LayoutX);
|
|
Assert.AreEqual(25f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(100f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child2.LayoutX);
|
|
Assert.AreEqual(150f, root_child2.LayoutY);
|
|
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child2.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_mutiple_children_row()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
root.AlignItems = YogaAlign.Center;
|
|
root.Width = 200;
|
|
root.Height = 200;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginRight = YogaValue.Auto();
|
|
root_child0.Width = 50;
|
|
root_child0.Height = 50;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.MarginRight = YogaValue.Auto();
|
|
root_child1.Width = 50;
|
|
root_child1.Height = 50;
|
|
root.Insert(1, root_child1);
|
|
|
|
YogaNode root_child2 = new YogaNode(config);
|
|
root_child2.Width = 50;
|
|
root_child2.Height = 50;
|
|
root.Insert(2, root_child2);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(75f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(75f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
Assert.AreEqual(150f, root_child2.LayoutX);
|
|
Assert.AreEqual(75f, root_child2.LayoutY);
|
|
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child2.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(125f, root_child0.LayoutX);
|
|
Assert.AreEqual(75f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(50f, root_child1.LayoutX);
|
|
Assert.AreEqual(75f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child2.LayoutX);
|
|
Assert.AreEqual(75f, root_child2.LayoutY);
|
|
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child2.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_left_and_right_column()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
root.AlignItems = YogaAlign.Center;
|
|
root.Width = 200;
|
|
root.Height = 200;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginLeft = YogaValue.Auto();
|
|
root_child0.MarginRight = YogaValue.Auto();
|
|
root_child0.Width = 50;
|
|
root_child0.Height = 50;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.Width = 50;
|
|
root_child1.Height = 50;
|
|
root.Insert(1, root_child1);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(50f, root_child0.LayoutX);
|
|
Assert.AreEqual(75f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(150f, root_child1.LayoutX);
|
|
Assert.AreEqual(75f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutX);
|
|
Assert.AreEqual(75f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutX);
|
|
Assert.AreEqual(75f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_left_and_right()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.Width = 200;
|
|
root.Height = 200;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginLeft = YogaValue.Auto();
|
|
root_child0.MarginRight = YogaValue.Auto();
|
|
root_child0.Width = 50;
|
|
root_child0.Height = 50;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.Width = 50;
|
|
root_child1.Height = 50;
|
|
root.Insert(1, root_child1);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutX);
|
|
Assert.AreEqual(50f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(150f, root_child1.LayoutX);
|
|
Assert.AreEqual(50f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_start_and_end_column()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
root.AlignItems = YogaAlign.Center;
|
|
root.Width = 200;
|
|
root.Height = 200;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginStart = YogaValue.Auto();
|
|
root_child0.MarginEnd = YogaValue.Auto();
|
|
root_child0.Width = 50;
|
|
root_child0.Height = 50;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.Width = 50;
|
|
root_child1.Height = 50;
|
|
root.Insert(1, root_child1);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(50f, root_child0.LayoutX);
|
|
Assert.AreEqual(75f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(150f, root_child1.LayoutX);
|
|
Assert.AreEqual(75f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutX);
|
|
Assert.AreEqual(75f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutX);
|
|
Assert.AreEqual(75f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_start_and_end()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.Width = 200;
|
|
root.Height = 200;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginStart = YogaValue.Auto();
|
|
root_child0.MarginEnd = YogaValue.Auto();
|
|
root_child0.Width = 50;
|
|
root_child0.Height = 50;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.Width = 50;
|
|
root_child1.Height = 50;
|
|
root.Insert(1, root_child1);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutX);
|
|
Assert.AreEqual(50f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(150f, root_child1.LayoutX);
|
|
Assert.AreEqual(50f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_left_and_right_column_and_center()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.AlignItems = YogaAlign.Center;
|
|
root.Width = 200;
|
|
root.Height = 200;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginLeft = YogaValue.Auto();
|
|
root_child0.MarginRight = YogaValue.Auto();
|
|
root_child0.Width = 50;
|
|
root_child0.Height = 50;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.Width = 50;
|
|
root_child1.Height = 50;
|
|
root.Insert(1, root_child1);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(50f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(50f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_left()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.AlignItems = YogaAlign.Center;
|
|
root.Width = 200;
|
|
root.Height = 200;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginLeft = YogaValue.Auto();
|
|
root_child0.Width = 50;
|
|
root_child0.Height = 50;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.Width = 50;
|
|
root_child1.Height = 50;
|
|
root.Insert(1, root_child1);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(150f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(50f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(150f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(50f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_right()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.AlignItems = YogaAlign.Center;
|
|
root.Width = 200;
|
|
root.Height = 200;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginRight = YogaValue.Auto();
|
|
root_child0.Width = 50;
|
|
root_child0.Height = 50;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.Width = 50;
|
|
root_child1.Height = 50;
|
|
root.Insert(1, root_child1);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(50f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(50f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_left_and_right_strech()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.FlexDirection = YogaFlexDirection.Row;
|
|
root.Width = 200;
|
|
root.Height = 200;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginLeft = YogaValue.Auto();
|
|
root_child0.MarginRight = YogaValue.Auto();
|
|
root_child0.Width = 50;
|
|
root_child0.Height = 50;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.Width = 50;
|
|
root_child1.Height = 50;
|
|
root.Insert(1, root_child1);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(50f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(150f, root_child1.LayoutX);
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutX);
|
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_top_and_bottom_strech()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.Width = 200;
|
|
root.Height = 200;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginTop = YogaValue.Auto();
|
|
root_child0.MarginBottom = YogaValue.Auto();
|
|
root_child0.Width = 50;
|
|
root_child0.Height = 50;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.Width = 50;
|
|
root_child1.Height = 50;
|
|
root.Insert(1, root_child1);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(50f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child1.LayoutX);
|
|
Assert.AreEqual(150f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(150f, root_child0.LayoutX);
|
|
Assert.AreEqual(50f, root_child0.LayoutY);
|
|
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(150f, root_child1.LayoutX);
|
|
Assert.AreEqual(150f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_should_not_be_part_of_max_height()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.Width = 250;
|
|
root.Height = 250;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginTop = 20;
|
|
root_child0.Width = 100;
|
|
root_child0.Height = 100;
|
|
root_child0.MaxHeight = 100;
|
|
root.Insert(0, root_child0);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(250f, root.LayoutWidth);
|
|
Assert.AreEqual(250f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(20f, root_child0.LayoutY);
|
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(250f, root.LayoutWidth);
|
|
Assert.AreEqual(250f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(150f, root_child0.LayoutX);
|
|
Assert.AreEqual(20f, root_child0.LayoutY);
|
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_should_not_be_part_of_max_width()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.Width = 250;
|
|
root.Height = 250;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginLeft = 20;
|
|
root_child0.Width = 100;
|
|
root_child0.MaxWidth = 100;
|
|
root_child0.Height = 100;
|
|
root.Insert(0, root_child0);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(250f, root.LayoutWidth);
|
|
Assert.AreEqual(250f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(20f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(250f, root.LayoutWidth);
|
|
Assert.AreEqual(250f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(150f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_left_right_child_bigger_than_parent()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.JustifyContent = YogaJustify.Center;
|
|
root.Width = 52;
|
|
root.Height = 52;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginLeft = YogaValue.Auto();
|
|
root_child0.MarginRight = YogaValue.Auto();
|
|
root_child0.Width = 72;
|
|
root_child0.Height = 72;
|
|
root.Insert(0, root_child0);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(52f, root.LayoutWidth);
|
|
Assert.AreEqual(52f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(52f, root.LayoutWidth);
|
|
Assert.AreEqual(52f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(-20f, root_child0.LayoutX);
|
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_left_child_bigger_than_parent()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.JustifyContent = YogaJustify.Center;
|
|
root.Width = 52;
|
|
root.Height = 52;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginLeft = YogaValue.Auto();
|
|
root_child0.Width = 72;
|
|
root_child0.Height = 72;
|
|
root.Insert(0, root_child0);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(52f, root.LayoutWidth);
|
|
Assert.AreEqual(52f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(52f, root.LayoutWidth);
|
|
Assert.AreEqual(52f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(-20f, root_child0.LayoutX);
|
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_fix_left_auto_right_child_bigger_than_parent()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.JustifyContent = YogaJustify.Center;
|
|
root.Width = 52;
|
|
root.Height = 52;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginLeft = 10;
|
|
root_child0.MarginRight = YogaValue.Auto();
|
|
root_child0.Width = 72;
|
|
root_child0.Height = 72;
|
|
root.Insert(0, root_child0);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(52f, root.LayoutWidth);
|
|
Assert.AreEqual(52f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(10f, root_child0.LayoutX);
|
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(52f, root.LayoutWidth);
|
|
Assert.AreEqual(52f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(-20f, root_child0.LayoutX);
|
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_left_fix_right_child_bigger_than_parent()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.JustifyContent = YogaJustify.Center;
|
|
root.Width = 52;
|
|
root.Height = 52;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.MarginLeft = YogaValue.Auto();
|
|
root_child0.MarginRight = 10;
|
|
root_child0.Width = 72;
|
|
root_child0.Height = 72;
|
|
root.Insert(0, root_child0);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(52f, root.LayoutWidth);
|
|
Assert.AreEqual(52f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(52f, root.LayoutWidth);
|
|
Assert.AreEqual(52f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(-30f, root_child0.LayoutX);
|
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_top_stretching_child()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.AlignItems = YogaAlign.Center;
|
|
root.Width = 200;
|
|
root.Height = 200;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.FlexGrow = 1;
|
|
root_child0.FlexShrink = 1;
|
|
root_child0.FlexBasis = 0.Percent();
|
|
root_child0.MarginTop = YogaValue.Auto();
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.Width = 50;
|
|
root_child1.Height = 50;
|
|
root.Insert(1, root_child1);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(0f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(150f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(150f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(100f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(0f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(150f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(150f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_margin_auto_left_stretching_child()
|
|
{
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
YogaNode root = new YogaNode(config);
|
|
root.AlignItems = YogaAlign.Center;
|
|
root.Width = 200;
|
|
root.Height = 200;
|
|
|
|
YogaNode root_child0 = new YogaNode(config);
|
|
root_child0.FlexGrow = 1;
|
|
root_child0.FlexShrink = 1;
|
|
root_child0.FlexBasis = 0.Percent();
|
|
root_child0.MarginLeft = YogaValue.Auto();
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child1 = new YogaNode(config);
|
|
root_child1.Width = 50;
|
|
root_child1.Height = 50;
|
|
root.Insert(1, root_child1);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(200f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(0f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(150f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(150f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(200f, root.LayoutWidth);
|
|
Assert.AreEqual(200f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(200f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(0f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(150f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(75f, root_child1.LayoutX);
|
|
Assert.AreEqual(150f, root_child1.LayoutY);
|
|
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
|
}
|
|
|
|
}
|
|
}
|