added tests for percentage
This commit is contained in:
794
csharp/tests/Facebook.Yoga/YGPercentageTest.cs
Normal file
794
csharp/tests/Facebook.Yoga/YGPercentageTest.cs
Normal file
@@ -0,0 +1,794 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPercentageTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class YGPercentageTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_percentage_width_height()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 200f;
|
||||
root.Height = 200f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 30f;
|
||||
root_child0.Height = 30f;
|
||||
root.Insert(0, root_child0);
|
||||
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(60f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(60f, root_child0.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(140f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(60f, root_child0.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_percentage_position_left_top()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 400f;
|
||||
root.Height = 400f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.SetPosition(YogaEdge.Left, 10f);
|
||||
root_child0.SetPosition(YogaEdge.Top, 20f);
|
||||
root_child0.Width = 45f;
|
||||
root_child0.Height = 55f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(400f, root.LayoutWidth);
|
||||
Assert.AreEqual(400f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(40f, root_child0.LayoutX);
|
||||
Assert.AreEqual(80f, root_child0.LayoutY);
|
||||
Assert.AreEqual(180f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(220f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(400f, root.LayoutWidth);
|
||||
Assert.AreEqual(400f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(260f, root_child0.LayoutX);
|
||||
Assert.AreEqual(80f, root_child0.LayoutY);
|
||||
Assert.AreEqual(180f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(220f, root_child0.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_percentage_position_bottom_right()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 500f;
|
||||
root.Height = 500f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.SetPosition(YogaEdge.Right, 20f);
|
||||
root_child0.SetPosition(YogaEdge.Bottom, 10f);
|
||||
root_child0.Width = 55f;
|
||||
root_child0.Height = 15f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(500f, root.LayoutWidth);
|
||||
Assert.AreEqual(500f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(-100f, root_child0.LayoutX);
|
||||
Assert.AreEqual(-50f, root_child0.LayoutY);
|
||||
Assert.AreEqual(275f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(75f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(500f, root.LayoutWidth);
|
||||
Assert.AreEqual(500f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(125f, root_child0.LayoutX);
|
||||
Assert.AreEqual(-50f, root_child0.LayoutY);
|
||||
Assert.AreEqual(275f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(75f, root_child0.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_percentage_flex_basis()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 200f;
|
||||
root.Height = 200f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 50f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root_child1.FlexBasis = 25f;
|
||||
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(125f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(200f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(125f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(75f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(200f, 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(125f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(200f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(75f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(200f, root_child1.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_percentage_flex_basis_cross()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 200f;
|
||||
root.Height = 200f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 50f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root_child1.FlexBasis = 25f;
|
||||
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(200f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(125f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(125f, root_child1.LayoutY);
|
||||
Assert.AreEqual(200f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(75f, 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(200f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(125f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(125f, root_child1.LayoutY);
|
||||
Assert.AreEqual(200f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(75f, root_child1.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_percentage_flex_basis_cross_min_height()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 200f;
|
||||
root.Height = 200f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.MinHeight = 60f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 2f;
|
||||
root_child1.MinHeight = 10f;
|
||||
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(200f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(140f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(140f, root_child1.LayoutY);
|
||||
Assert.AreEqual(200f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(60f, 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(200f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(140f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(140f, root_child1.LayoutY);
|
||||
Assert.AreEqual(200f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(60f, root_child1.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_percentage_flex_basis_main_max_height()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 200f;
|
||||
root.Height = 200f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 10f;
|
||||
root_child0.MaxHeight = 60f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 4f;
|
||||
root_child1.FlexBasis = 10f;
|
||||
root_child1.MaxHeight = 20f;
|
||||
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(52f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(120f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(52f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(148f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(40f, 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(148f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(52f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(120f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(148f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(40f, root_child1.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_percentage_flex_basis_cross_max_height()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 200f;
|
||||
root.Height = 200f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 10f;
|
||||
root_child0.MaxHeight = 60f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 4f;
|
||||
root_child1.FlexBasis = 10f;
|
||||
root_child1.MaxHeight = 20f;
|
||||
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(200f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(120f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(120f, root_child1.LayoutY);
|
||||
Assert.AreEqual(200f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(40f, 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(200f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(120f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(120f, root_child1.LayoutY);
|
||||
Assert.AreEqual(200f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(40f, root_child1.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_percentage_flex_basis_main_max_width()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 200f;
|
||||
root.Height = 200f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 15f;
|
||||
root_child0.MaxWidth = 60f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 4f;
|
||||
root_child1.FlexBasis = 10f;
|
||||
root_child1.MaxWidth = 20f;
|
||||
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(120f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(200f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(120f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(40f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(200f, 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(80f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(120f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(200f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(40f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(40f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(200f, root_child1.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_percentage_flex_basis_cross_max_width()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 200f;
|
||||
root.Height = 200f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 10f;
|
||||
root_child0.MaxWidth = 60f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 4f;
|
||||
root_child1.FlexBasis = 15f;
|
||||
root_child1.MaxWidth = 20f;
|
||||
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(120f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(50f, root_child1.LayoutY);
|
||||
Assert.AreEqual(40f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(150f, 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(80f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(120f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(160f, root_child1.LayoutX);
|
||||
Assert.AreEqual(50f, root_child1.LayoutY);
|
||||
Assert.AreEqual(40f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(150f, root_child1.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_percentage_flex_basis_main_min_width()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 200f;
|
||||
root.Height = 200f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 15f;
|
||||
root_child0.MinWidth = 60f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 4f;
|
||||
root_child1.FlexBasis = 10f;
|
||||
root_child1.MinWidth = 20f;
|
||||
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(120f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(200f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(120f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(80f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(200f, 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(80f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(120f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(200f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(80f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(200f, root_child1.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_percentage_flex_basis_cross_min_width()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 200f;
|
||||
root.Height = 200f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 10f;
|
||||
root_child0.MinWidth = 60f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 4f;
|
||||
root_child1.FlexBasis = 15f;
|
||||
root_child1.MinWidth = 20f;
|
||||
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(200f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(50f, root_child1.LayoutY);
|
||||
Assert.AreEqual(200f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(150f, 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(200f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(50f, root_child1.LayoutY);
|
||||
Assert.AreEqual(200f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(150f, root_child1.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_percentage_multiple_nested_with_padding_margin_and_percentage_values()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 200f;
|
||||
root.Height = 200f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 10f;
|
||||
root_child0.SetMargin(YogaEdge.Left, 5f);
|
||||
root_child0.SetMargin(YogaEdge.Top, 5f);
|
||||
root_child0.SetMargin(YogaEdge.Right, 5f);
|
||||
root_child0.SetMargin(YogaEdge.Bottom, 5f);
|
||||
root_child0.SetPadding(YogaEdge.Left, 3f);
|
||||
root_child0.SetPadding(YogaEdge.Top, 3f);
|
||||
root_child0.SetPadding(YogaEdge.Right, 3f);
|
||||
root_child0.SetPadding(YogaEdge.Bottom, 3f);
|
||||
root_child0.MinWidth = 60f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child0_child0 = new YogaNode();
|
||||
root_child0_child0.SetMargin(YogaEdge.Left, 5f);
|
||||
root_child0_child0.SetMargin(YogaEdge.Top, 5f);
|
||||
root_child0_child0.SetMargin(YogaEdge.Right, 5f);
|
||||
root_child0_child0.SetMargin(YogaEdge.Bottom, 5f);
|
||||
root_child0_child0.SetPadding(YogaEdge.Left, 3f);
|
||||
root_child0_child0.SetPadding(YogaEdge.Top, 3f);
|
||||
root_child0_child0.SetPadding(YogaEdge.Right, 3f);
|
||||
root_child0_child0.SetPadding(YogaEdge.Bottom, 3f);
|
||||
root_child0_child0.Width = 50f;
|
||||
root_child0.Insert(0, root_child0_child0);
|
||||
|
||||
YogaNode root_child0_child0_child0 = new YogaNode();
|
||||
root_child0_child0_child0.SetMargin(YogaEdge.Left, 5f);
|
||||
root_child0_child0_child0.SetMargin(YogaEdge.Top, 5f);
|
||||
root_child0_child0_child0.SetMargin(YogaEdge.Right, 5f);
|
||||
root_child0_child0_child0.SetMargin(YogaEdge.Bottom, 5f);
|
||||
root_child0_child0_child0.SetPadding(YogaEdge.Left, 3f);
|
||||
root_child0_child0_child0.SetPadding(YogaEdge.Top, 3f);
|
||||
root_child0_child0_child0.SetPadding(YogaEdge.Right, 3f);
|
||||
root_child0_child0_child0.SetPadding(YogaEdge.Bottom, 3f);
|
||||
root_child0_child0_child0.Width = 45f;
|
||||
root_child0_child0.Insert(0, root_child0_child0_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 4f;
|
||||
root_child1.FlexBasis = 15f;
|
||||
root_child1.MinWidth = 20f;
|
||||
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(5f, root_child0.LayoutX);
|
||||
Assert.AreEqual(5f, root_child0.LayoutY);
|
||||
Assert.AreEqual(190f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(48f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(8f, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(8f, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(92f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(25f, root_child0_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10f, root_child0_child0_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0_child0_child0.LayoutY);
|
||||
Assert.AreEqual(36f, root_child0_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(6f, root_child0_child0_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(58f, root_child1.LayoutY);
|
||||
Assert.AreEqual(200f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(142f, 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(5f, root_child0.LayoutX);
|
||||
Assert.AreEqual(5f, root_child0.LayoutY);
|
||||
Assert.AreEqual(190f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(48f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(90f, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(8f, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(92f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(25f, root_child0_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(46f, root_child0_child0_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0_child0_child0.LayoutY);
|
||||
Assert.AreEqual(36f, root_child0_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(6f, root_child0_child0_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(58f, root_child1.LayoutY);
|
||||
Assert.AreEqual(200f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(142f, root_child1.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
67
gentest/fixtures/YGPercentageTest.html
Normal file
67
gentest/fixtures/YGPercentageTest.html
Normal file
@@ -0,0 +1,67 @@
|
||||
<div id="percentage_width_height" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
|
||||
<div style="width: 30%; height: 30%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_position_left_top" experiments="Rounding" style="width: 400px; height: 400px; flex-direction: row;">
|
||||
<div style="width: 45%; height: 55%; left: 10%; top: 20%"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_position_bottom_right" experiments="Rounding" style="width: 500px; height: 500px; flex-direction: row;">
|
||||
<div style="width: 55%; height: 15%; bottom: 10%; right: 20%"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_flex_basis" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
|
||||
<div style="flex-grow: 1; flex-basis: 50%;"></div>
|
||||
<div style="flex-grow: 1; flex-basis: 25%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_flex_basis_cross" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
|
||||
<div style="flex-grow: 1; flex-basis: 50%;"></div>
|
||||
<div style="flex-grow: 1; flex-basis: 25%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_flex_basis_cross_min_height" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
|
||||
<div style="flex-grow: 1; min-height: 60%;"></div>
|
||||
<div style="flex-grow: 2; min-height: 10%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_flex_basis_main_max_height" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
|
||||
<div style="flex-grow: 1; flex-basis: 10%; max-height: 60%;"></div>
|
||||
<div style="flex-grow: 4; flex-basis: 10%; max-height: 20%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_flex_basis_cross_max_height" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
|
||||
<div style="flex-grow: 1; flex-basis: 10%; max-height: 60%;"></div>
|
||||
<div style="flex-grow: 4; flex-basis: 10%; max-height: 20%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_flex_basis_main_max_width" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
|
||||
<div style="flex-grow: 1; flex-basis: 15%; max-width: 60%;"></div>
|
||||
<div style="flex-grow: 4; flex-basis: 10%; max-width: 20%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_flex_basis_cross_max_width" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
|
||||
<div style="flex-grow: 1; flex-basis: 10%; max-width: 60%;"></div>
|
||||
<div style="flex-grow: 4; flex-basis: 15%; max-width: 20%;"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="percentage_flex_basis_main_min_width" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
|
||||
<div style="flex-grow: 1; flex-basis: 15%; min-width: 60%;"></div>
|
||||
<div style="flex-grow: 4; flex-basis: 10%; min-width: 20%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_flex_basis_cross_min_width" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
|
||||
<div style="flex-grow: 1; flex-basis: 10%; min-width: 60%;"></div>
|
||||
<div style="flex-grow: 4; flex-basis: 15%; min-width: 20%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_multiple_nested_with_padding_margin_and_percentage_values" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
|
||||
<div style="flex-grow: 1; flex-basis: 10%; min-width: 60%; margin: 5px; padding: 3px;">
|
||||
<div style="width: 50%; margin: 5px; padding: 3%;">
|
||||
<div style="width: 45%; margin: 5%; padding: 3px;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="flex-grow: 4; flex-basis: 15%; min-width: 20%;"></div>
|
||||
</div>
|
779
java/tests/com/facebook/yoga/YGPercentageTest.java
Normal file
779
java/tests/com/facebook/yoga/YGPercentageTest.java
Normal file
@@ -0,0 +1,779 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPercentageTest.html
|
||||
|
||||
package com.facebook.yoga;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class YGPercentageTest {
|
||||
@Test
|
||||
public void test_percentage_width_height() {
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
root.setWidth(200f);
|
||||
root.setHeight(200f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
root_child0.setWidth(30f);
|
||||
root_child0.setHeight(30f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(140f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_percentage_position_left_top() {
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
root.setWidth(400f);
|
||||
root.setHeight(400f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
root_child0.setPosition(YogaEdge.LEFT, 10f);
|
||||
root_child0.setPosition(YogaEdge.TOP, 20f);
|
||||
root_child0.setWidth(45f);
|
||||
root_child0.setHeight(55f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(400f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(400f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(40f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(80f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(180f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(220f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(400f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(400f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(260f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(80f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(180f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(220f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_percentage_position_bottom_right() {
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
root.setWidth(500f);
|
||||
root.setHeight(500f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
root_child0.setPosition(YogaEdge.RIGHT, 20f);
|
||||
root_child0.setPosition(YogaEdge.BOTTOM, 10f);
|
||||
root_child0.setWidth(55f);
|
||||
root_child0.setHeight(15f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(500f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(500f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(-100f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(-50f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(275f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(75f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(500f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(500f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(125f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(-50f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(275f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(75f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_percentage_flex_basis() {
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
root.setWidth(200f);
|
||||
root.setHeight(200f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
root_child0.setFlexGrow(1f);
|
||||
root_child0.setFlexBasis(50f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode();
|
||||
root_child1.setFlexGrow(1f);
|
||||
root_child1.setFlexBasis(25f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(125f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(125f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(75f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(75f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(125f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(75f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_percentage_flex_basis_cross() {
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setWidth(200f);
|
||||
root.setHeight(200f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
root_child0.setFlexGrow(1f);
|
||||
root_child0.setFlexBasis(50f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode();
|
||||
root_child1.setFlexGrow(1f);
|
||||
root_child1.setFlexBasis(25f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(125f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(125f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(75f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(125f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(125f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(75f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_percentage_flex_basis_cross_min_height() {
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setWidth(200f);
|
||||
root.setHeight(200f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
root_child0.setFlexGrow(1f);
|
||||
root_child0.setMinHeight(60f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode();
|
||||
root_child1.setFlexGrow(2f);
|
||||
root_child1.setMinHeight(10f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(140f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(140f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(60f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(140f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(140f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(60f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_percentage_flex_basis_main_max_height() {
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
root.setWidth(200f);
|
||||
root.setHeight(200f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
root_child0.setFlexGrow(1f);
|
||||
root_child0.setFlexBasis(10f);
|
||||
root_child0.setMaxHeight(60f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode();
|
||||
root_child1.setFlexGrow(4f);
|
||||
root_child1.setFlexBasis(10f);
|
||||
root_child1.setMaxHeight(20f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(52f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(120f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(52f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(148f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(148f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(52f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(120f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(148f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_percentage_flex_basis_cross_max_height() {
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setWidth(200f);
|
||||
root.setHeight(200f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
root_child0.setFlexGrow(1f);
|
||||
root_child0.setFlexBasis(10f);
|
||||
root_child0.setMaxHeight(60f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode();
|
||||
root_child1.setFlexGrow(4f);
|
||||
root_child1.setFlexBasis(10f);
|
||||
root_child1.setMaxHeight(20f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(120f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(120f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(120f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(120f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_percentage_flex_basis_main_max_width() {
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
root.setWidth(200f);
|
||||
root.setHeight(200f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
root_child0.setFlexGrow(1f);
|
||||
root_child0.setFlexBasis(15f);
|
||||
root_child0.setMaxWidth(60f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode();
|
||||
root_child1.setFlexGrow(4f);
|
||||
root_child1.setFlexBasis(10f);
|
||||
root_child1.setMaxWidth(20f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(120f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(120f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(120f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(40f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_percentage_flex_basis_cross_max_width() {
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setWidth(200f);
|
||||
root.setHeight(200f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
root_child0.setFlexGrow(1f);
|
||||
root_child0.setFlexBasis(10f);
|
||||
root_child0.setMaxWidth(60f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode();
|
||||
root_child1.setFlexGrow(4f);
|
||||
root_child1.setFlexBasis(15f);
|
||||
root_child1.setMaxWidth(20f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(120f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(120f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(160f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_percentage_flex_basis_main_min_width() {
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
root.setWidth(200f);
|
||||
root.setHeight(200f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
root_child0.setFlexGrow(1f);
|
||||
root_child0.setFlexBasis(15f);
|
||||
root_child0.setMinWidth(60f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode();
|
||||
root_child1.setFlexGrow(4f);
|
||||
root_child1.setFlexBasis(10f);
|
||||
root_child1.setMinWidth(20f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(120f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(120f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(80f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(120f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(80f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_percentage_flex_basis_cross_min_width() {
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setWidth(200f);
|
||||
root.setHeight(200f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
root_child0.setFlexGrow(1f);
|
||||
root_child0.setFlexBasis(10f);
|
||||
root_child0.setMinWidth(60f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode();
|
||||
root_child1.setFlexGrow(4f);
|
||||
root_child1.setFlexBasis(15f);
|
||||
root_child1.setMinWidth(20f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_percentage_multiple_nested_with_padding_margin_and_percentage_values() {
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode();
|
||||
root.setWidth(200f);
|
||||
root.setHeight(200f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode();
|
||||
root_child0.setFlexGrow(1f);
|
||||
root_child0.setFlexBasis(10f);
|
||||
root_child0.setMargin(YogaEdge.LEFT, 5f);
|
||||
root_child0.setMargin(YogaEdge.TOP, 5f);
|
||||
root_child0.setMargin(YogaEdge.RIGHT, 5f);
|
||||
root_child0.setMargin(YogaEdge.BOTTOM, 5f);
|
||||
root_child0.setPadding(YogaEdge.LEFT, 3);
|
||||
root_child0.setPadding(YogaEdge.TOP, 3);
|
||||
root_child0.setPadding(YogaEdge.RIGHT, 3);
|
||||
root_child0.setPadding(YogaEdge.BOTTOM, 3);
|
||||
root_child0.setMinWidth(60f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child0_child0 = new YogaNode();
|
||||
root_child0_child0.setMargin(YogaEdge.LEFT, 5f);
|
||||
root_child0_child0.setMargin(YogaEdge.TOP, 5f);
|
||||
root_child0_child0.setMargin(YogaEdge.RIGHT, 5f);
|
||||
root_child0_child0.setMargin(YogaEdge.BOTTOM, 5f);
|
||||
root_child0_child0.setPadding(YogaEdge.LEFT, 3);
|
||||
root_child0_child0.setPadding(YogaEdge.TOP, 3);
|
||||
root_child0_child0.setPadding(YogaEdge.RIGHT, 3);
|
||||
root_child0_child0.setPadding(YogaEdge.BOTTOM, 3);
|
||||
root_child0_child0.setWidth(50f);
|
||||
root_child0.addChildAt(root_child0_child0, 0);
|
||||
|
||||
final YogaNode root_child0_child0_child0 = new YogaNode();
|
||||
root_child0_child0_child0.setMargin(YogaEdge.LEFT, 5f);
|
||||
root_child0_child0_child0.setMargin(YogaEdge.TOP, 5f);
|
||||
root_child0_child0_child0.setMargin(YogaEdge.RIGHT, 5f);
|
||||
root_child0_child0_child0.setMargin(YogaEdge.BOTTOM, 5f);
|
||||
root_child0_child0_child0.setPadding(YogaEdge.LEFT, 3);
|
||||
root_child0_child0_child0.setPadding(YogaEdge.TOP, 3);
|
||||
root_child0_child0_child0.setPadding(YogaEdge.RIGHT, 3);
|
||||
root_child0_child0_child0.setPadding(YogaEdge.BOTTOM, 3);
|
||||
root_child0_child0_child0.setWidth(45f);
|
||||
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode();
|
||||
root_child1.setFlexGrow(4f);
|
||||
root_child1.setFlexBasis(15f);
|
||||
root_child1.setMinWidth(20f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(5f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(5f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(190f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(48f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(8f, root_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(8f, root_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(92f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(25f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(36f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(6f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(58f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(142f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout();
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(5f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(5f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(190f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(48f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(90f, root_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(8f, root_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(92f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(25f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(46f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(36f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(6f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(58f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(142f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
|
||||
}
|
||||
|
||||
}
|
760
tests/YGPercentageTest.cpp
Normal file
760
tests/YGPercentageTest.cpp
Normal file
@@ -0,0 +1,760 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPercentageTest.html
|
||||
|
||||
#include <yoga/Yoga.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(YogaTest, percentage_width_height) {
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
|
||||
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
||||
YGNodeStyleSetWidthWithUnit(root, YGPx(200));
|
||||
YGNodeStyleSetHeightWithUnit(root, YGPx(200));
|
||||
|
||||
const YGNodeRef root_child0 = YGNodeNew();
|
||||
YGNodeStyleSetWidthWithUnit(root_child0, YGPercent(30));
|
||||
YGNodeStyleSetHeightWithUnit(root_child0, YGPercent(30));
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
|
||||
}
|
||||
|
||||
TEST(YogaTest, percentage_position_left_top) {
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
|
||||
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
||||
YGNodeStyleSetWidthWithUnit(root, YGPx(400));
|
||||
YGNodeStyleSetHeightWithUnit(root, YGPx(400));
|
||||
|
||||
const YGNodeRef root_child0 = YGNodeNew();
|
||||
YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeLeft, YGPercent(10));
|
||||
YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeTop, YGPercent(20));
|
||||
YGNodeStyleSetWidthWithUnit(root_child0, YGPercent(45));
|
||||
YGNodeStyleSetHeightWithUnit(root_child0, YGPercent(55));
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(220, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(260, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(220, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
|
||||
}
|
||||
|
||||
TEST(YogaTest, percentage_position_bottom_right) {
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
|
||||
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
||||
YGNodeStyleSetWidthWithUnit(root, YGPx(500));
|
||||
YGNodeStyleSetHeightWithUnit(root, YGPx(500));
|
||||
|
||||
const YGNodeRef root_child0 = YGNodeNew();
|
||||
YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeRight, YGPercent(20));
|
||||
YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeBottom, YGPercent(10));
|
||||
YGNodeStyleSetWidthWithUnit(root_child0, YGPercent(55));
|
||||
YGNodeStyleSetHeightWithUnit(root_child0, YGPercent(15));
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(-100, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(-50, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(275, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(-50, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(275, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
|
||||
}
|
||||
|
||||
TEST(YogaTest, percentage_flex_basis) {
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
|
||||
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
||||
YGNodeStyleSetWidthWithUnit(root, YGPx(200));
|
||||
YGNodeStyleSetHeightWithUnit(root, YGPx(200));
|
||||
|
||||
const YGNodeRef root_child0 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child0, 1);
|
||||
YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(50));
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
|
||||
const YGNodeRef root_child1 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child1, 1);
|
||||
YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(25));
|
||||
YGNodeInsertChild(root, root_child1, 1);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
|
||||
}
|
||||
|
||||
TEST(YogaTest, percentage_flex_basis_cross) {
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
|
||||
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
YGNodeStyleSetWidthWithUnit(root, YGPx(200));
|
||||
YGNodeStyleSetHeightWithUnit(root, YGPx(200));
|
||||
|
||||
const YGNodeRef root_child0 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child0, 1);
|
||||
YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(50));
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
|
||||
const YGNodeRef root_child1 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child1, 1);
|
||||
YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(25));
|
||||
YGNodeInsertChild(root, root_child1, 1);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
|
||||
}
|
||||
|
||||
TEST(YogaTest, percentage_flex_basis_cross_min_height) {
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
|
||||
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
YGNodeStyleSetWidthWithUnit(root, YGPx(200));
|
||||
YGNodeStyleSetHeightWithUnit(root, YGPx(200));
|
||||
|
||||
const YGNodeRef root_child0 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child0, 1);
|
||||
YGNodeStyleSetMinHeightWithUnit(root_child0, YGPercent(60));
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
|
||||
const YGNodeRef root_child1 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child1, 2);
|
||||
YGNodeStyleSetMinHeightWithUnit(root_child1, YGPercent(10));
|
||||
YGNodeInsertChild(root, root_child1, 1);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(140, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(140, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(140, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(140, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
|
||||
}
|
||||
|
||||
TEST(YogaTest, percentage_flex_basis_main_max_height) {
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
|
||||
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
||||
YGNodeStyleSetWidthWithUnit(root, YGPx(200));
|
||||
YGNodeStyleSetHeightWithUnit(root, YGPx(200));
|
||||
|
||||
const YGNodeRef root_child0 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child0, 1);
|
||||
YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(10));
|
||||
YGNodeStyleSetMaxHeightWithUnit(root_child0, YGPercent(60));
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
|
||||
const YGNodeRef root_child1 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child1, 4);
|
||||
YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(10));
|
||||
YGNodeStyleSetMaxHeightWithUnit(root_child1, YGPercent(20));
|
||||
YGNodeInsertChild(root, root_child1, 1);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(52, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(52, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(148, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(148, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(52, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(148, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
|
||||
}
|
||||
|
||||
TEST(YogaTest, percentage_flex_basis_cross_max_height) {
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
|
||||
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
YGNodeStyleSetWidthWithUnit(root, YGPx(200));
|
||||
YGNodeStyleSetHeightWithUnit(root, YGPx(200));
|
||||
|
||||
const YGNodeRef root_child0 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child0, 1);
|
||||
YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(10));
|
||||
YGNodeStyleSetMaxHeightWithUnit(root_child0, YGPercent(60));
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
|
||||
const YGNodeRef root_child1 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child1, 4);
|
||||
YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(10));
|
||||
YGNodeStyleSetMaxHeightWithUnit(root_child1, YGPercent(20));
|
||||
YGNodeInsertChild(root, root_child1, 1);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
|
||||
}
|
||||
|
||||
TEST(YogaTest, percentage_flex_basis_main_max_width) {
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
|
||||
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
||||
YGNodeStyleSetWidthWithUnit(root, YGPx(200));
|
||||
YGNodeStyleSetHeightWithUnit(root, YGPx(200));
|
||||
|
||||
const YGNodeRef root_child0 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child0, 1);
|
||||
YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(15));
|
||||
YGNodeStyleSetMaxWidthWithUnit(root_child0, YGPercent(60));
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
|
||||
const YGNodeRef root_child1 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child1, 4);
|
||||
YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(10));
|
||||
YGNodeStyleSetMaxWidthWithUnit(root_child1, YGPercent(20));
|
||||
YGNodeInsertChild(root, root_child1, 1);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
|
||||
}
|
||||
|
||||
TEST(YogaTest, percentage_flex_basis_cross_max_width) {
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
|
||||
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
YGNodeStyleSetWidthWithUnit(root, YGPx(200));
|
||||
YGNodeStyleSetHeightWithUnit(root, YGPx(200));
|
||||
|
||||
const YGNodeRef root_child0 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child0, 1);
|
||||
YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(10));
|
||||
YGNodeStyleSetMaxWidthWithUnit(root_child0, YGPercent(60));
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
|
||||
const YGNodeRef root_child1 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child1, 4);
|
||||
YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(15));
|
||||
YGNodeStyleSetMaxWidthWithUnit(root_child1, YGPercent(20));
|
||||
YGNodeInsertChild(root, root_child1, 1);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
|
||||
}
|
||||
|
||||
TEST(YogaTest, percentage_flex_basis_main_min_width) {
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
|
||||
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
||||
YGNodeStyleSetWidthWithUnit(root, YGPx(200));
|
||||
YGNodeStyleSetHeightWithUnit(root, YGPx(200));
|
||||
|
||||
const YGNodeRef root_child0 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child0, 1);
|
||||
YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(15));
|
||||
YGNodeStyleSetMinWidthWithUnit(root_child0, YGPercent(60));
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
|
||||
const YGNodeRef root_child1 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child1, 4);
|
||||
YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(10));
|
||||
YGNodeStyleSetMinWidthWithUnit(root_child1, YGPercent(20));
|
||||
YGNodeInsertChild(root, root_child1, 1);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
|
||||
}
|
||||
|
||||
TEST(YogaTest, percentage_flex_basis_cross_min_width) {
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
|
||||
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
YGNodeStyleSetWidthWithUnit(root, YGPx(200));
|
||||
YGNodeStyleSetHeightWithUnit(root, YGPx(200));
|
||||
|
||||
const YGNodeRef root_child0 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child0, 1);
|
||||
YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(10));
|
||||
YGNodeStyleSetMinWidthWithUnit(root_child0, YGPercent(60));
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
|
||||
const YGNodeRef root_child1 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child1, 4);
|
||||
YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(15));
|
||||
YGNodeStyleSetMinWidthWithUnit(root_child1, YGPercent(20));
|
||||
YGNodeInsertChild(root, root_child1, 1);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
|
||||
}
|
||||
|
||||
TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_values) {
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
|
||||
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
YGNodeStyleSetWidthWithUnit(root, YGPx(200));
|
||||
YGNodeStyleSetHeightWithUnit(root, YGPx(200));
|
||||
|
||||
const YGNodeRef root_child0 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child0, 1);
|
||||
YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(10));
|
||||
YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeLeft, YGPx(5));
|
||||
YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeTop, YGPx(5));
|
||||
YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeRight, YGPx(5));
|
||||
YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeBottom, YGPx(5));
|
||||
YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeLeft, YGPx(3));
|
||||
YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeTop, YGPx(3));
|
||||
YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeRight, YGPx(3));
|
||||
YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeBottom, YGPx(3));
|
||||
YGNodeStyleSetMinWidthWithUnit(root_child0, YGPercent(60));
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
|
||||
const YGNodeRef root_child0_child0 = YGNodeNew();
|
||||
YGNodeStyleSetMarginWithUnit(root_child0_child0, YGEdgeLeft, YGPx(5));
|
||||
YGNodeStyleSetMarginWithUnit(root_child0_child0, YGEdgeTop, YGPx(5));
|
||||
YGNodeStyleSetMarginWithUnit(root_child0_child0, YGEdgeRight, YGPx(5));
|
||||
YGNodeStyleSetMarginWithUnit(root_child0_child0, YGEdgeBottom, YGPx(5));
|
||||
YGNodeStyleSetPaddingWithUnit(root_child0_child0, YGEdgeLeft, YGPercent(3));
|
||||
YGNodeStyleSetPaddingWithUnit(root_child0_child0, YGEdgeTop, YGPercent(3));
|
||||
YGNodeStyleSetPaddingWithUnit(root_child0_child0, YGEdgeRight, YGPercent(3));
|
||||
YGNodeStyleSetPaddingWithUnit(root_child0_child0, YGEdgeBottom, YGPercent(3));
|
||||
YGNodeStyleSetWidthWithUnit(root_child0_child0, YGPercent(50));
|
||||
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||
|
||||
const YGNodeRef root_child0_child0_child0 = YGNodeNew();
|
||||
YGNodeStyleSetMarginWithUnit(root_child0_child0_child0, YGEdgeLeft, YGPercent(5));
|
||||
YGNodeStyleSetMarginWithUnit(root_child0_child0_child0, YGEdgeTop, YGPercent(5));
|
||||
YGNodeStyleSetMarginWithUnit(root_child0_child0_child0, YGEdgeRight, YGPercent(5));
|
||||
YGNodeStyleSetMarginWithUnit(root_child0_child0_child0, YGEdgeBottom, YGPercent(5));
|
||||
YGNodeStyleSetPaddingWithUnit(root_child0_child0_child0, YGEdgeLeft, YGPx(3));
|
||||
YGNodeStyleSetPaddingWithUnit(root_child0_child0_child0, YGEdgeTop, YGPx(3));
|
||||
YGNodeStyleSetPaddingWithUnit(root_child0_child0_child0, YGEdgeRight, YGPx(3));
|
||||
YGNodeStyleSetPaddingWithUnit(root_child0_child0_child0, YGEdgeBottom, YGPx(3));
|
||||
YGNodeStyleSetWidthWithUnit(root_child0_child0_child0, YGPercent(45));
|
||||
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
|
||||
|
||||
const YGNodeRef root_child1 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(root_child1, 4);
|
||||
YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(15));
|
||||
YGNodeStyleSetMinWidthWithUnit(root_child1, YGPercent(20));
|
||||
YGNodeInsertChild(root, root_child1, 1);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(190, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(48, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(8, YGNodeLayoutGetLeft(root_child0_child0));
|
||||
ASSERT_FLOAT_EQ(8, YGNodeLayoutGetTop(root_child0_child0));
|
||||
ASSERT_FLOAT_EQ(92, YGNodeLayoutGetWidth(root_child0_child0));
|
||||
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
||||
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child0_child0));
|
||||
ASSERT_FLOAT_EQ(36, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
||||
ASSERT_FLOAT_EQ(6, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(58, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(142, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(190, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(48, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child0));
|
||||
ASSERT_FLOAT_EQ(8, YGNodeLayoutGetTop(root_child0_child0));
|
||||
ASSERT_FLOAT_EQ(92, YGNodeLayoutGetWidth(root_child0_child0));
|
||||
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(46, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
||||
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child0_child0));
|
||||
ASSERT_FLOAT_EQ(36, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
||||
ASSERT_FLOAT_EQ(6, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
||||
ASSERT_FLOAT_EQ(58, YGNodeLayoutGetTop(root_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
|
||||
ASSERT_FLOAT_EQ(142, YGNodeLayoutGetHeight(root_child1));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
|
||||
}
|
Reference in New Issue
Block a user