Add unittest for percentage width inside absolute layout
Summary: Added unittest to constraint layout of percentage width inside absolute parent. See #454. Closes https://github.com/facebook/yoga/pull/456 Differential Revision: D4674103 Pulled By: emilsjolander fbshipit-source-id: 569a762e5a2b4ac80cd79bfbc9abfe57ada74dc9
This commit is contained in:
committed by
Facebook Github Bot
parent
af8d55c08e
commit
01bf8d7b6c
@@ -1146,5 +1146,76 @@ namespace Facebook.Yoga
|
||||
Assert.AreEqual(50f, root_child0_child0_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_percent_absolute_position()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.Width = 60;
|
||||
root.Height = 50;
|
||||
|
||||
YogaNode root_child0 = new YogaNode(config);
|
||||
root_child0.FlexDirection = YogaFlexDirection.Row;
|
||||
root_child0.PositionType = YogaPositionType.Absolute;
|
||||
root_child0.Left = 50.Percent();
|
||||
root_child0.Width = 100.Percent();
|
||||
root_child0.Height = 50;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child0_child0 = new YogaNode(config);
|
||||
root_child0_child0.Width = 100.Percent();
|
||||
root_child0.Insert(0, root_child0_child0);
|
||||
|
||||
YogaNode root_child0_child1 = new YogaNode(config);
|
||||
root_child0_child1.Width = 100.Percent();
|
||||
root_child0.Insert(1, root_child0_child1);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(60f, root.LayoutWidth);
|
||||
Assert.AreEqual(50f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(30f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(60f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(60f, root_child0_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child1.LayoutY);
|
||||
Assert.AreEqual(60f, root_child0_child1.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(60f, root.LayoutWidth);
|
||||
Assert.AreEqual(50f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(30f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(60f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(-60f, root_child0_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child1.LayoutY);
|
||||
Assert.AreEqual(60f, root_child0_child1.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user