C# Baseline function
Summary: same as Measure function, based on #317 Closes https://github.com/facebook/yoga/pull/321 Reviewed By: emilsjolander Differential Revision: D4385336 Pulled By: splhack fbshipit-source-id: b583ec79861d2e9abba31a72503e2f706bfda8e8
This commit is contained in:
committed by
Facebook Github Bot
parent
8d320ceac2
commit
70a4221b9e
@@ -197,6 +197,54 @@ namespace Facebook.Yoga
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBaselineFunc()
|
||||
{
|
||||
YogaNode node = new YogaNode();
|
||||
node.Height = 200;
|
||||
node.FlexDirection = YogaFlexDirection.Row;
|
||||
node.AlignItems = YogaAlign.Baseline;
|
||||
|
||||
YogaNode child0 = new YogaNode();
|
||||
child0.Width = 100;
|
||||
child0.Height = 110;
|
||||
child0.SetBaselineFunction((_, width, height) => {
|
||||
Assert.AreEqual(100, width);
|
||||
Assert.AreEqual(110, height);
|
||||
return 65;
|
||||
});
|
||||
node.Insert(0, child0);
|
||||
|
||||
YogaNode child1 = new YogaNode();
|
||||
child1.Width = 100;
|
||||
child1.Height = 110;
|
||||
child1.SetBaselineFunction((_, width, height) => {
|
||||
Assert.AreEqual(100, width);
|
||||
Assert.AreEqual(110, height);
|
||||
return 80;
|
||||
});
|
||||
node.Insert(1, child1);
|
||||
|
||||
YogaNode child2 = new YogaNode();
|
||||
child2.Width = 100;
|
||||
child2.Height = 110;
|
||||
child2.SetBaselineFunction((_, width, height) => {
|
||||
Assert.AreEqual(100, width);
|
||||
Assert.AreEqual(110, height);
|
||||
return 88;
|
||||
});
|
||||
node.Insert(2, child2);
|
||||
|
||||
node.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, child0.LayoutX);
|
||||
Assert.AreEqual(23, child0.LayoutY);
|
||||
Assert.AreEqual(100, child1.LayoutX);
|
||||
Assert.AreEqual(8, child1.LayoutY);
|
||||
Assert.AreEqual(200, child2.LayoutX);
|
||||
Assert.AreEqual(0, child2.LayoutY);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPrint()
|
||||
{
|
||||
|
Reference in New Issue
Block a user