2016-10-23 10:27:32 -07:00
|
|
|
/**
|
|
|
|
* 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);
|
2016-11-15 09:08:51 -08:00
|
|
|
root.StyleDirection = CSSDirection.LTR;
|
2016-10-23 10:27:32 -07:00
|
|
|
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);
|
|
|
|
|
2016-11-15 09:08:51 -08:00
|
|
|
root.StyleDirection = CSSDirection.RTL;
|
2016-10-23 10:27:32 -07:00
|
|
|
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);
|
2016-11-15 09:08:51 -08:00
|
|
|
root.StyleDirection = CSSDirection.LTR;
|
2016-10-23 10:27:32 -07:00
|
|
|
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);
|
|
|
|
|
2016-11-15 09:08:51 -08:00
|
|
|
root.StyleDirection = CSSDirection.RTL;
|
2016-10-23 10:27:32 -07:00
|
|
|
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);
|
2016-11-15 09:08:51 -08:00
|
|
|
root.StyleDirection = CSSDirection.LTR;
|
2016-10-23 10:27:32 -07:00
|
|
|
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);
|
|
|
|
|
2016-11-15 09:08:51 -08:00
|
|
|
root.StyleDirection = CSSDirection.RTL;
|
2016-10-23 10:27:32 -07:00
|
|
|
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);
|
2016-11-15 09:08:51 -08:00
|
|
|
root.StyleDirection = CSSDirection.LTR;
|
2016-10-23 10:27:32 -07:00
|
|
|
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);
|
|
|
|
|
2016-11-15 09:08:51 -08:00
|
|
|
root.StyleDirection = CSSDirection.RTL;
|
2016-10-23 10:27:32 -07:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|