Reviewed By: emilsjolander Differential Revision: D4482049 fbshipit-source-id: c30a6550ed175811df29c24ba03af92f3bd32713
178 lines
6.7 KiB
C#
178 lines
6.7 KiB
C#
/**
|
|
* 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/YGSizeOverflowTest.html
|
|
|
|
using System;
|
|
using NUnit.Framework;
|
|
|
|
namespace Facebook.Yoga
|
|
{
|
|
[TestFixture]
|
|
public class YGSizeOverflowTest
|
|
{
|
|
[Test]
|
|
public void Test_nested_overflowing_child()
|
|
{
|
|
YogaNode root = new YogaNode();
|
|
root.Width = 100;
|
|
root.Height = 100;
|
|
|
|
YogaNode root_child0 = new YogaNode();
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child0_child0 = new YogaNode();
|
|
root_child0_child0.Width = 200;
|
|
root_child0_child0.Height = 200;
|
|
root_child0.Insert(0, root_child0_child0);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(200f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
|
Assert.AreEqual(200f, root_child0_child0.LayoutWidth);
|
|
Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(200f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(-100f, root_child0_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
|
Assert.AreEqual(200f, root_child0_child0.LayoutWidth);
|
|
Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_nested_overflowing_child_in_constraint_parent()
|
|
{
|
|
YogaNode root = new YogaNode();
|
|
root.Width = 100;
|
|
root.Height = 100;
|
|
|
|
YogaNode root_child0 = new YogaNode();
|
|
root_child0.Width = 100;
|
|
root_child0.Height = 100;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child0_child0 = new YogaNode();
|
|
root_child0_child0.Width = 200;
|
|
root_child0_child0.Height = 200;
|
|
root_child0.Insert(0, root_child0_child0);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
|
Assert.AreEqual(200f, root_child0_child0.LayoutWidth);
|
|
Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(-100f, root_child0_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
|
Assert.AreEqual(200f, root_child0_child0.LayoutWidth);
|
|
Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_parent_wrap_child_size_overflowing_parent()
|
|
{
|
|
YogaNode root = new YogaNode();
|
|
root.Width = 100;
|
|
root.Height = 100;
|
|
|
|
YogaNode root_child0 = new YogaNode();
|
|
root_child0.Width = 100;
|
|
root.Insert(0, root_child0);
|
|
|
|
YogaNode root_child0_child0 = new YogaNode();
|
|
root_child0_child0.Width = 100;
|
|
root_child0_child0.Height = 200;
|
|
root_child0.Insert(0, root_child0_child0);
|
|
root.StyleDirection = YogaDirection.LTR;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(200f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
|
Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
|
|
Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
|
|
|
|
root.StyleDirection = YogaDirection.RTL;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0f, root.LayoutX);
|
|
Assert.AreEqual(0f, root.LayoutY);
|
|
Assert.AreEqual(100f, root.LayoutWidth);
|
|
Assert.AreEqual(100f, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
|
Assert.AreEqual(200f, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
|
Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
|
|
Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
|
|
}
|
|
|
|
}
|
|
}
|