Add generated tests
Summary: - Add Java and C# test code generated by gentest Reviewed By: emilsjolander Differential Revision: D4065904 fbshipit-source-id: c0d489f37ee0a3132185636812057dc95725d59a
This commit is contained in:
committed by
Facebook Github Bot
parent
dc5e613285
commit
ef538a45cd
266
csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs
Normal file
266
csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs
Normal file
@@ -0,0 +1,266 @@
|
||||
/**
|
||||
* 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.sh with the following input
|
||||
*
|
||||
<div id="absolute_layout_width_height_start_top" style="width: 100px; height: 100px;">
|
||||
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="absolute_layout_width_height_end_bottom" style="width: 100px; height: 100px;">
|
||||
<div style="width:10px; height: 10px; position: absolute; end: 10px; bottom: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="absolute_layout_start_top_end_bottom" style="width: 100px; height: 100px;">
|
||||
<div style="position: absolute; start: 10px; top: 10px; end: 10px; bottom: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="absolute_layout_width_height_start_top_end_bottom" style="width: 100px; height: 100px;">
|
||||
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px; end: 10px; bottom: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent" style="height: 50px; width: 50px; overflow: hidden; flex-direction: row;">
|
||||
<div style="position: absolute; start: 0; top: 0;">
|
||||
<div style="width: 100px; height: 100px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutAbsolutePositionTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_absolute_layout_width_height_start_top()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.PositionType = CSSPositionType.Absolute;
|
||||
root_child0.SetPosition(CSSEdge.Start, 10);
|
||||
root_child0.SetPosition(CSSEdge.Top, 10);
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_absolute_layout_width_height_end_bottom()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.PositionType = CSSPositionType.Absolute;
|
||||
root_child0.SetPosition(CSSEdge.End, 10);
|
||||
root_child0.SetPosition(CSSEdge.Bottom, 10);
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80, root_child0.LayoutX);
|
||||
Assert.AreEqual(80, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(80, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_absolute_layout_start_top_end_bottom()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.PositionType = CSSPositionType.Absolute;
|
||||
root_child0.SetPosition(CSSEdge.Start, 10);
|
||||
root_child0.SetPosition(CSSEdge.Top, 10);
|
||||
root_child0.SetPosition(CSSEdge.End, 10);
|
||||
root_child0.SetPosition(CSSEdge.Bottom, 10);
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(80, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(80, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_absolute_layout_width_height_start_top_end_bottom()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.PositionType = CSSPositionType.Absolute;
|
||||
root_child0.SetPosition(CSSEdge.Start, 10);
|
||||
root_child0.SetPosition(CSSEdge.Top, 10);
|
||||
root_child0.SetPosition(CSSEdge.End, 10);
|
||||
root_child0.SetPosition(CSSEdge.Bottom, 10);
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.Overflow = CSSOverflow.Hidden;
|
||||
root.StyleWidth = 50;
|
||||
root.StyleHeight = 50;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.PositionType = CSSPositionType.Absolute;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child0_child0 = new CSSNode();
|
||||
root_child0_child0.StyleWidth = 100;
|
||||
root_child0_child0.StyleHeight = 100;
|
||||
root_child0.Insert(0, root_child0_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(50, root.LayoutWidth);
|
||||
Assert.AreEqual(50, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(50, root.LayoutWidth);
|
||||
Assert.AreEqual(50, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(-50, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
450
csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs
Normal file
450
csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs
Normal file
@@ -0,0 +1,450 @@
|
||||
/**
|
||||
* 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.sh with the following input
|
||||
*
|
||||
<div id="align_content_flex_start" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: flex-start;">
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_content_flex_end" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: flex-end;">
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_content_center" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: center;">
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_content_stretch" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: stretch;">
|
||||
<div style="width: 50px;"></div>
|
||||
<div style="width: 50px;"></div>
|
||||
<div style="width: 50px;"></div>
|
||||
<div style="width: 50px;"></div>
|
||||
<div style="width: 50px;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutAlignContentTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_align_content_flex_start()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.Wrap = CSSWrap.Wrap;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 50;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 50;
|
||||
root_child1.StyleHeight = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 50;
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
CSSNode root_child3 = new CSSNode();
|
||||
root_child3.StyleWidth = 50;
|
||||
root_child3.StyleHeight = 10;
|
||||
root.Insert(3, root_child3);
|
||||
|
||||
CSSNode root_child4 = new CSSNode();
|
||||
root_child4.StyleWidth = 50;
|
||||
root_child4.StyleHeight = 10;
|
||||
root.Insert(4, root_child4);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(10, root_child1.LayoutY);
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(20, root_child2.LayoutY);
|
||||
Assert.AreEqual(50, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child3.LayoutX);
|
||||
Assert.AreEqual(30, root_child3.LayoutY);
|
||||
Assert.AreEqual(50, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child4.LayoutX);
|
||||
Assert.AreEqual(40, root_child4.LayoutY);
|
||||
Assert.AreEqual(50, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child4.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child1.LayoutX);
|
||||
Assert.AreEqual(10, root_child1.LayoutY);
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child2.LayoutX);
|
||||
Assert.AreEqual(20, root_child2.LayoutY);
|
||||
Assert.AreEqual(50, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child3.LayoutX);
|
||||
Assert.AreEqual(30, root_child3.LayoutY);
|
||||
Assert.AreEqual(50, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child4.LayoutX);
|
||||
Assert.AreEqual(40, root_child4.LayoutY);
|
||||
Assert.AreEqual(50, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child4.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_content_flex_end()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.AlignContent = CSSAlign.FlexEnd;
|
||||
root.Wrap = CSSWrap.Wrap;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 50;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 50;
|
||||
root_child1.StyleHeight = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 50;
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
CSSNode root_child3 = new CSSNode();
|
||||
root_child3.StyleWidth = 50;
|
||||
root_child3.StyleHeight = 10;
|
||||
root.Insert(3, root_child3);
|
||||
|
||||
CSSNode root_child4 = new CSSNode();
|
||||
root_child4.StyleWidth = 50;
|
||||
root_child4.StyleHeight = 10;
|
||||
root.Insert(4, root_child4);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(10, root_child1.LayoutY);
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(20, root_child2.LayoutY);
|
||||
Assert.AreEqual(50, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child3.LayoutX);
|
||||
Assert.AreEqual(30, root_child3.LayoutY);
|
||||
Assert.AreEqual(50, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child4.LayoutX);
|
||||
Assert.AreEqual(40, root_child4.LayoutY);
|
||||
Assert.AreEqual(50, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child4.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child1.LayoutX);
|
||||
Assert.AreEqual(10, root_child1.LayoutY);
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child2.LayoutX);
|
||||
Assert.AreEqual(20, root_child2.LayoutY);
|
||||
Assert.AreEqual(50, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child3.LayoutX);
|
||||
Assert.AreEqual(30, root_child3.LayoutY);
|
||||
Assert.AreEqual(50, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child4.LayoutX);
|
||||
Assert.AreEqual(40, root_child4.LayoutY);
|
||||
Assert.AreEqual(50, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child4.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_content_center()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.AlignContent = CSSAlign.Center;
|
||||
root.Wrap = CSSWrap.Wrap;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 50;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 50;
|
||||
root_child1.StyleHeight = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 50;
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
CSSNode root_child3 = new CSSNode();
|
||||
root_child3.StyleWidth = 50;
|
||||
root_child3.StyleHeight = 10;
|
||||
root.Insert(3, root_child3);
|
||||
|
||||
CSSNode root_child4 = new CSSNode();
|
||||
root_child4.StyleWidth = 50;
|
||||
root_child4.StyleHeight = 10;
|
||||
root.Insert(4, root_child4);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(10, root_child1.LayoutY);
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(20, root_child2.LayoutY);
|
||||
Assert.AreEqual(50, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child3.LayoutX);
|
||||
Assert.AreEqual(30, root_child3.LayoutY);
|
||||
Assert.AreEqual(50, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child4.LayoutX);
|
||||
Assert.AreEqual(40, root_child4.LayoutY);
|
||||
Assert.AreEqual(50, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child4.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child1.LayoutX);
|
||||
Assert.AreEqual(10, root_child1.LayoutY);
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child2.LayoutX);
|
||||
Assert.AreEqual(20, root_child2.LayoutY);
|
||||
Assert.AreEqual(50, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child3.LayoutX);
|
||||
Assert.AreEqual(30, root_child3.LayoutY);
|
||||
Assert.AreEqual(50, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child4.LayoutX);
|
||||
Assert.AreEqual(40, root_child4.LayoutY);
|
||||
Assert.AreEqual(50, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child4.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_content_stretch()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.AlignContent = CSSAlign.Stretch;
|
||||
root.Wrap = CSSWrap.Wrap;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 50;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 50;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 50;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
CSSNode root_child3 = new CSSNode();
|
||||
root_child3.StyleWidth = 50;
|
||||
root.Insert(3, root_child3);
|
||||
|
||||
CSSNode root_child4 = new CSSNode();
|
||||
root_child4.StyleWidth = 50;
|
||||
root.Insert(4, root_child4);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(0, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(0, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(50, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(0, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child3.LayoutX);
|
||||
Assert.AreEqual(0, root_child3.LayoutY);
|
||||
Assert.AreEqual(50, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(0, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child4.LayoutX);
|
||||
Assert.AreEqual(0, root_child4.LayoutY);
|
||||
Assert.AreEqual(50, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(0, root_child4.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(0, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(0, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(50, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(0, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child3.LayoutX);
|
||||
Assert.AreEqual(0, root_child3.LayoutY);
|
||||
Assert.AreEqual(50, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(0, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child4.LayoutX);
|
||||
Assert.AreEqual(0, root_child4.LayoutY);
|
||||
Assert.AreEqual(50, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(0, root_child4.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
194
csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs
Normal file
194
csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs
Normal file
@@ -0,0 +1,194 @@
|
||||
/**
|
||||
* 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.sh with the following input
|
||||
*
|
||||
<div id="align_items_stretch" style="width: 100px; height: 100px;">
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_items_center" style="width: 100px; height: 100px; align-items: center;">
|
||||
<div style="height: 10px; width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_items_flex_start" style="width: 100px; height: 100px; align-items: flex-start;">
|
||||
<div style="height: 10px; width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_items_flex_end" style="width: 100px; height: 100px; align-items: flex-end;">
|
||||
<div style="height: 10px; width: 10px;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutAlignItemsTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_align_items_stretch()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_items_center()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.AlignItems = CSSAlign.Center;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(45, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(45, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_items_flex_start()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.AlignItems = CSSAlign.FlexStart;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(90, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_items_flex_end()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.AlignItems = CSSAlign.FlexEnd;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(90, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
197
csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs
Normal file
197
csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs
Normal file
@@ -0,0 +1,197 @@
|
||||
/**
|
||||
* 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.sh with the following input
|
||||
*
|
||||
<div id="align_self_center" style="width:100px; height: 100px;">
|
||||
<div style="height: 10px; width: 10px; align-self: center;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_self_flex_end" style="width:100px; height: 100px;">
|
||||
<div style="height: 10px; width: 10px; align-self: flex-end;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_self_flex_start" style="width:100px; height: 100px;">
|
||||
<div style="height: 10px; width: 10px; align-self: flex-start;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_self_flex_end_override_flex_start" style="width:100px; height: 100px; align-items: flex-start;">
|
||||
<div style="height: 10px; width: 10px; align-self: flex-end;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutAlignSelfTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_align_self_center()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.AlignSelf = CSSAlign.Center;
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(45, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(45, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_self_flex_end()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.AlignSelf = CSSAlign.FlexEnd;
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(90, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_self_flex_start()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.AlignSelf = CSSAlign.FlexStart;
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(90, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_self_flex_end_override_flex_start()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.AlignItems = CSSAlign.FlexStart;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.AlignSelf = CSSAlign.FlexEnd;
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(90, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
234
csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs
Normal file
234
csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs
Normal file
@@ -0,0 +1,234 @@
|
||||
/**
|
||||
* 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.sh with the following input
|
||||
*
|
||||
<div id="border_no_size" style="border-width: 10px;">
|
||||
</div>
|
||||
|
||||
<div id="border_container_match_child" style="border-width: 10px;">
|
||||
<div style="width: 10px; height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="border_flex_child" style="width: 100px; height: 100px; border-width: 10px;">
|
||||
<div style="width: 10px; flex-grow:1"></div>
|
||||
</div>
|
||||
|
||||
<div id="border_stretch_child" style="width: 100px; height: 100px; border-width: 10px;">
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="border_center_child" style="width: 100px; height: 100px; border-start-width: 10px; border-top-width: 10; border-end-width: 20px; border-bottom-width: 20px; align-items: center; justify-content: center;">
|
||||
<div style="height: 10px; width: 10px;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutBorderTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_border_no_size()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetBorder(CSSEdge.Left, 10);
|
||||
root.SetBorder(CSSEdge.Top, 10);
|
||||
root.SetBorder(CSSEdge.Right, 10);
|
||||
root.SetBorder(CSSEdge.Bottom, 10);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(20, root.LayoutWidth);
|
||||
Assert.AreEqual(20, root.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(20, root.LayoutWidth);
|
||||
Assert.AreEqual(20, root.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_border_container_match_child()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetBorder(CSSEdge.Left, 10);
|
||||
root.SetBorder(CSSEdge.Top, 10);
|
||||
root.SetBorder(CSSEdge.Right, 10);
|
||||
root.SetBorder(CSSEdge.Bottom, 10);
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(30, root.LayoutWidth);
|
||||
Assert.AreEqual(30, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(30, root.LayoutWidth);
|
||||
Assert.AreEqual(30, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_border_flex_child()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetBorder(CSSEdge.Left, 10);
|
||||
root.SetBorder(CSSEdge.Top, 10);
|
||||
root.SetBorder(CSSEdge.Right, 10);
|
||||
root.SetBorder(CSSEdge.Bottom, 10);
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.StyleWidth = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_border_stretch_child()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetBorder(CSSEdge.Left, 10);
|
||||
root.SetBorder(CSSEdge.Top, 10);
|
||||
root.SetBorder(CSSEdge.Right, 10);
|
||||
root.SetBorder(CSSEdge.Bottom, 10);
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(80, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(80, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_border_center_child()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.JustifyContent = CSSJustify.Center;
|
||||
root.AlignItems = CSSAlign.Center;
|
||||
root.SetBorder(CSSEdge.Start, 10);
|
||||
root.SetBorder(CSSEdge.End, 20);
|
||||
root.SetBorder(CSSEdge.Bottom, 20);
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(40, root_child0.LayoutX);
|
||||
Assert.AreEqual(35, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child0.LayoutX);
|
||||
Assert.AreEqual(35, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
452
csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs
Normal file
452
csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs
Normal file
@@ -0,0 +1,452 @@
|
||||
/**
|
||||
* 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.sh with the following input
|
||||
*
|
||||
<div id="flex_direction_column_no_height" style="width: 100px">
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_direction_row_no_width" style="height: 100px; flex-direction: row;">
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_direction_column" style="height: 100px; width: 100px;">
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_direction_row" style="height: 100px; width: 100px; flex-direction: row;">
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_direction_column_reverse" style="height: 100px; width: 100px; flex-direction: column-reverse;">
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_direction_row_reverse" style="height: 100px; width: 100px; flex-direction: row-reverse;">
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutFlexDirectionTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_flex_direction_column_no_height()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleHeight = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(30, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(10, root_child1.LayoutY);
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(20, root_child2.LayoutY);
|
||||
Assert.AreEqual(100, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(30, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(10, root_child1.LayoutY);
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(20, root_child2.LayoutY);
|
||||
Assert.AreEqual(100, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_direction_row_no_width()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(30, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(10, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(20, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(30, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(20, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(10, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_direction_column()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleHeight = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(10, root_child1.LayoutY);
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(20, root_child2.LayoutY);
|
||||
Assert.AreEqual(100, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(10, root_child1.LayoutY);
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(20, root_child2.LayoutY);
|
||||
Assert.AreEqual(100, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_direction_row()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(10, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(20, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(90, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(10, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(70, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_direction_column_reverse()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.ColumnReverse;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleHeight = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(90, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(80, root_child1.LayoutY);
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(70, root_child2.LayoutY);
|
||||
Assert.AreEqual(100, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(90, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(80, root_child1.LayoutY);
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(70, root_child2.LayoutY);
|
||||
Assert.AreEqual(100, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_direction_row_reverse()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.RowReverse;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(90, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(10, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(70, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(10, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(20, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
403
csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs
Normal file
403
csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs
Normal file
@@ -0,0 +1,403 @@
|
||||
/**
|
||||
* 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.sh with the following input
|
||||
*
|
||||
<div id="flex_basis_flex_grow_column" style="width: 100px; height: 100px;">
|
||||
<div style="flex-basis: 50px; flex-grow: 1;"></div>
|
||||
<div style="flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_basis_flex_grow_row" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
<div style="flex-basis: 50px; flex-grow: 1;"></div>
|
||||
<div style="flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_basis_flex_shrink_column" style="width: 100px; height: 100px;">
|
||||
<div style="flex-basis: 100px; flex-shrink: 1;"></div>
|
||||
<div style="flex-basis: 50px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_basis_flex_shrink_row" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
<div style="flex-basis: 100px; flex-shrink: 1;"></div>
|
||||
<div style="flex-basis: 50px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_shrink_to_zero" style="height: 75px;">
|
||||
<div style="width: 50px; height: 50px; flex-shrink:0;"></div>
|
||||
<div style="width: 50px; height: 50px; flex-shrink:1;"></div>
|
||||
<div style="width: 50px; height: 50px; flex-shrink:0;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_basis_overrides_main_size" style="height: 100px; width: 100px;">
|
||||
<div style="height: 20px; flex-grow:1; flex-basis:50px;"></div>
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutFlexTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_flex_basis_flex_grow_column()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.FlexBasis = 50;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.FlexGrow = 1;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(75, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(75, root_child1.LayoutY);
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(25, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(75, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(75, root_child1.LayoutY);
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(25, root_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_basis_flex_grow_row()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.FlexBasis = 50;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.FlexGrow = 1;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(75, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(75, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(25, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(25, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(75, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(25, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_basis_flex_shrink_column()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.FlexShrink = 1;
|
||||
root_child0.FlexBasis = 100;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.FlexBasis = 50;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(50, root_child1.LayoutY);
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(50, root_child1.LayoutY);
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_basis_flex_shrink_row()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.FlexShrink = 1;
|
||||
root_child0.FlexBasis = 100;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.FlexBasis = 50;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_shrink_to_zero()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleHeight = 75;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 50;
|
||||
root_child0.StyleHeight = 50;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.FlexShrink = 1;
|
||||
root_child1.StyleWidth = 50;
|
||||
root_child1.StyleHeight = 50;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 50;
|
||||
root_child2.StyleHeight = 50;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(50, root.LayoutWidth);
|
||||
Assert.AreEqual(75, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(50, root_child1.LayoutY);
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(0, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(50, root_child2.LayoutY);
|
||||
Assert.AreEqual(50, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(50, root.LayoutWidth);
|
||||
Assert.AreEqual(75, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(50, root_child1.LayoutY);
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(0, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(50, root_child2.LayoutY);
|
||||
Assert.AreEqual(50, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_basis_overrides_main_size()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.FlexBasis = 50;
|
||||
root_child0.StyleHeight = 20;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.FlexGrow = 1;
|
||||
root_child1.StyleHeight = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.FlexGrow = 1;
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(60, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(60, root_child1.LayoutY);
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(20, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(80, root_child2.LayoutY);
|
||||
Assert.AreEqual(100, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(20, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(60, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(60, root_child1.LayoutY);
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(20, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(80, root_child2.LayoutY);
|
||||
Assert.AreEqual(100, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(20, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
389
csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs
Normal file
389
csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs
Normal file
@@ -0,0 +1,389 @@
|
||||
/**
|
||||
* 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.sh with the following input
|
||||
*
|
||||
<div id="wrap_column" style="height: 100px; flex-wrap: wrap">
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="wrap_row" style="width: 100px; flex-direction: row; flex-wrap: wrap">
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="wrap_row_align_items_flex_end" style="width: 100px; flex-direction: row; flex-wrap: wrap; align-items: flex-end;">
|
||||
<div style="height: 10px; width: 30px;"></div>
|
||||
<div style="height: 20px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="wrap_row_align_items_center" style="width: 100px; flex-direction: row; flex-wrap: wrap; align-items: center;">
|
||||
<div style="height: 10px; width: 30px;"></div>
|
||||
<div style="height: 20px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutFlexWrapTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_wrap_column()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.Wrap = CSSWrap.Wrap;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 30;
|
||||
root_child0.StyleHeight = 30;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 30;
|
||||
root_child1.StyleHeight = 30;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 30;
|
||||
root_child2.StyleHeight = 30;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
CSSNode root_child3 = new CSSNode();
|
||||
root_child3.StyleWidth = 30;
|
||||
root_child3.StyleHeight = 30;
|
||||
root.Insert(3, root_child3);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(60, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(30, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(30, root_child1.LayoutY);
|
||||
Assert.AreEqual(30, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(60, root_child2.LayoutY);
|
||||
Assert.AreEqual(30, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(30, root_child3.LayoutX);
|
||||
Assert.AreEqual(0, root_child3.LayoutY);
|
||||
Assert.AreEqual(30, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child3.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(60, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(30, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(30, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(30, root_child1.LayoutX);
|
||||
Assert.AreEqual(30, root_child1.LayoutY);
|
||||
Assert.AreEqual(30, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(30, root_child2.LayoutX);
|
||||
Assert.AreEqual(60, root_child2.LayoutY);
|
||||
Assert.AreEqual(30, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child3.LayoutX);
|
||||
Assert.AreEqual(0, root_child3.LayoutY);
|
||||
Assert.AreEqual(30, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child3.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_wrap_row()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.Wrap = CSSWrap.Wrap;
|
||||
root.StyleWidth = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 30;
|
||||
root_child0.StyleHeight = 30;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 30;
|
||||
root_child1.StyleHeight = 30;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 30;
|
||||
root_child2.StyleHeight = 30;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
CSSNode root_child3 = new CSSNode();
|
||||
root_child3.StyleWidth = 30;
|
||||
root_child3.StyleHeight = 30;
|
||||
root.Insert(3, root_child3);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(60, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(30, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(30, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(30, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(60, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(30, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child3.LayoutX);
|
||||
Assert.AreEqual(30, root_child3.LayoutY);
|
||||
Assert.AreEqual(30, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child3.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(60, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(70, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(30, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(40, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(30, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(30, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(70, root_child3.LayoutX);
|
||||
Assert.AreEqual(30, root_child3.LayoutY);
|
||||
Assert.AreEqual(30, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child3.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_wrap_row_align_items_flex_end()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.AlignItems = CSSAlign.FlexEnd;
|
||||
root.Wrap = CSSWrap.Wrap;
|
||||
root.StyleWidth = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 30;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 30;
|
||||
root_child1.StyleHeight = 20;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 30;
|
||||
root_child2.StyleHeight = 30;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
CSSNode root_child3 = new CSSNode();
|
||||
root_child3.StyleWidth = 30;
|
||||
root_child3.StyleHeight = 30;
|
||||
root.Insert(3, root_child3);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(60, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(20, root_child0.LayoutY);
|
||||
Assert.AreEqual(30, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(30, root_child1.LayoutX);
|
||||
Assert.AreEqual(10, root_child1.LayoutY);
|
||||
Assert.AreEqual(30, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(20, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(60, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(30, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child3.LayoutX);
|
||||
Assert.AreEqual(30, root_child3.LayoutY);
|
||||
Assert.AreEqual(30, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child3.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(60, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(70, root_child0.LayoutX);
|
||||
Assert.AreEqual(20, root_child0.LayoutY);
|
||||
Assert.AreEqual(30, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(40, root_child1.LayoutX);
|
||||
Assert.AreEqual(10, root_child1.LayoutY);
|
||||
Assert.AreEqual(30, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(20, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(30, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(70, root_child3.LayoutX);
|
||||
Assert.AreEqual(30, root_child3.LayoutY);
|
||||
Assert.AreEqual(30, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child3.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_wrap_row_align_items_center()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.AlignItems = CSSAlign.Center;
|
||||
root.Wrap = CSSWrap.Wrap;
|
||||
root.StyleWidth = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 30;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 30;
|
||||
root_child1.StyleHeight = 20;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 30;
|
||||
root_child2.StyleHeight = 30;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
CSSNode root_child3 = new CSSNode();
|
||||
root_child3.StyleWidth = 30;
|
||||
root_child3.StyleHeight = 30;
|
||||
root.Insert(3, root_child3);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(60, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(30, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(30, root_child1.LayoutX);
|
||||
Assert.AreEqual(5, root_child1.LayoutY);
|
||||
Assert.AreEqual(30, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(20, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(60, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(30, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child3.LayoutX);
|
||||
Assert.AreEqual(30, root_child3.LayoutY);
|
||||
Assert.AreEqual(30, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child3.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(60, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(70, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(30, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(40, root_child1.LayoutX);
|
||||
Assert.AreEqual(5, root_child1.LayoutY);
|
||||
Assert.AreEqual(30, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(20, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(30, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(70, root_child3.LayoutX);
|
||||
Assert.AreEqual(30, root_child3.LayoutY);
|
||||
Assert.AreEqual(30, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child3.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
746
csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs
Normal file
746
csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs
Normal file
@@ -0,0 +1,746 @@
|
||||
/**
|
||||
* 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.sh with the following input
|
||||
*
|
||||
<div id="justify_content_row_flex_start" style="width: 102px; height: 102px; flex-direction: row; justify-content: flex-start;">
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_row_flex_end" style="width: 102px; height: 102px; flex-direction: row; justify-content: flex-end;">
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_row_center" style="width: 102px; height: 102px; flex-direction: row; justify-content: center;">
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_row_space_between" style="width: 102px; height: 102px; flex-direction: row; justify-content: space-between;">
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_row_space_around" style="width: 102px; height: 102px; flex-direction: row; justify-content: space-around;">
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_column_flex_start" style="width: 102px; height: 102px; justify-content: flex-start;">
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="heigth: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_column_flex_end" style="width: 102px; height: 102px; justify-content: flex-end;">
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_column_center" style="width: 102px; height: 102px; justify-content: center;">
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_column_space_between" style="width: 102px; height: 102px; justify-content: space-between;">
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_column_space_around" style="width: 102px; height: 102px; justify-content: space-around;">
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutJustifyContentTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_justify_content_row_flex_start()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 102;
|
||||
root.StyleHeight = 102;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(10, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(20, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(92, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(82, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(10, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(72, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_row_flex_end()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.JustifyContent = CSSJustify.FlexEnd;
|
||||
root.StyleWidth = 102;
|
||||
root.StyleHeight = 102;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(72, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(82, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(10, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(92, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(20, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(10, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_row_center()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.JustifyContent = CSSJustify.Center;
|
||||
root.StyleWidth = 102;
|
||||
root.StyleHeight = 102;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(36, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(46, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(10, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(56, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(56, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(46, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(10, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(36, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_row_space_between()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.JustifyContent = CSSJustify.SpaceBetween;
|
||||
root.StyleWidth = 102;
|
||||
root.StyleHeight = 102;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(46, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(10, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(92, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(92, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(46, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(10, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_row_space_around()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.JustifyContent = CSSJustify.SpaceAround;
|
||||
root.StyleWidth = 102;
|
||||
root.StyleHeight = 102;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(12, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(46, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(10, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(46, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(10, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(12, root_child2.LayoutX);
|
||||
Assert.AreEqual(0, root_child2.LayoutY);
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_column_flex_start()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 102;
|
||||
root.StyleHeight = 102;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(102, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(10, root_child1.LayoutY);
|
||||
Assert.AreEqual(102, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(0, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(10, root_child2.LayoutY);
|
||||
Assert.AreEqual(102, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(102, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(10, root_child1.LayoutY);
|
||||
Assert.AreEqual(102, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(0, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(10, root_child2.LayoutY);
|
||||
Assert.AreEqual(102, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_column_flex_end()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.JustifyContent = CSSJustify.FlexEnd;
|
||||
root.StyleWidth = 102;
|
||||
root.StyleHeight = 102;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleHeight = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(72, root_child0.LayoutY);
|
||||
Assert.AreEqual(102, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(82, root_child1.LayoutY);
|
||||
Assert.AreEqual(102, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(92, root_child2.LayoutY);
|
||||
Assert.AreEqual(102, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(72, root_child0.LayoutY);
|
||||
Assert.AreEqual(102, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(82, root_child1.LayoutY);
|
||||
Assert.AreEqual(102, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(92, root_child2.LayoutY);
|
||||
Assert.AreEqual(102, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_column_center()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.JustifyContent = CSSJustify.Center;
|
||||
root.StyleWidth = 102;
|
||||
root.StyleHeight = 102;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleHeight = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(36, root_child0.LayoutY);
|
||||
Assert.AreEqual(102, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(46, root_child1.LayoutY);
|
||||
Assert.AreEqual(102, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(56, root_child2.LayoutY);
|
||||
Assert.AreEqual(102, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(36, root_child0.LayoutY);
|
||||
Assert.AreEqual(102, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(46, root_child1.LayoutY);
|
||||
Assert.AreEqual(102, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(56, root_child2.LayoutY);
|
||||
Assert.AreEqual(102, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_column_space_between()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.JustifyContent = CSSJustify.SpaceBetween;
|
||||
root.StyleWidth = 102;
|
||||
root.StyleHeight = 102;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleHeight = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(102, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(46, root_child1.LayoutY);
|
||||
Assert.AreEqual(102, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(92, root_child2.LayoutY);
|
||||
Assert.AreEqual(102, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(102, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(46, root_child1.LayoutY);
|
||||
Assert.AreEqual(102, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(92, root_child2.LayoutY);
|
||||
Assert.AreEqual(102, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_column_space_around()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.JustifyContent = CSSJustify.SpaceAround;
|
||||
root.StyleWidth = 102;
|
||||
root.StyleHeight = 102;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleHeight = 10;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(12, root_child0.LayoutY);
|
||||
Assert.AreEqual(102, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(46, root_child1.LayoutY);
|
||||
Assert.AreEqual(102, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(80, root_child2.LayoutY);
|
||||
Assert.AreEqual(102, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(102, root.LayoutWidth);
|
||||
Assert.AreEqual(102, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(12, root_child0.LayoutY);
|
||||
Assert.AreEqual(102, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(46, root_child1.LayoutY);
|
||||
Assert.AreEqual(102, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(80, root_child2.LayoutY);
|
||||
Assert.AreEqual(102, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
479
csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs
Normal file
479
csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs
Normal file
@@ -0,0 +1,479 @@
|
||||
/**
|
||||
* 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.sh with the following input
|
||||
*
|
||||
<div id="margin_start" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
<div style="width: 10px; margin-start: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="margin_top" style="width: 100px; height: 100px;">
|
||||
<div style="height: 10px; margin-top: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="margin_end" style="width: 100px; height: 100px; flex-direction: row; justify-content: flex-end;">
|
||||
<div style="width: 10px; margin-end: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="margin_bottom" style="width: 100px; height: 100px; justify-content: flex-end;">
|
||||
<div style="height: 10px; margin-bottom: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="margin_and_flex_row" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
<div style="margin-start: 10px; margin-end; 10px; flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="margin_and_flex_column" style="width: 100px; height: 100px;">
|
||||
<div style="margin-top: 10px; margin-bottom; 10px; flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="margin_and_stretch_row" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
<div style="margin-top: 10px; margin-bottom; 10px; flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="margin_and_stretch_column" style="width: 100px; height: 100px;">
|
||||
<div style="margin-start: 10px; margin-end; 10px; flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="margin_with_sibling_row" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
<div style="margin-end; 10px; flex-grow: 1;"></div>
|
||||
<div style="flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="margin_with_sibling_column" style="width: 100px; height: 100px;">
|
||||
<div style="margin-bottom; 10px; flex-grow: 1;"></div>
|
||||
<div style="flex-grow: 1;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutMarginTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_margin_start()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.SetMargin(CSSEdge.Start, 10);
|
||||
root_child0.StyleWidth = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_margin_top()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.SetMargin(CSSEdge.Top, 10);
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_margin_end()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.JustifyContent = CSSJustify.FlexEnd;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.SetMargin(CSSEdge.End, 10);
|
||||
root_child0.StyleWidth = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_margin_bottom()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.JustifyContent = CSSJustify.FlexEnd;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.SetMargin(CSSEdge.Bottom, 10);
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(80, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(80, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_margin_and_flex_row()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.SetMargin(CSSEdge.Start, 10);
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(90, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(90, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_margin_and_flex_column()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.SetMargin(CSSEdge.Top, 10);
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(90, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(90, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_margin_and_stretch_row()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.SetMargin(CSSEdge.Top, 10);
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(90, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(90, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_margin_and_stretch_column()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.SetMargin(CSSEdge.Start, 10);
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(90, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(90, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_margin_with_sibling_row()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.FlexGrow = 1;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.FlexGrow = 1;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_margin_with_sibling_column()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.FlexGrow = 1;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.FlexGrow = 1;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(50, root_child1.LayoutY);
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(50, root_child1.LayoutY);
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
387
csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs
Normal file
387
csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs
Normal file
@@ -0,0 +1,387 @@
|
||||
/**
|
||||
* 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.sh with the following input
|
||||
*
|
||||
<div id="max_width" style="width: 100px; height: 100px;">
|
||||
<div style="height: 10px; max-width: 50px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="max_height" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
<div style="width: 10px; max-height: 50px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="min_height" style="width: 100px; height: 100px;">
|
||||
<div style="flex-grow: 1; min-height: 60px;"></div>
|
||||
<div style="flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="min_width" style="width: 100px; height: 100px; flex-direction: row">
|
||||
<div style="flex-grow: 1; min-width: 60px;"></div>
|
||||
<div style="flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_min_max" style="max-height: 200px; min-height: 100px; width: 100px; justify-content: center;">
|
||||
<div style="width: 60px; height: 60px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_items_min_max" style="max-width: 200px; min-width: 100px; height: 100px; align-items: center;">
|
||||
<div style="width: 60px; height: 60px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_overflow_min_max" style="min-height: 100px; max-height: 110px; justify-content: center;">
|
||||
<div style="width: 50px; height: 50px;"></div>
|
||||
<div style="width: 50px; height: 50px;"></div>
|
||||
<div style="width: 50px; height: 50px;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutMinMaxDimensionTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_max_width()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleMaxWidth = 50;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_max_height()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleMaxHeight = 50;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(90, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_min_height()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.StyleMinHeight = 60;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.FlexGrow = 1;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(80, root_child1.LayoutY);
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(20, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(80, root_child1.LayoutY);
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(20, root_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_min_width()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.StyleMinWidth = 60;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.FlexGrow = 1;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(80, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(20, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(20, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(80, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(0, root_child1.LayoutY);
|
||||
Assert.AreEqual(20, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_min_max()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.JustifyContent = CSSJustify.Center;
|
||||
root.StyleWidth = 100;
|
||||
root.StyleMinHeight = 100;
|
||||
root.StyleMaxHeight = 200;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 60;
|
||||
root_child0.StyleHeight = 60;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(20, root_child0.LayoutY);
|
||||
Assert.AreEqual(60, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(60, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(40, root_child0.LayoutX);
|
||||
Assert.AreEqual(20, root_child0.LayoutY);
|
||||
Assert.AreEqual(60, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(60, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_items_min_max()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.AlignItems = CSSAlign.Center;
|
||||
root.StyleMinWidth = 100;
|
||||
root.StyleMaxWidth = 200;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 60;
|
||||
root_child0.StyleHeight = 60;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(20, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(60, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(60, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(20, root_child0.LayoutX);
|
||||
Assert.AreEqual(0, root_child0.LayoutY);
|
||||
Assert.AreEqual(60, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(60, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_overflow_min_max()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.JustifyContent = CSSJustify.Center;
|
||||
root.StyleMinHeight = 100;
|
||||
root.StyleMaxHeight = 110;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 50;
|
||||
root_child0.StyleHeight = 50;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 50;
|
||||
root_child1.StyleHeight = 50;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 50;
|
||||
root_child2.StyleHeight = 50;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(50, root.LayoutWidth);
|
||||
Assert.AreEqual(110, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(-20, root_child0.LayoutY);
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(30, root_child1.LayoutY);
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(80, root_child2.LayoutY);
|
||||
Assert.AreEqual(50, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(50, root.LayoutWidth);
|
||||
Assert.AreEqual(110, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child0.LayoutX);
|
||||
Assert.AreEqual(-20, root_child0.LayoutY);
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child1.LayoutX);
|
||||
Assert.AreEqual(30, root_child1.LayoutY);
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0, root_child2.LayoutX);
|
||||
Assert.AreEqual(80, root_child2.LayoutY);
|
||||
Assert.AreEqual(50, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
234
csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs
Normal file
234
csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs
Normal file
@@ -0,0 +1,234 @@
|
||||
/**
|
||||
* 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.sh with the following input
|
||||
*
|
||||
<div id="padding_no_size" style="padding: 10px;">
|
||||
</div>
|
||||
|
||||
<div id="padding_container_match_child" style="padding: 10px;">
|
||||
<div style="width: 10px; height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="padding_flex_child" style="width: 100px; height: 100px; padding: 10px;">
|
||||
<div style="width: 10px; flex-grow:1"></div>
|
||||
</div>
|
||||
|
||||
<div id="padding_stretch_child" style="width: 100px; height: 100px; padding: 10px;">
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="padding_center_child" style="width: 100px; height: 100px; padding-start: 10px; padding-top: 10; padding-end: 20px; padding-bottom: 20px; align-items: center; justify-content: center;">
|
||||
<div style="height: 10px; width: 10px;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutPaddingTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_padding_no_size()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetPadding(CSSEdge.Left, 10);
|
||||
root.SetPadding(CSSEdge.Top, 10);
|
||||
root.SetPadding(CSSEdge.Right, 10);
|
||||
root.SetPadding(CSSEdge.Bottom, 10);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(20, root.LayoutWidth);
|
||||
Assert.AreEqual(20, root.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(20, root.LayoutWidth);
|
||||
Assert.AreEqual(20, root.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_padding_container_match_child()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetPadding(CSSEdge.Left, 10);
|
||||
root.SetPadding(CSSEdge.Top, 10);
|
||||
root.SetPadding(CSSEdge.Right, 10);
|
||||
root.SetPadding(CSSEdge.Bottom, 10);
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(30, root.LayoutWidth);
|
||||
Assert.AreEqual(30, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(30, root.LayoutWidth);
|
||||
Assert.AreEqual(30, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_padding_flex_child()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetPadding(CSSEdge.Left, 10);
|
||||
root.SetPadding(CSSEdge.Top, 10);
|
||||
root.SetPadding(CSSEdge.Right, 10);
|
||||
root.SetPadding(CSSEdge.Bottom, 10);
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.StyleWidth = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_padding_stretch_child()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetPadding(CSSEdge.Left, 10);
|
||||
root.SetPadding(CSSEdge.Top, 10);
|
||||
root.SetPadding(CSSEdge.Right, 10);
|
||||
root.SetPadding(CSSEdge.Bottom, 10);
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(80, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10, root_child0.LayoutX);
|
||||
Assert.AreEqual(10, root_child0.LayoutY);
|
||||
Assert.AreEqual(80, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_padding_center_child()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.JustifyContent = CSSJustify.Center;
|
||||
root.AlignItems = CSSAlign.Center;
|
||||
root.SetPadding(CSSEdge.Start, 10);
|
||||
root.SetPadding(CSSEdge.End, 20);
|
||||
root.SetPadding(CSSEdge.Bottom, 20);
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(40, root_child0.LayoutX);
|
||||
Assert.AreEqual(35, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
Assert.AreEqual(0, root.LayoutY);
|
||||
Assert.AreEqual(100, root.LayoutWidth);
|
||||
Assert.AreEqual(100, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50, root_child0.LayoutX);
|
||||
Assert.AreEqual(35, root_child0.LayoutY);
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user