Add feature to use percentage as value unit #258

Closed
woehrl01 wants to merge 43 commits from percentage-feature into master
41 changed files with 4450 additions and 1110 deletions

6
.gitignore vendored
View File

@@ -8,6 +8,12 @@
# Visual studio code
.vscode
*.pdb
emilsjolander commented 2016-12-23 13:48:55 -08:00 (Migrated from github.com)
Review

please mirror these changes in .hgignore

please mirror these changes in .hgignore
*.tlog
*.obj
*.pch
*.log
*.orig
# Xcode
## Build generated

View File

@@ -8,6 +8,12 @@
# Visual studio code
.vscode
*.pdb
*.tlog
*.obj
*.pch
*.log
*.orig
# Xcode
## Build generated

View File

@@ -0,0 +1,31 @@
/**
* 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.
*/
namespace Facebook.Yoga
{
public class Border
{
public float? Top;
public float? Bottom;
public float? Left;
public float? Right;
public Border(
float? top = null,
float? bottom = null,
float? left = null,
float? right = null)
{
Top = top;
Bottom = bottom;
Left = left;
Right = right;
}
}
}

View File

@@ -197,43 +197,64 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetFlexBasis(YGNodeHandle node, float flexBasis);
[DllImport(DllName)]
public static extern float YGNodeStyleGetFlexBasis(YGNodeHandle node);
public static extern void YGNodeStyleSetFlexBasisPercent(YGNodeHandle node, float flexBasis);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetFlexBasis(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width);
[DllImport(DllName)]
public static extern float YGNodeStyleGetWidth(YGNodeHandle node);
public static extern void YGNodeStyleSetWidthPercent(YGNodeHandle node, float width);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetWidth(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height);
[DllImport(DllName)]
public static extern float YGNodeStyleGetHeight(YGNodeHandle node);
public static extern void YGNodeStyleSetHeightPercent(YGNodeHandle node, float height);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetHeight(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth);
[DllImport(DllName)]
public static extern float YGNodeStyleGetMinWidth(YGNodeHandle node);
public static extern void YGNodeStyleSetMinWidthPercent(YGNodeHandle node, float minWidth);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetMinWidth(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight);
[DllImport(DllName)]
public static extern float YGNodeStyleGetMinHeight(YGNodeHandle node);
public static extern void YGNodeStyleSetMinHeightPercent(YGNodeHandle node, float minHeight);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetMinHeight(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth);
[DllImport(DllName)]
public static extern float YGNodeStyleGetMaxWidth(YGNodeHandle node);
public static extern void YGNodeStyleSetMaxWidthPercent(YGNodeHandle node, float maxWidth);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetMaxWidth(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight);
[DllImport(DllName)]
public static extern float YGNodeStyleGetMaxHeight(YGNodeHandle node);
public static extern void YGNodeStyleSetMaxHeightPercent(YGNodeHandle node, float maxHeight);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetMaxHeight(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetAspectRatio(YGNodeHandle node, float aspectRatio);
@@ -249,19 +270,28 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetPosition(YGNodeHandle node, YogaEdge edge, float position);
[DllImport(DllName)]
public static extern float YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge);
public static extern void YGNodeStyleSetPositionPercent(YGNodeHandle node, YogaEdge edge, float position);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName)]
public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin);
[DllImport(DllName)]
public static extern float YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge);
public static extern void YGNodeStyleSetMarginPercent(YGNodeHandle node, YogaEdge edge, float margin);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName)]
public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding);
[DllImport(DllName)]
public static extern float YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge);
public static extern void YGNodeStyleSetPaddingPercent(YGNodeHandle node, YogaEdge edge, float padding);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName)]
public static extern void YGNodeStyleSetBorder(YGNodeHandle node, YogaEdge edge, float border);

View File

@@ -11,16 +11,16 @@ namespace Facebook.Yoga
{
public class Spacing
{
public float? Top;
public float? Bottom;
public float? Left;
public float? Right;
public YogaValue? Top;
public YogaValue? Bottom;
public YogaValue? Left;
public YogaValue? Right;
public Spacing(
float? top = null,
float? bottom = null,
float? left = null,
float? right = null)
YogaValue? top = null,
YogaValue? bottom = null,
YogaValue? left = null,
YogaValue? right = null)
{
Top = top;
Bottom = bottom;

View File

@@ -17,5 +17,10 @@ namespace Facebook.Yoga
{
return float.IsNaN(value);
}
public static bool IsUndefined(YogaValue value)
{
return value.Unit == YogaUnit.Undefined;
}
}
}

View File

@@ -26,17 +26,17 @@ namespace Facebook.Yoga
float? flex = null,
float? flexGrow = null,
float? flexShrink = null,
float? flexBasis = null,
YogaValue? flexBasis = null,
Spacing position = null,
Spacing margin = null,
Spacing padding = null,
Spacing border = null,
float? width = null,
float? height = null,
float? maxWidth = null,
float? maxHeight = null,
float? minWidth = null,
float? minHeight = null)
Border border = null,
YogaValue? width = null,
YogaValue? height = null,
YogaValue? maxWidth = null,
YogaValue? maxHeight = null,
YogaValue? minWidth = null,
YogaValue? minHeight = null)
{
YogaNode node = new YogaNode();

View File

@@ -10,7 +10,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace Facebook.Yoga
@@ -228,7 +227,7 @@ namespace Facebook.Yoga
}
}
public float FlexBasis
public YogaValue FlexBasis
{
get
{
@@ -237,28 +236,49 @@ namespace Facebook.Yoga
set
{
Native.YGNodeStyleSetFlexBasis(_ygNode, value);
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetFlexBasisPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetFlexBasis(_ygNode, value.Value);
}
}
}
public float GetMargin(YogaEdge edge)
public YogaValue GetMargin(YogaEdge edge)
{
return Native.YGNodeStyleGetMargin(_ygNode, edge);
}
public void SetMargin(YogaEdge edge, float value)
public void SetMargin(YogaEdge edge, YogaValue value)
{
Native.YGNodeStyleSetMargin(_ygNode, edge, value);
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetMarginPercent(_ygNode, edge, value.Value);
}
else
{
Native.YGNodeStyleSetMargin(_ygNode, edge, value.Value);
}
}
public float GetPadding(YogaEdge edge)
public YogaValue GetPadding(YogaEdge edge)
{
return Native.YGNodeStyleGetPadding(_ygNode, edge);
}
public void SetPadding(YogaEdge edge, float padding)
public void SetPadding(YogaEdge edge, YogaValue value)
{
Native.YGNodeStyleSetPadding(_ygNode, edge, padding);
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetPaddingPercent(_ygNode, edge, value.Value);
}
else
{
Native.YGNodeStyleSetPadding(_ygNode, edge, value.Value);
}
}
public float GetBorder(YogaEdge edge)
@@ -271,17 +291,24 @@ namespace Facebook.Yoga
Native.YGNodeStyleSetBorder(_ygNode, edge, border);
}
public float GetPosition(YogaEdge edge)
public YogaValue GetPosition(YogaEdge edge)
{
return Native.YGNodeStyleGetPosition(_ygNode, edge);
}
public void SetPosition(YogaEdge edge, float position)
public void SetPosition(YogaEdge edge, YogaValue value)
{
Native.YGNodeStyleSetPosition(_ygNode, edge, position);
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetPositionPercent(_ygNode, edge, value.Value);
}
else
{
Native.YGNodeStyleSetPosition(_ygNode, edge, value.Value);
}
}
public float Width
public YogaValue Width
{
get
{
@@ -290,11 +317,18 @@ namespace Facebook.Yoga
set
{
Native.YGNodeStyleSetWidth(_ygNode, value);
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetWidthPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetWidth(_ygNode, value.Value);
}
}
}
public float Height
public YogaValue Height
{
get
{
@@ -303,11 +337,18 @@ namespace Facebook.Yoga
set
{
Native.YGNodeStyleSetHeight(_ygNode, value);
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetHeightPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetHeight(_ygNode, value.Value);
}
}
}
public float MaxWidth
public YogaValue MaxWidth
{
get
{
@@ -316,11 +357,18 @@ namespace Facebook.Yoga
set
{
Native.YGNodeStyleSetMaxWidth(_ygNode, value);
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetMaxWidthPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetMaxWidth(_ygNode, value.Value);
}
}
}
public float MaxHeight
public YogaValue MaxHeight
{
get
{
@@ -329,11 +377,18 @@ namespace Facebook.Yoga
set
{
Native.YGNodeStyleSetMaxHeight(_ygNode, value);
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetMaxHeightPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetMaxHeight(_ygNode, value.Value);
}
}
}
public float MinWidth
public YogaValue MinWidth
{
get
{
@@ -342,11 +397,18 @@ namespace Facebook.Yoga
set
{
Native.YGNodeStyleSetMinWidth(_ygNode, value);
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetMinWidthPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetMinWidth(_ygNode, value.Value);
}
}
}
public float MinHeight
public YogaValue MinHeight
{
get
{
@@ -355,7 +417,14 @@ namespace Facebook.Yoga
set
{
Native.YGNodeStyleSetMinHeight(_ygNode, value);
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetMinHeightPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetMinHeight(_ygNode, value.Value);
}
}
}

View File

@@ -0,0 +1,18 @@
/**
* 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.
*/
namespace Facebook.Yoga
{
public enum YogaUnit
{
Undefined,
Pixel,
Percent
}
}

View File

@@ -0,0 +1,74 @@
/**
* 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.
*/
using System.Runtime.InteropServices;
namespace Facebook.Yoga
{
[StructLayout(LayoutKind.Sequential)]
public struct YogaValue
{
private float value;
private YogaUnit unit;
public YogaUnit Unit => unit;
public float Value => value;
public static YogaValue Pixel(float value)
{
return new YogaValue
{
value = value,
unit = YogaConstants.IsUndefined(value) ? YogaUnit.Undefined : YogaUnit.Pixel
};
}
public bool Equals(YogaValue other)
{
return Unit == other.Unit && (Value.Equals(other.Value) || Unit == YogaUnit.Undefined);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
return obj is YogaValue && Equals((YogaValue) obj);
}
public override int GetHashCode()
{
unchecked
{
return (Value.GetHashCode() * 397) ^ (int) Unit;
}
}
public static YogaValue Undefined()
{
return new YogaValue
{
value = YogaConstants.Undefined,
unit = YogaUnit.Undefined
};
}
public static YogaValue Percent(float value)
{
return new YogaValue
{
value = value,
unit = YogaConstants.IsUndefined(value) ? YogaUnit.Undefined : YogaUnit.Percent
};
}
public static implicit operator YogaValue(float pixelValue)
{
return Pixel(pixelValue);
}
}
}

View File

@@ -0,0 +1,34 @@
/**
* 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.
*/
namespace Facebook.Yoga
{
public static class YogaValueExtensions
{
public static YogaValue Percent(this float value)
{
return YogaValue.Percent(value);
}
public static YogaValue Px(this float value)
{
return YogaValue.Pixel(value);
}
public static YogaValue Percent(this int value)
{
return YogaValue.Percent(value);
}
public static YogaValue Px(this int value)
{
return YogaValue.Pixel(value);
}
}
}

View File

@@ -21,15 +21,15 @@ namespace Facebook.Yoga
public void Test_absolute_layout_width_height_start_top()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.Start, 10f);
root_child0.SetPosition(YogaEdge.Top, 10f);
root_child0.Width = 10f;
root_child0.Height = 10f;
root_child0.SetPosition(YogaEdge.Start, 10);
root_child0.SetPosition(YogaEdge.Top, 10);
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -62,15 +62,15 @@ namespace Facebook.Yoga
public void Test_absolute_layout_width_height_end_bottom()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.End, 10f);
root_child0.SetPosition(YogaEdge.Bottom, 10f);
root_child0.Width = 10f;
root_child0.Height = 10f;
root_child0.SetPosition(YogaEdge.End, 10);
root_child0.SetPosition(YogaEdge.Bottom, 10);
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -103,15 +103,15 @@ namespace Facebook.Yoga
public void Test_absolute_layout_start_top_end_bottom()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.Start, 10f);
root_child0.SetPosition(YogaEdge.Top, 10f);
root_child0.SetPosition(YogaEdge.End, 10f);
root_child0.SetPosition(YogaEdge.Bottom, 10f);
root_child0.SetPosition(YogaEdge.Start, 10);
root_child0.SetPosition(YogaEdge.Top, 10);
root_child0.SetPosition(YogaEdge.End, 10);
root_child0.SetPosition(YogaEdge.Bottom, 10);
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -144,17 +144,17 @@ namespace Facebook.Yoga
public void Test_absolute_layout_width_height_start_top_end_bottom()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.Start, 10f);
root_child0.SetPosition(YogaEdge.Top, 10f);
root_child0.SetPosition(YogaEdge.End, 10f);
root_child0.SetPosition(YogaEdge.Bottom, 10f);
root_child0.Width = 10f;
root_child0.Height = 10f;
root_child0.SetPosition(YogaEdge.Start, 10);
root_child0.SetPosition(YogaEdge.Top, 10);
root_child0.SetPosition(YogaEdge.End, 10);
root_child0.SetPosition(YogaEdge.Bottom, 10);
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -189,18 +189,18 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Overflow = YogaOverflow.Hidden;
root.Width = 50f;
root.Height = 50f;
root.Width = 50;
root.Height = 50;
YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.Start, 0f);
root_child0.SetPosition(YogaEdge.Top, 0f);
root_child0.SetPosition(YogaEdge.Start, 0);
root_child0.SetPosition(YogaEdge.Top, 0);
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.Width = 100f;
root_child0_child0.Height = 100f;
root_child0_child0.Width = 100;
root_child0_child0.Height = 100;
root_child0.Insert(0, root_child0_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -243,35 +243,35 @@ namespace Facebook.Yoga
public void Test_absolute_layout_within_border()
{
YogaNode root = new YogaNode();
root.SetMargin(YogaEdge.Left, 10f);
root.SetMargin(YogaEdge.Top, 10f);
root.SetMargin(YogaEdge.Right, 10f);
root.SetMargin(YogaEdge.Bottom, 10f);
root.SetPadding(YogaEdge.Left, 10f);
root.SetPadding(YogaEdge.Top, 10f);
root.SetPadding(YogaEdge.Right, 10f);
root.SetPadding(YogaEdge.Bottom, 10f);
root.SetBorder(YogaEdge.Left, 10f);
root.SetBorder(YogaEdge.Top, 10f);
root.SetBorder(YogaEdge.Right, 10f);
root.SetBorder(YogaEdge.Bottom, 10f);
root.Width = 100f;
root.Height = 100f;
root.SetMargin(YogaEdge.Left, 10);
root.SetMargin(YogaEdge.Top, 10);
root.SetMargin(YogaEdge.Right, 10);
root.SetMargin(YogaEdge.Bottom, 10);
root.SetPadding(YogaEdge.Left, 10);
root.SetPadding(YogaEdge.Top, 10);
root.SetPadding(YogaEdge.Right, 10);
root.SetPadding(YogaEdge.Bottom, 10);
root.SetBorder(YogaEdge.Left, 10);
root.SetBorder(YogaEdge.Top, 10);
root.SetBorder(YogaEdge.Right, 10);
root.SetBorder(YogaEdge.Bottom, 10);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.Left, 0f);
root_child0.SetPosition(YogaEdge.Top, 0f);
root_child0.Width = 50f;
root_child0.Height = 50f;
root_child0.SetPosition(YogaEdge.Left, 0);
root_child0.SetPosition(YogaEdge.Top, 0);
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.PositionType = YogaPositionType.Absolute;
root_child1.SetPosition(YogaEdge.Right, 0f);
root_child1.SetPosition(YogaEdge.Bottom, 0f);
root_child1.Width = 50f;
root_child1.Height = 50f;
root_child1.SetPosition(YogaEdge.Right, 0);
root_child1.SetPosition(YogaEdge.Bottom, 0);
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();

View File

@@ -22,32 +22,32 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.Wrap = YogaWrap.Wrap;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 50f;
root_child0.Height = 10f;
root_child0.Width = 50;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 50f;
root_child1.Height = 10f;
root_child1.Width = 50;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Width = 50f;
root_child2.Height = 10f;
root_child2.Width = 50;
root_child2.Height = 10;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
root_child3.Width = 50f;
root_child3.Height = 10f;
root_child3.Width = 50;
root_child3.Height = 10;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
root_child4.Width = 50f;
root_child4.Height = 10f;
root_child4.Width = 50;
root_child4.Height = 10;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -122,32 +122,32 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.AlignContent = YogaAlign.FlexEnd;
root.Wrap = YogaWrap.Wrap;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 50f;
root_child0.Height = 10f;
root_child0.Width = 50;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 50f;
root_child1.Height = 10f;
root_child1.Width = 50;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Width = 50f;
root_child2.Height = 10f;
root_child2.Width = 50;
root_child2.Height = 10;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
root_child3.Width = 50f;
root_child3.Height = 10f;
root_child3.Width = 50;
root_child3.Height = 10;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
root_child4.Width = 50f;
root_child4.Height = 10f;
root_child4.Width = 50;
root_child4.Height = 10;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -222,32 +222,32 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.AlignContent = YogaAlign.Center;
root.Wrap = YogaWrap.Wrap;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 50f;
root_child0.Height = 10f;
root_child0.Width = 50;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 50f;
root_child1.Height = 10f;
root_child1.Width = 50;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Width = 50f;
root_child2.Height = 10f;
root_child2.Width = 50;
root_child2.Height = 10;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
root_child3.Width = 50f;
root_child3.Height = 10f;
root_child3.Width = 50;
root_child3.Height = 10;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
root_child4.Width = 50f;
root_child4.Height = 10f;
root_child4.Width = 50;
root_child4.Height = 10;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -322,27 +322,27 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.AlignContent = YogaAlign.Stretch;
root.Wrap = YogaWrap.Wrap;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 50f;
root_child0.Width = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 50f;
root_child1.Width = 50;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Width = 50f;
root_child2.Width = 50;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
root_child3.Width = 50f;
root_child3.Width = 50;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
root_child4.Width = 50f;
root_child4.Width = 50;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();

View File

@@ -21,11 +21,11 @@ namespace Facebook.Yoga
public void Test_align_items_stretch()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -59,12 +59,12 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.AlignItems = YogaAlign.Center;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f;
root_child0.Height = 10f;
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -98,12 +98,12 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.AlignItems = YogaAlign.FlexStart;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f;
root_child0.Height = 10f;
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -137,12 +137,12 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.AlignItems = YogaAlign.FlexEnd;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f;
root_child0.Height = 10f;
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();

View File

@@ -21,13 +21,13 @@ namespace Facebook.Yoga
public void Test_align_self_center()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.AlignSelf = YogaAlign.Center;
root_child0.Width = 10f;
root_child0.Height = 10f;
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -60,13 +60,13 @@ namespace Facebook.Yoga
public void Test_align_self_flex_end()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.AlignSelf = YogaAlign.FlexEnd;
root_child0.Width = 10f;
root_child0.Height = 10f;
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -99,13 +99,13 @@ namespace Facebook.Yoga
public void Test_align_self_flex_start()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.AlignSelf = YogaAlign.FlexStart;
root_child0.Width = 10f;
root_child0.Height = 10f;
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -139,13 +139,13 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.AlignItems = YogaAlign.FlexStart;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.AlignSelf = YogaAlign.FlexEnd;
root_child0.Width = 10f;
root_child0.Height = 10f;
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();

View File

@@ -21,10 +21,10 @@ namespace Facebook.Yoga
public void Test_border_no_size()
{
YogaNode root = new YogaNode();
root.SetBorder(YogaEdge.Left, 10f);
root.SetBorder(YogaEdge.Top, 10f);
root.SetBorder(YogaEdge.Right, 10f);
root.SetBorder(YogaEdge.Bottom, 10f);
root.SetBorder(YogaEdge.Left, 10);
root.SetBorder(YogaEdge.Top, 10);
root.SetBorder(YogaEdge.Right, 10);
root.SetBorder(YogaEdge.Bottom, 10);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -46,14 +46,14 @@ namespace Facebook.Yoga
public void Test_border_container_match_child()
{
YogaNode root = new YogaNode();
root.SetBorder(YogaEdge.Left, 10f);
root.SetBorder(YogaEdge.Top, 10f);
root.SetBorder(YogaEdge.Right, 10f);
root.SetBorder(YogaEdge.Bottom, 10f);
root.SetBorder(YogaEdge.Left, 10);
root.SetBorder(YogaEdge.Top, 10);
root.SetBorder(YogaEdge.Right, 10);
root.SetBorder(YogaEdge.Bottom, 10);
YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f;
root_child0.Height = 10f;
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -86,16 +86,16 @@ namespace Facebook.Yoga
public void Test_border_flex_child()
{
YogaNode root = new YogaNode();
root.SetBorder(YogaEdge.Left, 10f);
root.SetBorder(YogaEdge.Top, 10f);
root.SetBorder(YogaEdge.Right, 10f);
root.SetBorder(YogaEdge.Bottom, 10f);
root.Width = 100f;
root.Height = 100f;
root.SetBorder(YogaEdge.Left, 10);
root.SetBorder(YogaEdge.Top, 10);
root.SetBorder(YogaEdge.Right, 10);
root.SetBorder(YogaEdge.Bottom, 10);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.Width = 10f;
root_child0.FlexGrow = 1;
root_child0.Width = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -128,15 +128,15 @@ namespace Facebook.Yoga
public void Test_border_stretch_child()
{
YogaNode root = new YogaNode();
root.SetBorder(YogaEdge.Left, 10f);
root.SetBorder(YogaEdge.Top, 10f);
root.SetBorder(YogaEdge.Right, 10f);
root.SetBorder(YogaEdge.Bottom, 10f);
root.Width = 100f;
root.Height = 100f;
root.SetBorder(YogaEdge.Left, 10);
root.SetBorder(YogaEdge.Top, 10);
root.SetBorder(YogaEdge.Right, 10);
root.SetBorder(YogaEdge.Bottom, 10);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -171,15 +171,15 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.Center;
root.AlignItems = YogaAlign.Center;
root.SetBorder(YogaEdge.Start, 10f);
root.SetBorder(YogaEdge.End, 20f);
root.SetBorder(YogaEdge.Bottom, 20f);
root.Width = 100f;
root.Height = 100f;
root.SetBorder(YogaEdge.Start, 10);
root.SetBorder(YogaEdge.End, 20);
root.SetBorder(YogaEdge.Bottom, 20);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f;
root_child0.Height = 10f;
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();

View File

@@ -21,18 +21,18 @@ namespace Facebook.Yoga
public void Test_flex_direction_column_no_height()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Width = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Height = 10f;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Height = 10f;
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -86,18 +86,18 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Height = 100f;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f;
root_child0.Width = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 10f;
root_child1.Width = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Width = 10f;
root_child2.Width = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -150,19 +150,19 @@ namespace Facebook.Yoga
public void Test_flex_direction_column()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Height = 10f;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Height = 10f;
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -216,19 +216,19 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f;
root_child0.Width = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 10f;
root_child1.Width = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Width = 10f;
root_child2.Width = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -282,19 +282,19 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.ColumnReverse;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Height = 10f;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Height = 10f;
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -348,19 +348,19 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.RowReverse;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f;
root_child0.Width = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 10f;
root_child1.Width = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Width = 10f;
root_child2.Width = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();

View File

@@ -21,16 +21,16 @@ namespace Facebook.Yoga
public void Test_flex_basis_flex_grow_column()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.FlexBasis = 50f;
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f;
root_child1.FlexGrow = 1;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -74,16 +74,16 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.FlexBasis = 50f;
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f;
root_child1.FlexGrow = 1;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -126,16 +126,16 @@ namespace Facebook.Yoga
public void Test_flex_basis_flex_shrink_column()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexShrink = 1f;
root_child0.FlexBasis = 100f;
root_child0.FlexShrink = 1;
root_child0.FlexBasis = 100;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexBasis = 50f;
root_child1.FlexBasis = 50;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -179,16 +179,16 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexShrink = 1f;
root_child0.FlexBasis = 100f;
root_child0.FlexShrink = 1;
root_child0.FlexBasis = 100;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexBasis = 50f;
root_child1.FlexBasis = 50;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -231,22 +231,22 @@ namespace Facebook.Yoga
public void Test_flex_shrink_to_zero()
{
YogaNode root = new YogaNode();
root.Height = 75f;
root.Height = 75;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 50f;
root_child0.Height = 50f;
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexShrink = 1f;
root_child1.Width = 50f;
root_child1.Height = 50f;
root_child1.FlexShrink = 1;
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Width = 50f;
root_child2.Height = 50f;
root_child2.Width = 50;
root_child2.Height = 50;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -299,23 +299,23 @@ namespace Facebook.Yoga
public void Test_flex_basis_overrides_main_size()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.FlexBasis = 50f;
root_child0.Height = 20f;
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50;
root_child0.Height = 20;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f;
root_child1.Height = 10f;
root_child1.FlexGrow = 1;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.FlexGrow = 1f;
root_child2.Height = 10f;
root_child2.FlexGrow = 1;
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -368,15 +368,15 @@ namespace Facebook.Yoga
public void Test_flex_grow_shrink_at_most()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.FlexGrow = 1f;
root_child0_child0.FlexShrink = 1f;
root_child0_child0.FlexGrow = 1;
root_child0_child0.FlexShrink = 1;
root_child0.Insert(0, root_child0_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();

View File

@@ -22,26 +22,26 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.Wrap = YogaWrap.Wrap;
root.Height = 100f;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 30f;
root_child0.Height = 30f;
root_child0.Width = 30;
root_child0.Height = 30;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 30f;
root_child1.Height = 30f;
root_child1.Width = 30;
root_child1.Height = 30;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Width = 30f;
root_child2.Height = 30f;
root_child2.Width = 30;
root_child2.Height = 30;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
root_child3.Width = 30f;
root_child3.Height = 30f;
root_child3.Width = 30;
root_child3.Height = 30;
root.Insert(3, root_child3);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -106,26 +106,26 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Wrap = YogaWrap.Wrap;
root.Width = 100f;
root.Width = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 30f;
root_child0.Height = 30f;
root_child0.Width = 30;
root_child0.Height = 30;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 30f;
root_child1.Height = 30f;
root_child1.Width = 30;
root_child1.Height = 30;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Width = 30f;
root_child2.Height = 30f;
root_child2.Width = 30;
root_child2.Height = 30;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
root_child3.Width = 30f;
root_child3.Height = 30f;
root_child3.Width = 30;
root_child3.Height = 30;
root.Insert(3, root_child3);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -191,26 +191,26 @@ namespace Facebook.Yoga
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.FlexEnd;
root.Wrap = YogaWrap.Wrap;
root.Width = 100f;
root.Width = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 30f;
root_child0.Height = 10f;
root_child0.Width = 30;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 30f;
root_child1.Height = 20f;
root_child1.Width = 30;
root_child1.Height = 20;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Width = 30f;
root_child2.Height = 30f;
root_child2.Width = 30;
root_child2.Height = 30;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
root_child3.Width = 30f;
root_child3.Height = 30f;
root_child3.Width = 30;
root_child3.Height = 30;
root.Insert(3, root_child3);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -276,26 +276,26 @@ namespace Facebook.Yoga
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Center;
root.Wrap = YogaWrap.Wrap;
root.Width = 100f;
root.Width = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 30f;
root_child0.Height = 10f;
root_child0.Width = 30;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 30f;
root_child1.Height = 20f;
root_child1.Width = 30;
root_child1.Height = 20;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Width = 30f;
root_child2.Height = 30f;
root_child2.Width = 30;
root_child2.Height = 30;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
root_child3.Width = 30f;
root_child3.Height = 30f;
root_child3.Width = 30;
root_child3.Height = 30;
root.Insert(3, root_child3);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();

View File

@@ -22,19 +22,19 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 102f;
root.Height = 102f;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f;
root_child0.Width = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 10f;
root_child1.Width = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Width = 10f;
root_child2.Width = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -89,19 +89,19 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.JustifyContent = YogaJustify.FlexEnd;
root.Width = 102f;
root.Height = 102f;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f;
root_child0.Width = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 10f;
root_child1.Width = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Width = 10f;
root_child2.Width = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -156,19 +156,19 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.JustifyContent = YogaJustify.Center;
root.Width = 102f;
root.Height = 102f;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f;
root_child0.Width = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 10f;
root_child1.Width = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Width = 10f;
root_child2.Width = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -223,19 +223,19 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.JustifyContent = YogaJustify.SpaceBetween;
root.Width = 102f;
root.Height = 102f;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f;
root_child0.Width = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 10f;
root_child1.Width = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Width = 10f;
root_child2.Width = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -290,19 +290,19 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.JustifyContent = YogaJustify.SpaceAround;
root.Width = 102f;
root.Height = 102f;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f;
root_child0.Width = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 10f;
root_child1.Width = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Width = 10f;
root_child2.Width = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -355,18 +355,18 @@ namespace Facebook.Yoga
public void Test_justify_content_column_flex_start()
{
YogaNode root = new YogaNode();
root.Width = 102f;
root.Height = 102f;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Height = 10f;
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -420,19 +420,19 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.FlexEnd;
root.Width = 102f;
root.Height = 102f;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Height = 10f;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Height = 10f;
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -486,19 +486,19 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.Center;
root.Width = 102f;
root.Height = 102f;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Height = 10f;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Height = 10f;
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -552,19 +552,19 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.SpaceBetween;
root.Width = 102f;
root.Height = 102f;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Height = 10f;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Height = 10f;
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -618,19 +618,19 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.SpaceAround;
root.Width = 102f;
root.Height = 102f;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Height = 10f;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Height = 10f;
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();

View File

@@ -22,12 +22,12 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.SetMargin(YogaEdge.Start, 10f);
root_child0.Width = 10f;
root_child0.SetMargin(YogaEdge.Start, 10);
root_child0.Width = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -60,12 +60,12 @@ namespace Facebook.Yoga
public void Test_margin_top()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.SetMargin(YogaEdge.Top, 10f);
root_child0.Height = 10f;
root_child0.SetMargin(YogaEdge.Top, 10);
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -100,12 +100,12 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.JustifyContent = YogaJustify.FlexEnd;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.SetMargin(YogaEdge.End, 10f);
root_child0.Width = 10f;
root_child0.SetMargin(YogaEdge.End, 10);
root_child0.Width = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -139,12 +139,12 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.FlexEnd;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.SetMargin(YogaEdge.Bottom, 10f);
root_child0.Height = 10f;
root_child0.SetMargin(YogaEdge.Bottom, 10);
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -178,12 +178,12 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.SetMargin(YogaEdge.Start, 10f);
root_child0.FlexGrow = 1;
root_child0.SetMargin(YogaEdge.Start, 10);
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -216,12 +216,12 @@ namespace Facebook.Yoga
public void Test_margin_and_flex_column()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.SetMargin(YogaEdge.Top, 10f);
root_child0.FlexGrow = 1;
root_child0.SetMargin(YogaEdge.Top, 10);
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -255,12 +255,12 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.SetMargin(YogaEdge.Top, 10f);
root_child0.FlexGrow = 1;
root_child0.SetMargin(YogaEdge.Top, 10);
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -293,12 +293,12 @@ namespace Facebook.Yoga
public void Test_margin_and_stretch_column()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.SetMargin(YogaEdge.Start, 10f);
root_child0.FlexGrow = 1;
root_child0.SetMargin(YogaEdge.Start, 10);
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -332,15 +332,15 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.FlexGrow = 1;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f;
root_child1.FlexGrow = 1;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -383,15 +383,15 @@ namespace Facebook.Yoga
public void Test_margin_with_sibling_column()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.FlexGrow = 1;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f;
root_child1.FlexGrow = 1;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();

View File

@@ -21,12 +21,12 @@ namespace Facebook.Yoga
public void Test_max_width()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.MaxWidth = 50f;
root_child0.Height = 10f;
root_child0.MaxWidth = 50;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -60,12 +60,12 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f;
root_child0.MaxHeight = 50f;
root_child0.Width = 10;
root_child0.MaxHeight = 50;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -98,16 +98,16 @@ namespace Facebook.Yoga
public void Test_min_height()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.MinHeight = 60f;
root_child0.FlexGrow = 1;
root_child0.MinHeight = 60;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f;
root_child1.FlexGrow = 1;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -151,16 +151,16 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.MinWidth = 60f;
root_child0.FlexGrow = 1;
root_child0.MinWidth = 60;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f;
root_child1.FlexGrow = 1;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -204,13 +204,13 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.Center;
root.Width = 100f;
root.MinHeight = 100f;
root.MaxHeight = 200f;
root.Width = 100;
root.MinHeight = 100;
root.MaxHeight = 200;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 60f;
root_child0.Height = 60f;
root_child0.Width = 60;
root_child0.Height = 60;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -244,13 +244,13 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.AlignItems = YogaAlign.Center;
root.MinWidth = 100f;
root.MaxWidth = 200f;
root.Height = 100f;
root.MinWidth = 100;
root.MaxWidth = 200;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 60f;
root_child0.Height = 60f;
root_child0.Width = 60;
root_child0.Height = 60;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -284,22 +284,22 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.Center;
root.MinHeight = 100f;
root.MaxHeight = 110f;
root.MinHeight = 100;
root.MaxHeight = 110;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 50f;
root_child0.Height = 50f;
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 50f;
root_child1.Height = 50f;
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.Width = 50f;
root_child2.Height = 50f;
root_child2.Width = 50;
root_child2.Height = 50;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -352,17 +352,17 @@ namespace Facebook.Yoga
public void Test_flex_grow_within_max_width()
{
YogaNode root = new YogaNode();
root.Width = 200f;
root.Height = 100f;
root.Width = 200;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.MaxWidth = 100f;
root_child0.MaxWidth = 100;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.FlexGrow = 1f;
root_child0_child0.Height = 20f;
root_child0_child0.FlexGrow = 1;
root_child0_child0.Height = 20;
root_child0.Insert(0, root_child0_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -405,17 +405,17 @@ namespace Facebook.Yoga
public void Test_flex_grow_within_constrained_max_width()
{
YogaNode root = new YogaNode();
root.Width = 200f;
root.Height = 100f;
root.Width = 200;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.MaxWidth = 300f;
root_child0.MaxWidth = 300;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.FlexGrow = 1f;
root_child0_child0.Height = 20f;
root_child0_child0.FlexGrow = 1;
root_child0_child0.Height = 20;
root_child0.Insert(0, root_child0_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -459,15 +459,15 @@ namespace Facebook.Yoga
{
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.MinWidth = 100f;
root.Height = 100f;
root.MinWidth = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.FlexGrow = 1;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 50f;
root_child1.Width = 50;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -510,14 +510,14 @@ namespace Facebook.Yoga
public void Test_flex_grow_within_constrained_min_column()
{
YogaNode root = new YogaNode();
root.MinHeight = 100f;
root.MinHeight = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.FlexGrow = 1;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Height = 50f;
root_child1.Height = 50;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -560,21 +560,21 @@ namespace Facebook.Yoga
public void Test_flex_grow_within_constrained_max_row()
{
YogaNode root = new YogaNode();
root.Width = 200f;
root.Width = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.MaxWidth = 100f;
root_child0.Height = 100f;
root_child0.MaxWidth = 100;
root_child0.Height = 100;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.FlexShrink = 1f;
root_child0_child0.FlexBasis = 100f;
root_child0_child0.FlexShrink = 1;
root_child0_child0.FlexBasis = 100;
root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child1 = new YogaNode();
root_child0_child1.Width = 50f;
root_child0_child1.Width = 50;
root_child0.Insert(1, root_child0_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -627,16 +627,16 @@ namespace Facebook.Yoga
public void Test_flex_grow_within_constrained_max_column()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.MaxHeight = 100f;
root.Width = 100;
root.MaxHeight = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexShrink = 1f;
root_child0.FlexBasis = 100f;
root_child0.FlexShrink = 1;
root_child0.FlexBasis = 100;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Height = 50f;
root_child1.Height = 50;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();

View File

@@ -21,10 +21,10 @@ namespace Facebook.Yoga
public void Test_padding_no_size()
{
YogaNode root = new YogaNode();
root.SetPadding(YogaEdge.Left, 10f);
root.SetPadding(YogaEdge.Top, 10f);
root.SetPadding(YogaEdge.Right, 10f);
root.SetPadding(YogaEdge.Bottom, 10f);
root.SetPadding(YogaEdge.Left, 10);
root.SetPadding(YogaEdge.Top, 10);
root.SetPadding(YogaEdge.Right, 10);
root.SetPadding(YogaEdge.Bottom, 10);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -46,14 +46,14 @@ namespace Facebook.Yoga
public void Test_padding_container_match_child()
{
YogaNode root = new YogaNode();
root.SetPadding(YogaEdge.Left, 10f);
root.SetPadding(YogaEdge.Top, 10f);
root.SetPadding(YogaEdge.Right, 10f);
root.SetPadding(YogaEdge.Bottom, 10f);
root.SetPadding(YogaEdge.Left, 10);
root.SetPadding(YogaEdge.Top, 10);
root.SetPadding(YogaEdge.Right, 10);
root.SetPadding(YogaEdge.Bottom, 10);
YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f;
root_child0.Height = 10f;
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -86,16 +86,16 @@ namespace Facebook.Yoga
public void Test_padding_flex_child()
{
YogaNode root = new YogaNode();
root.SetPadding(YogaEdge.Left, 10f);
root.SetPadding(YogaEdge.Top, 10f);
root.SetPadding(YogaEdge.Right, 10f);
root.SetPadding(YogaEdge.Bottom, 10f);
root.Width = 100f;
root.Height = 100f;
root.SetPadding(YogaEdge.Left, 10);
root.SetPadding(YogaEdge.Top, 10);
root.SetPadding(YogaEdge.Right, 10);
root.SetPadding(YogaEdge.Bottom, 10);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.Width = 10f;
root_child0.FlexGrow = 1;
root_child0.Width = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -128,15 +128,15 @@ namespace Facebook.Yoga
public void Test_padding_stretch_child()
{
YogaNode root = new YogaNode();
root.SetPadding(YogaEdge.Left, 10f);
root.SetPadding(YogaEdge.Top, 10f);
root.SetPadding(YogaEdge.Right, 10f);
root.SetPadding(YogaEdge.Bottom, 10f);
root.Width = 100f;
root.Height = 100f;
root.SetPadding(YogaEdge.Left, 10);
root.SetPadding(YogaEdge.Top, 10);
root.SetPadding(YogaEdge.Right, 10);
root.SetPadding(YogaEdge.Bottom, 10);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -171,15 +171,15 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.Center;
root.AlignItems = YogaAlign.Center;
root.SetPadding(YogaEdge.Start, 10f);
root.SetPadding(YogaEdge.End, 20f);
root.SetPadding(YogaEdge.Bottom, 20f);
root.Width = 100f;
root.Height = 100f;
root.SetPadding(YogaEdge.Start, 10);
root.SetPadding(YogaEdge.End, 20);
root.SetPadding(YogaEdge.Bottom, 20);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f;
root_child0.Height = 10f;
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -214,16 +214,16 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.FlexEnd;
root.AlignItems = YogaAlign.FlexEnd;
root.Width = 200f;
root.Height = 200f;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.SetPadding(YogaEdge.Left, 20f);
root_child0.SetPadding(YogaEdge.Top, 20f);
root_child0.SetPadding(YogaEdge.Right, 20f);
root_child0.SetPadding(YogaEdge.Bottom, 20f);
root_child0.Width = 100f;
root_child0.Height = 100f;
root_child0.SetPadding(YogaEdge.Left, 20);
root_child0.SetPadding(YogaEdge.Top, 20);
root_child0.SetPadding(YogaEdge.Right, 20);
root_child0.SetPadding(YogaEdge.Bottom, 20);
root_child0.Width = 100;
root_child0.Height = 100;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();

View File

@@ -0,0 +1,959 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPercentageTest.html
using System;
using NUnit.Framework;
namespace Facebook.Yoga
{
[TestFixture]
public class YGPercentageTest
{
[Test]
public void Test_percentage_width_height()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 30.Percent();
root_child0.Height = 30.Percent();
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(60f, root_child0.LayoutWidth);
Assert.AreEqual(60f, root_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(140f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(60f, root_child0.LayoutWidth);
Assert.AreEqual(60f, root_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_position_left_top()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 400;
root.Height = 400;
YogaNode root_child0 = new YogaNode();
root_child0.SetPosition(YogaEdge.Left, 10.Percent());
root_child0.SetPosition(YogaEdge.Top, 20.Percent());
root_child0.Width = 45.Percent();
root_child0.Height = 55.Percent();
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(400f, root.LayoutWidth);
Assert.AreEqual(400f, root.LayoutHeight);
Assert.AreEqual(40f, root_child0.LayoutX);
Assert.AreEqual(80f, root_child0.LayoutY);
Assert.AreEqual(180f, root_child0.LayoutWidth);
Assert.AreEqual(220f, root_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(400f, root.LayoutWidth);
Assert.AreEqual(400f, root.LayoutHeight);
Assert.AreEqual(260f, root_child0.LayoutX);
Assert.AreEqual(80f, root_child0.LayoutY);
Assert.AreEqual(180f, root_child0.LayoutWidth);
Assert.AreEqual(220f, root_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_position_bottom_right()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 500;
root.Height = 500;
YogaNode root_child0 = new YogaNode();
root_child0.SetPosition(YogaEdge.Right, 20.Percent());
root_child0.SetPosition(YogaEdge.Bottom, 10.Percent());
root_child0.Width = 55.Percent();
root_child0.Height = 15.Percent();
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(500f, root.LayoutWidth);
Assert.AreEqual(500f, root.LayoutHeight);
Assert.AreEqual(-100f, root_child0.LayoutX);
Assert.AreEqual(-50f, root_child0.LayoutY);
Assert.AreEqual(275f, root_child0.LayoutWidth);
Assert.AreEqual(75f, root_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(500f, root.LayoutWidth);
Assert.AreEqual(500f, root.LayoutHeight);
Assert.AreEqual(125f, root_child0.LayoutX);
Assert.AreEqual(-50f, root_child0.LayoutY);
Assert.AreEqual(275f, root_child0.LayoutWidth);
Assert.AreEqual(75f, root_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1;
root_child1.FlexBasis = 25.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(125f, root_child0.LayoutWidth);
Assert.AreEqual(200f, root_child0.LayoutHeight);
Assert.AreEqual(125f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(75f, root_child1.LayoutWidth);
Assert.AreEqual(200f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(75f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(125f, root_child0.LayoutWidth);
Assert.AreEqual(200f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(75f, root_child1.LayoutWidth);
Assert.AreEqual(200f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_cross()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1;
root_child1.FlexBasis = 25.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(125f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(125f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(75f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(125f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(125f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(75f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_cross_min_height()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.MinHeight = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 2;
root_child1.MinHeight = 10.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(140f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(140f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(60f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(140f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(140f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(60f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_main_max_height()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 10.Percent();
root_child0.MaxHeight = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 10.Percent();
root_child1.MaxHeight = 20.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(52f, root_child0.LayoutWidth);
Assert.AreEqual(120f, root_child0.LayoutHeight);
Assert.AreEqual(52f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(148f, root_child1.LayoutWidth);
Assert.AreEqual(40f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(148f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(52f, root_child0.LayoutWidth);
Assert.AreEqual(120f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(148f, root_child1.LayoutWidth);
Assert.AreEqual(40f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_cross_max_height()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 10.Percent();
root_child0.MaxHeight = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 10.Percent();
root_child1.MaxHeight = 20.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(120f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(120f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(40f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(120f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(120f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(40f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_main_max_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 15.Percent();
root_child0.MaxWidth = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 10.Percent();
root_child1.MaxWidth = 20.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(120f, root_child0.LayoutWidth);
Assert.AreEqual(200f, root_child0.LayoutHeight);
Assert.AreEqual(120f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(40f, root_child1.LayoutWidth);
Assert.AreEqual(200f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(80f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(120f, root_child0.LayoutWidth);
Assert.AreEqual(200f, root_child0.LayoutHeight);
Assert.AreEqual(40f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(40f, root_child1.LayoutWidth);
Assert.AreEqual(200f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_cross_max_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 10.Percent();
root_child0.MaxWidth = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 15.Percent();
root_child1.MaxWidth = 20.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(120f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(40f, root_child1.LayoutWidth);
Assert.AreEqual(150f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(80f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(120f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(160f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(40f, root_child1.LayoutWidth);
Assert.AreEqual(150f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_main_min_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 15.Percent();
root_child0.MinWidth = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 10.Percent();
root_child1.MinWidth = 20.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(120f, root_child0.LayoutWidth);
Assert.AreEqual(200f, root_child0.LayoutHeight);
Assert.AreEqual(120f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(80f, root_child1.LayoutWidth);
Assert.AreEqual(200f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(80f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(120f, root_child0.LayoutWidth);
Assert.AreEqual(200f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(80f, root_child1.LayoutWidth);
Assert.AreEqual(200f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_cross_min_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 10.Percent();
root_child0.MinWidth = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 15.Percent();
root_child1.MinWidth = 20.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(150f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(150f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_multiple_nested_with_padding_margin_and_percentage_values()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 10.Percent();
root_child0.SetMargin(YogaEdge.Left, 5);
root_child0.SetMargin(YogaEdge.Top, 5);
root_child0.SetMargin(YogaEdge.Right, 5);
root_child0.SetMargin(YogaEdge.Bottom, 5);
root_child0.SetPadding(YogaEdge.Left, 3);
root_child0.SetPadding(YogaEdge.Top, 3);
root_child0.SetPadding(YogaEdge.Right, 3);
root_child0.SetPadding(YogaEdge.Bottom, 3);
root_child0.MinWidth = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.SetMargin(YogaEdge.Left, 5);
root_child0_child0.SetMargin(YogaEdge.Top, 5);
root_child0_child0.SetMargin(YogaEdge.Right, 5);
root_child0_child0.SetMargin(YogaEdge.Bottom, 5);
root_child0_child0.SetPadding(YogaEdge.Left, 3.Percent());
root_child0_child0.SetPadding(YogaEdge.Top, 3.Percent());
root_child0_child0.SetPadding(YogaEdge.Right, 3.Percent());
root_child0_child0.SetPadding(YogaEdge.Bottom, 3.Percent());
root_child0_child0.Width = 50.Percent();
root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child0_child0 = new YogaNode();
root_child0_child0_child0.SetMargin(YogaEdge.Left, 5.Percent());
root_child0_child0_child0.SetMargin(YogaEdge.Top, 5.Percent());
root_child0_child0_child0.SetMargin(YogaEdge.Right, 5.Percent());
root_child0_child0_child0.SetMargin(YogaEdge.Bottom, 5.Percent());
root_child0_child0_child0.SetPadding(YogaEdge.Left, 3);
root_child0_child0_child0.SetPadding(YogaEdge.Top, 3);
root_child0_child0_child0.SetPadding(YogaEdge.Right, 3);
root_child0_child0_child0.SetPadding(YogaEdge.Bottom, 3);
root_child0_child0_child0.Width = 45.Percent();
root_child0_child0.Insert(0, root_child0_child0_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 15.Percent();
root_child1.MinWidth = 20.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(5f, root_child0.LayoutX);
Assert.AreEqual(5f, root_child0.LayoutY);
Assert.AreEqual(190f, root_child0.LayoutWidth);
Assert.AreEqual(48f, root_child0.LayoutHeight);
Assert.AreEqual(8f, root_child0_child0.LayoutX);
Assert.AreEqual(8f, root_child0_child0.LayoutY);
Assert.AreEqual(92f, root_child0_child0.LayoutWidth);
Assert.AreEqual(25f, root_child0_child0.LayoutHeight);
Assert.AreEqual(10f, root_child0_child0_child0.LayoutX);
Assert.AreEqual(10f, root_child0_child0_child0.LayoutY);
Assert.AreEqual(36f, root_child0_child0_child0.LayoutWidth);
Assert.AreEqual(6f, root_child0_child0_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(58f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(142f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(5f, root_child0.LayoutX);
Assert.AreEqual(5f, root_child0.LayoutY);
Assert.AreEqual(190f, root_child0.LayoutWidth);
Assert.AreEqual(48f, root_child0.LayoutHeight);
Assert.AreEqual(90f, root_child0_child0.LayoutX);
Assert.AreEqual(8f, root_child0_child0.LayoutY);
Assert.AreEqual(92f, root_child0_child0.LayoutWidth);
Assert.AreEqual(25f, root_child0_child0.LayoutHeight);
Assert.AreEqual(46f, root_child0_child0_child0.LayoutX);
Assert.AreEqual(10f, root_child0_child0_child0.LayoutY);
Assert.AreEqual(36f, root_child0_child0_child0.LayoutWidth);
Assert.AreEqual(6f, root_child0_child0_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(58f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(142f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_margin_should_calculate_based_only_on_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 200;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.SetMargin(YogaEdge.Left, 10.Percent());
root_child0.SetMargin(YogaEdge.Top, 10.Percent());
root_child0.SetMargin(YogaEdge.Right, 10.Percent());
root_child0.SetMargin(YogaEdge.Bottom, 10.Percent());
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.Width = 10;
root_child0_child0.Height = 10;
root_child0.Insert(0, root_child0_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(20f, root_child0.LayoutX);
Assert.AreEqual(20f, root_child0.LayoutY);
Assert.AreEqual(160f, root_child0.LayoutWidth);
Assert.AreEqual(60f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(10f, root_child0_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(20f, root_child0.LayoutX);
Assert.AreEqual(20f, root_child0.LayoutY);
Assert.AreEqual(160f, root_child0.LayoutWidth);
Assert.AreEqual(60f, root_child0.LayoutHeight);
Assert.AreEqual(150f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(10f, root_child0_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_padding_should_calculate_based_only_on_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 200;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.SetPadding(YogaEdge.Left, 10.Percent());
root_child0.SetPadding(YogaEdge.Top, 10.Percent());
root_child0.SetPadding(YogaEdge.Right, 10.Percent());
root_child0.SetPadding(YogaEdge.Bottom, 10.Percent());
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.Width = 10;
root_child0_child0.Height = 10;
root_child0.Insert(0, root_child0_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(20f, root_child0_child0.LayoutX);
Assert.AreEqual(20f, root_child0_child0.LayoutY);
Assert.AreEqual(10f, root_child0_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(170f, root_child0_child0.LayoutX);
Assert.AreEqual(20f, root_child0_child0.LayoutY);
Assert.AreEqual(10f, root_child0_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_absolute_position()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 200;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.Left, 30.Percent());
root_child0.SetPosition(YogaEdge.Top, 10.Percent());
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(60f, root_child0.LayoutX);
Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(60f, root_child0.LayoutX);
Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
}
}

View File

@@ -24,19 +24,19 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f;
root.Height = 100f;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.FlexGrow = 1;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f;
root_child1.FlexGrow = 1;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.FlexGrow = 1f;
root_child2.FlexGrow = 1;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -94,27 +94,27 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 113f;
root.Height = 100f;
root.Width = 113;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.FlexGrow = 1;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f;
root_child1.FlexGrow = 1;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.FlexGrow = 1f;
root_child2.FlexGrow = 1;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
root_child3.FlexGrow = 1f;
root_child3.FlexGrow = 1;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
root_child4.FlexGrow = 1f;
root_child4.FlexGrow = 1;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -192,20 +192,20 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 101f;
root.Height = 100f;
root.Width = 101;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexShrink = 1f;
root_child0.FlexBasis = 100f;
root_child0.FlexShrink = 1;
root_child0.FlexBasis = 100;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexBasis = 25f;
root_child1.FlexBasis = 25;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.FlexBasis = 25f;
root_child2.FlexBasis = 25;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -262,23 +262,23 @@ namespace Facebook.Yoga
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 100f;
root.Height = 113f;
root.Width = 100;
root.Height = 113;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.FlexBasis = 50f;
root_child0.Height = 20f;
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50;
root_child0.Height = 20;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f;
root_child1.Height = 10f;
root_child1.FlexGrow = 1;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.FlexGrow = 1f;
root_child2.Height = 10f;
root_child2.FlexGrow = 1;
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -346,7 +346,7 @@ namespace Facebook.Yoga
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1.6f;
root_child1.Height = 10f;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
@@ -418,14 +418,14 @@ namespace Facebook.Yoga
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.FlexGrow = 1f;
root_child0_child0.FlexGrow = 1;
root_child0_child0.FlexBasis = 0.3f;
root_child0_child0.SetPosition(YogaEdge.Bottom, 13.3f);
root_child0_child0.Height = 9.9f;
root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child1 = new YogaNode();
root_child0_child1.FlexGrow = 4f;
root_child0_child1.FlexGrow = 4;
root_child0_child1.FlexBasis = 0.3f;
root_child0_child1.SetPosition(YogaEdge.Top, 13.3f);
root_child0_child1.Height = 1.1f;
@@ -433,7 +433,7 @@ namespace Facebook.Yoga
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1.6f;
root_child1.Height = 10f;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
@@ -515,23 +515,23 @@ namespace Facebook.Yoga
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 100f;
root.Width = 100;
root.Height = 113.4f;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.FlexBasis = 50f;
root_child0.Height = 20f;
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50;
root_child0.Height = 20;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f;
root_child1.Height = 10f;
root_child1.FlexGrow = 1;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.FlexGrow = 1f;
root_child2.Height = 10f;
root_child2.FlexGrow = 1;
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -588,23 +588,23 @@ namespace Facebook.Yoga
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 100f;
root.Width = 100;
root.Height = 113.6f;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.FlexBasis = 50f;
root_child0.Height = 20f;
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50;
root_child0.Height = 20;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f;
root_child1.Height = 10f;
root_child1.FlexGrow = 1;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.FlexGrow = 1f;
root_child2.Height = 10f;
root_child2.FlexGrow = 1;
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -662,23 +662,23 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.SetPosition(YogaEdge.Top, 0.3f);
root.Width = 100f;
root.Width = 100;
root.Height = 113.4f;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.FlexBasis = 50f;
root_child0.Height = 20f;
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50;
root_child0.Height = 20;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f;
root_child1.Height = 10f;
root_child1.FlexGrow = 1;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.FlexGrow = 1f;
root_child2.Height = 10f;
root_child2.FlexGrow = 1;
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -736,23 +736,23 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.SetPosition(YogaEdge.Top, 0.7f);
root.Width = 100f;
root.Width = 100;
root.Height = 113.4f;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root_child0.FlexBasis = 50f;
root_child0.Height = 20f;
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50;
root_child0.Height = 20;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f;
root_child1.Height = 10f;
root_child1.FlexGrow = 1;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
root_child2.FlexGrow = 1f;
root_child2.Height = 10f;
root_child2.FlexGrow = 1;
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();

View File

@@ -51,14 +51,14 @@ namespace Facebook.Yoga
Assert.AreEqual(YogaFlexDirection.Column, node.FlexDirection);
Assert.AreEqual(YogaPositionType.Absolute, node.PositionType);
Assert.AreEqual(YogaWrap.Wrap, node.Wrap);
Assert.AreEqual(6, node.GetPosition(YogaEdge.Top));
Assert.AreEqual(6.Px(), node.GetPosition(YogaEdge.Top));
Assert.IsTrue(YogaConstants.IsUndefined(node.GetPosition(YogaEdge.Bottom)));
Assert.AreEqual(4, node.GetPosition(YogaEdge.Right));
Assert.AreEqual(4.Px(), node.GetPosition(YogaEdge.Right));
Assert.IsTrue(YogaConstants.IsUndefined(node.GetPosition(YogaEdge.Left)));
Assert.AreEqual(0, node.GetMargin(YogaEdge.Top));
Assert.AreEqual(5, node.GetMargin(YogaEdge.Bottom));
Assert.AreEqual(3, node.GetMargin(YogaEdge.Left));
Assert.AreEqual(0, node.GetMargin(YogaEdge.Right));
Assert.AreEqual(0.Px(), node.GetMargin(YogaEdge.Top));
Assert.AreEqual(5.Px(), node.GetMargin(YogaEdge.Bottom));
Assert.AreEqual(3.Px(), node.GetMargin(YogaEdge.Left));
Assert.AreEqual(0.Px(), node.GetMargin(YogaEdge.Right));
}
[Test]
@@ -85,7 +85,7 @@ namespace Facebook.Yoga
position: new Spacing(top: 5, bottom: 6, left: 7, right: 8),
margin: new Spacing(top: 9, bottom: 10, left: 11, right: 12),
padding: new Spacing(top: 13, bottom: 14, left: 15, right: 16),
border: new Spacing(top: 17, bottom: 18, left: 19, right: 20),
border: new Border(top: 17, bottom: 18, left: 19, right: 20),
width: 21,
height: 22,
@@ -108,36 +108,36 @@ namespace Facebook.Yoga
Assert.AreEqual(2, node.FlexGrow);
Assert.AreEqual(3, node.FlexShrink);
Assert.AreEqual(4, node.FlexBasis);
Assert.AreEqual(4.Px(), node.FlexBasis);
node.FlexGrow = YogaConstants.Undefined;
Assert.AreEqual(1, node.FlexGrow);
Assert.AreEqual(5, node.GetPosition(YogaEdge.Top));
Assert.AreEqual(6, node.GetPosition(YogaEdge.Bottom));
Assert.AreEqual(7, node.GetPosition(YogaEdge.Left));
Assert.AreEqual(8, node.GetPosition(YogaEdge.Right));
Assert.AreEqual(5.Px(), node.GetPosition(YogaEdge.Top));
Assert.AreEqual(6.Px(), node.GetPosition(YogaEdge.Bottom));
Assert.AreEqual(7.Px(), node.GetPosition(YogaEdge.Left));
Assert.AreEqual(8.Px(), node.GetPosition(YogaEdge.Right));
Assert.AreEqual(9, node.GetMargin(YogaEdge.Top));
Assert.AreEqual(10, node.GetMargin(YogaEdge.Bottom));
Assert.AreEqual(11, node.GetMargin(YogaEdge.Left));
Assert.AreEqual(12, node.GetMargin(YogaEdge.Right));
Assert.AreEqual(9.Px(), node.GetMargin(YogaEdge.Top));
Assert.AreEqual(10.Px(), node.GetMargin(YogaEdge.Bottom));
Assert.AreEqual(11.Px(), node.GetMargin(YogaEdge.Left));
Assert.AreEqual(12.Px(), node.GetMargin(YogaEdge.Right));
Assert.AreEqual(13, node.GetPadding(YogaEdge.Top));
Assert.AreEqual(14, node.GetPadding(YogaEdge.Bottom));
Assert.AreEqual(15, node.GetPadding(YogaEdge.Left));
Assert.AreEqual(16, node.GetPadding(YogaEdge.Right));
Assert.AreEqual(13.Px(), node.GetPadding(YogaEdge.Top));
Assert.AreEqual(14.Px(), node.GetPadding(YogaEdge.Bottom));
Assert.AreEqual(15.Px(), node.GetPadding(YogaEdge.Left));
Assert.AreEqual(16.Px(), node.GetPadding(YogaEdge.Right));
Assert.AreEqual(17, node.GetBorder(YogaEdge.Top));
Assert.AreEqual(18, node.GetBorder(YogaEdge.Bottom));
Assert.AreEqual(19, node.GetBorder(YogaEdge.Left));
Assert.AreEqual(20, node.GetBorder(YogaEdge.Right));
Assert.AreEqual(21, node.Width);
Assert.AreEqual(22, node.Height);
Assert.AreEqual(23, node.MinWidth);
Assert.AreEqual(24, node.MinHeight);
Assert.AreEqual(25, node.MaxWidth);
Assert.AreEqual(26, node.MaxHeight);
Assert.AreEqual(21.Px(), node.Width);
Assert.AreEqual(22.Px(), node.Height);
Assert.AreEqual(23.Px(), node.MinWidth);
Assert.AreEqual(24.Px(), node.MinHeight);
Assert.AreEqual(25.Px(), node.MaxWidth);
Assert.AreEqual(26.Px(), node.MaxHeight);
}
}
}

View File

@@ -212,7 +212,7 @@ namespace Facebook.Yoga
parent.Insert(0, child0);
parent.Insert(0, child1);
parent.CalculateLayout();
Assert.AreEqual(parent.Print(), "{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100, height: 120, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35, height: 45, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30, height: 40, },\n]},\n");
Assert.AreEqual("{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100px, height: 120px, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35px, height: 45px, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30px, height: 40px, },\n]},\n", parent.Print());
}
[Test]
@@ -225,7 +225,7 @@ namespace Facebook.Yoga
node1.MaxHeight = 100;
node0.CopyStyle(node1);
Assert.AreEqual(100, node0.MaxHeight);
Assert.AreEqual(100.Px(), node0.MaxHeight);
}
private void ForceGC()

View File

@@ -17,6 +17,11 @@ ENUMS = {
'LTR',
emilsjolander commented 2016-12-23 13:51:01 -08:00 (Migrated from github.com)
Review

indentation

indentation
'RTL',
emilsjolander commented 2016-12-23 13:57:12 -08:00 (Migrated from github.com)
Review

'Unit' is still wrongly indented compared to other enums

'Unit' is still wrongly indented compared to other enums
woehrl01 commented 2016-12-23 13:58:18 -08:00 (Migrated from github.com)
Review

😖 sorry, will do (all my editors are configured to use tabs instead of spaces)

😖 sorry, will do (all my editors are configured to use tabs instead of spaces)
],
'Unit': [
'Undefined',
'Pixel',
'Percent',
],
'FlexDirection': [
'Column',
'ColumnReverse',

View File

@@ -0,0 +1,82 @@
<div id="percentage_width_height" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
emilsjolander commented 2016-12-16 02:10:56 -08:00 (Migrated from github.com)
Review

Indentation here seems a bit off. Could you please update your tests to look more like the others?


<div id="percentage_padding_should_calculate_based_only_on_width" experiments="Rounding" style="width: 200px; height: 100px;">
    <div style="flex-grow: 1; padding: 10%;">
        <div style="width: 10px; height: 10px;"></div>
    </div>
</div>
Indentation here seems a bit off. Could you please update your tests to look more like the others? ```html <div id="percentage_padding_should_calculate_based_only_on_width" experiments="Rounding" style="width: 200px; height: 100px;"> <div style="flex-grow: 1; padding: 10%;"> <div style="width: 10px; height: 10px;"></div> </div> </div> ```
emilsjolander commented 2016-12-16 02:11:44 -08:00 (Migrated from github.com)
Review

Still missing tests for % border values

Still missing tests for % border values
woehrl01 commented 2016-12-16 02:16:13 -08:00 (Migrated from github.com)
Review

there is no need to write tests for border, as border can't have percentage in css.

there is no need to write tests for border, as border can't have percentage in css.
<div style="width: 30%; height: 30%;"></div>
</div>
<div id="percentage_position_left_top" experiments="Rounding" style="width: 400px; height: 400px; flex-direction: row;">
<div style="width: 45%; height: 55%; left: 10%; top: 20%"></div>
</div>
<div id="percentage_position_bottom_right" experiments="Rounding" style="width: 500px; height: 500px; flex-direction: row;">
<div style="width: 55%; height: 15%; bottom: 10%; right: 20%"></div>
</div>
<div id="percentage_flex_basis" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
<div style="flex-grow: 1; flex-basis: 50%;"></div>
<div style="flex-grow: 1; flex-basis: 25%;"></div>
</div>
<div id="percentage_flex_basis_cross" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
<div style="flex-grow: 1; flex-basis: 50%;"></div>
<div style="flex-grow: 1; flex-basis: 25%;"></div>
</div>
<div id="percentage_flex_basis_cross_min_height" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
<div style="flex-grow: 1; min-height: 60%;"></div>
<div style="flex-grow: 2; min-height: 10%;"></div>
</div>
<div id="percentage_flex_basis_main_max_height" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
<div style="flex-grow: 1; flex-basis: 10%; max-height: 60%;"></div>
<div style="flex-grow: 4; flex-basis: 10%; max-height: 20%;"></div>
</div>
<div id="percentage_flex_basis_cross_max_height" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
<div style="flex-grow: 1; flex-basis: 10%; max-height: 60%;"></div>
<div style="flex-grow: 4; flex-basis: 10%; max-height: 20%;"></div>
</div>
<div id="percentage_flex_basis_main_max_width" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
<div style="flex-grow: 1; flex-basis: 15%; max-width: 60%;"></div>
<div style="flex-grow: 4; flex-basis: 10%; max-width: 20%;"></div>
</div>
<div id="percentage_flex_basis_cross_max_width" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
<div style="flex-grow: 1; flex-basis: 10%; max-width: 60%;"></div>
<div style="flex-grow: 4; flex-basis: 15%; max-width: 20%;"></div>
</div>
<div id="percentage_flex_basis_main_min_width" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
<div style="flex-grow: 1; flex-basis: 15%; min-width: 60%;"></div>
<div style="flex-grow: 4; flex-basis: 10%; min-width: 20%;"></div>
</div>
<div id="percentage_flex_basis_cross_min_width" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
<div style="flex-grow: 1; flex-basis: 10%; min-width: 60%;"></div>
<div style="flex-grow: 4; flex-basis: 15%; min-width: 20%;"></div>
</div>
<div id="percentage_multiple_nested_with_padding_margin_and_percentage_values" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
<div style="flex-grow: 1; flex-basis: 10%; min-width: 60%; margin: 5px; padding: 3px;">
<div style="width: 50%; margin: 5px; padding: 3%;">
<div style="width: 45%; margin: 5%; padding: 3px;"></div>
</div>
</div>
<div style="flex-grow: 4; flex-basis: 15%; min-width: 20%;"></div>
</div>
<div id="percentage_margin_should_calculate_based_only_on_width" experiments="Rounding" style="width: 200px; height: 100px;">
<div style="flex-grow: 1; margin: 10%;">
<div style="width: 10px; height: 10px;"></div>
</div>
</div>
<div id="percentage_padding_should_calculate_based_only_on_width" experiments="Rounding" style="width: 200px; height: 100px;">
<div style="flex-grow: 1; padding: 10%;">
<div style="width: 10px; height: 10px;"></div>
</div>
</div>
<div id="percentage_absolute_position" experiments="Rounding" style="width: 200px; height: 100px;">
<div style="position: absolute; top: 10%; left: 30%; width: 10px; height: 10px;"></div>
</div>

View File

@@ -7,9 +7,17 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
function toFloatString(n) {
function toValueCpp(value) {
var n = value.toString().replace('px','').replace('%','');
return n + (Number(n) == n && n % 1 !== 0 ? 'f' : '');
}
function toFunctionName(value) {
if (value.indexOf('%') >= 0){
return 'Percent';
}
return '';
}
var CPPEmitter = function() {
Emitter.call(this, 'cpp', ' ');
@@ -66,7 +74,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
}},
AssertEQ:{value:function(v0, v1) {
this.push('ASSERT_FLOAT_EQ(' + toFloatString(v0) + ', ' + v1 + ');');
this.push('ASSERT_FLOAT_EQ(' + toValueCpp(v0) + ', ' + v1 + ');');
}},
YGAlignAuto:{value:'YGAlignAuto'},
@@ -133,90 +141,90 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
}},
YGNodeStyleSetAlignContent:{value:function(nodeName, value) {
this.push('YGNodeStyleSetAlignContent(' + nodeName + ', ' + value + ');');
this.push('YGNodeStyleSetAlignContent(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetAlignItems:{value:function(nodeName, value) {
this.push('YGNodeStyleSetAlignItems(' + nodeName + ', ' + value + ');');
this.push('YGNodeStyleSetAlignItems(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetAlignSelf:{value:function(nodeName, value) {
this.push('YGNodeStyleSetAlignSelf(' + nodeName + ', ' + value + ');');
this.push('YGNodeStyleSetAlignSelf(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetBorder:{value:function(nodeName, edge, value) {
this.push('YGNodeStyleSetBorder(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetBorder(' + nodeName + ', ' + edge + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetDirection:{value:function(nodeName, value) {
this.push('YGNodeStyleSetDirection(' + nodeName + ', ' + value + ');');
this.push('YGNodeStyleSetDirection(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetFlexBasis:{value:function(nodeName, value) {
this.push('YGNodeStyleSetFlexBasis(' + nodeName + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetFlexBasis' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetFlexDirection:{value:function(nodeName, value) {
this.push('YGNodeStyleSetFlexDirection(' + nodeName + ', ' + value + ');');
this.push('YGNodeStyleSetFlexDirection(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetFlexGrow:{value:function(nodeName, value) {
this.push('YGNodeStyleSetFlexGrow(' + nodeName + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetFlexGrow(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetFlexShrink:{value:function(nodeName, value) {
this.push('YGNodeStyleSetFlexShrink(' + nodeName + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetFlexShrink(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetFlexWrap:{value:function(nodeName, value) {
this.push('YGNodeStyleSetFlexWrap(' + nodeName + ', ' + value + ');');
this.push('YGNodeStyleSetFlexWrap(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetHeight:{value:function(nodeName, value) {
this.push('YGNodeStyleSetHeight(' + nodeName + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetHeight' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetJustifyContent:{value:function(nodeName, value) {
this.push('YGNodeStyleSetJustifyContent(' + nodeName + ', ' + value + ');');
this.push('YGNodeStyleSetJustifyContent(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetMargin:{value:function(nodeName, edge, value) {
this.push('YGNodeStyleSetMargin(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetMargin' + toFunctionName(value) + '(' + nodeName + ', ' + edge + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetMaxHeight:{value:function(nodeName, value) {
this.push('YGNodeStyleSetMaxHeight(' + nodeName + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetMaxHeight' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetMaxWidth:{value:function(nodeName, value) {
this.push('YGNodeStyleSetMaxWidth(' + nodeName + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetMaxWidth' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetMinHeight:{value:function(nodeName, value) {
this.push('YGNodeStyleSetMinHeight(' + nodeName + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetMinHeight' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetMinWidth:{value:function(nodeName, value) {
this.push('YGNodeStyleSetMinWidth(' + nodeName + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetMinWidth' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetOverflow:{value:function(nodeName, value) {
this.push('YGNodeStyleSetOverflow(' + nodeName + ', ' + value + ');');
this.push('YGNodeStyleSetOverflow(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetPadding:{value:function(nodeName, edge, value) {
this.push('YGNodeStyleSetPadding(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetPadding' + toFunctionName(value) + '(' + nodeName + ', ' + edge + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetPosition:{value:function(nodeName, edge, value) {
this.push('YGNodeStyleSetPosition(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetPosition' + toFunctionName(value) + '(' + nodeName + ', ' + edge + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetPositionType:{value:function(nodeName, value) {
this.push('YGNodeStyleSetPositionType(' + nodeName + ', ' + value + ');');
this.push('YGNodeStyleSetPositionType(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
YGNodeStyleSetWidth:{value:function(nodeName, value) {
this.push('YGNodeStyleSetWidth(' + nodeName + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetWidth' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
});

View File

@@ -7,6 +7,19 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
function toValueCs(value) {
var n = value.toString().replace('px','').replace('%','');
return n + (Number(n) == n && n % 1 !== 0 ? 'f' : '');
}
function toValueCsCs(value) {
var methodName = '';
if (value.indexOf('%') >= 0){
methodName = '.Percent()';
}
return toValueCs(value) + methodName;
}
var CSEmitter = function() {
Emitter.call(this, 'cs', ' ');
};
@@ -143,90 +156,90 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
}},
YGNodeStyleSetAlignContent:{value:function(nodeName, value) {
this.push(nodeName + '.AlignContent = ' + value + ';');
this.push(nodeName + '.AlignContent = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetAlignItems:{value:function(nodeName, value) {
this.push(nodeName + '.AlignItems = ' + value + ';');
this.push(nodeName + '.AlignItems = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetAlignSelf:{value:function(nodeName, value) {
this.push(nodeName + '.AlignSelf = ' + value + ';');
this.push(nodeName + '.AlignSelf = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetBorder:{value:function(nodeName, edge, value) {
this.push(nodeName + '.SetBorder(' + edge + ', ' + value + 'f);');
this.push(nodeName + '.SetBorder(' + edge + ', ' + toValueCs(value) + ');');
}},
YGNodeStyleSetDirection:{value:function(nodeName, value) {
this.push(nodeName + '.StyleDirection = ' + value + ';');
this.push(nodeName + '.StyleDirection = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetFlexBasis:{value:function(nodeName, value) {
this.push(nodeName + '.FlexBasis = ' + value + 'f;');
this.push(nodeName + '.FlexBasis = ' + toValueCsCs(value) + ';');
}},
YGNodeStyleSetFlexDirection:{value:function(nodeName, value) {
this.push(nodeName + '.FlexDirection = ' + value + ';');
this.push(nodeName + '.FlexDirection = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetFlexGrow:{value:function(nodeName, value) {
this.push(nodeName + '.FlexGrow = ' + value + 'f;');
this.push(nodeName + '.FlexGrow = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetFlexShrink:{value:function(nodeName, value) {
this.push(nodeName + '.FlexShrink = ' + value + 'f;');
this.push(nodeName + '.FlexShrink = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetFlexWrap:{value:function(nodeName, value) {
this.push(nodeName + '.Wrap = ' + value + ';');
this.push(nodeName + '.Wrap = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetHeight:{value:function(nodeName, value) {
this.push(nodeName + '.Height = ' + value + 'f;');
this.push(nodeName + '.Height = ' + toValueCsCs(value) + ';');
}},
YGNodeStyleSetJustifyContent:{value:function(nodeName, value) {
this.push(nodeName + '.JustifyContent = ' + value + ';');
this.push(nodeName + '.JustifyContent = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetMargin:{value:function(nodeName, edge, value) {
this.push(nodeName + '.SetMargin(' + edge + ', ' + value + 'f);');
this.push(nodeName + '.SetMargin(' + edge + ', ' + toValueCsCs(value) + ');');
}},
YGNodeStyleSetMaxHeight:{value:function(nodeName, value) {
this.push(nodeName + '.MaxHeight = ' + value + 'f;');
this.push(nodeName + '.MaxHeight = ' + toValueCsCs(value) + ';');
}},
YGNodeStyleSetMaxWidth:{value:function(nodeName, value) {
this.push(nodeName + '.MaxWidth = ' + value + 'f;');
this.push(nodeName + '.MaxWidth = ' + toValueCsCs(value) + ';');
}},
YGNodeStyleSetMinHeight:{value:function(nodeName, value) {
this.push(nodeName + '.MinHeight = ' + value + 'f;');
this.push(nodeName + '.MinHeight = ' + toValueCsCs(value) + ';');
}},
YGNodeStyleSetMinWidth:{value:function(nodeName, value) {
this.push(nodeName + '.MinWidth = ' + value + 'f;');
this.push(nodeName + '.MinWidth = ' + toValueCsCs(value) + ';');
}},
YGNodeStyleSetOverflow:{value:function(nodeName, value) {
this.push(nodeName + '.Overflow = ' + value + ';');
this.push(nodeName + '.Overflow = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetPadding:{value:function(nodeName, edge, value) {
this.push(nodeName + '.SetPadding(' + edge + ', ' + value + 'f);');
this.push(nodeName + '.SetPadding(' + edge + ', ' + toValueCsCs(value) + ');');
}},
YGNodeStyleSetPosition:{value:function(nodeName, edge, value) {
this.push(nodeName + '.SetPosition(' + edge + ', ' + value + 'f);');
this.push(nodeName + '.SetPosition(' + edge + ', ' + toValueCsCs(value) + ');');
}},
YGNodeStyleSetPositionType:{value:function(nodeName, value) {
this.push(nodeName + '.PositionType = ' + value + ';');
this.push(nodeName + '.PositionType = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetWidth:{value:function(nodeName, value) {
this.push(nodeName + '.Width = ' + value + 'f;');
this.push(nodeName + '.Width = ' + toValueCsCs(value) + ';');
}},
});

View File

@@ -7,6 +7,11 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
function toValueJava(value) {
var n = value.toString().replace('px','').replace('%','');
return n + (Number(n) == n && n % 1 !== 0 ? '' : '');
}
var JavaEmitter = function() {
Emitter.call(this, 'java', ' ');
};
@@ -148,90 +153,90 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
}},
YGNodeStyleSetAlignContent:{value:function(nodeName, value) {
this.push(nodeName + '.setAlignContent(' + value + ');');
this.push(nodeName + '.setAlignContent(' + toValueJava(value) + ');');
}},
YGNodeStyleSetAlignItems:{value:function(nodeName, value) {
this.push(nodeName + '.setAlignItems(' + value + ');');
this.push(nodeName + '.setAlignItems(' + toValueJava(value) + ');');
}},
YGNodeStyleSetAlignSelf:{value:function(nodeName, value) {
this.push(nodeName + '.setAlignSelf(' + value + ');');
this.push(nodeName + '.setAlignSelf(' + toValueJava(value) + ');');
}},
YGNodeStyleSetBorder:{value:function(nodeName, edge, value) {
this.push(nodeName + '.setBorder(' + edge + ', ' + value + 'f);');
this.push(nodeName + '.setBorder(' + edge + ', ' + toValueJava(value) + 'f);');
}},
YGNodeStyleSetDirection:{value:function(nodeName, value) {
this.push(nodeName + '.setDirection(' + value + ');');
this.push(nodeName + '.setDirection(' + toValueJava(value) + ');');
}},
YGNodeStyleSetFlexBasis:{value:function(nodeName, value) {
this.push(nodeName + '.setFlexBasis(' + value + 'f);');
this.push(nodeName + '.setFlexBasis(' + toValueJava(value) + 'f);');
}},
YGNodeStyleSetFlexDirection:{value:function(nodeName, value) {
this.push(nodeName + '.setFlexDirection(' + value + ');');
this.push(nodeName + '.setFlexDirection(' + toValueJava(value) + ');');
}},
YGNodeStyleSetFlexGrow:{value:function(nodeName, value) {
this.push(nodeName + '.setFlexGrow(' + value + 'f);');
this.push(nodeName + '.setFlexGrow(' + toValueJava(value) + 'f);');
}},
YGNodeStyleSetFlexShrink:{value:function(nodeName, value) {
this.push(nodeName + '.setFlexShrink(' + value + 'f);');
this.push(nodeName + '.setFlexShrink(' + toValueJava(value) + 'f);');
}},
YGNodeStyleSetFlexWrap:{value:function(nodeName, value) {
this.push(nodeName + '.setWrap(' + value + ');');
this.push(nodeName + '.setWrap(' + toValueJava(value) + ');');
}},
YGNodeStyleSetHeight:{value:function(nodeName, value) {
this.push(nodeName + '.setHeight(' + value + 'f);');
this.push(nodeName + '.setHeight(' + toValueJava(value) + 'f);');
}},
YGNodeStyleSetJustifyContent:{value:function(nodeName, value) {
this.push(nodeName + '.setJustifyContent(' + value + ');');
this.push(nodeName + '.setJustifyContent(' + toValueJava(value) + ');');
}},
YGNodeStyleSetMargin:{value:function(nodeName, edge, value) {
this.push(nodeName + '.setMargin(' + edge + ', ' + value + 'f);');
this.push(nodeName + '.setMargin(' + edge + ', ' + toValueJava(value) + 'f);');
}},
YGNodeStyleSetMaxHeight:{value:function(nodeName, value) {
this.push(nodeName + '.setMaxHeight(' + value + 'f);');
this.push(nodeName + '.setMaxHeight(' + toValueJava(value) + 'f);');
}},
YGNodeStyleSetMaxWidth:{value:function(nodeName, value) {
this.push(nodeName + '.setMaxWidth(' + value + 'f);');
this.push(nodeName + '.setMaxWidth(' + toValueJava(value) + 'f);');
}},
YGNodeStyleSetMinHeight:{value:function(nodeName, value) {
this.push(nodeName + '.setMinHeight(' + value + 'f);');
this.push(nodeName + '.setMinHeight(' + toValueJava(value) + 'f);');
}},
YGNodeStyleSetMinWidth:{value:function(nodeName, value) {
this.push(nodeName + '.setMinWidth(' + value + 'f);');
this.push(nodeName + '.setMinWidth(' + toValueJava(value) + 'f);');
}},
YGNodeStyleSetOverflow:{value:function(nodeName, value) {
this.push(nodeName + '.setOverflow(' + value + ');');
this.push(nodeName + '.setOverflow(' + toValueJava(value) + ');');
}},
YGNodeStyleSetPadding:{value:function(nodeName, edge, value) {
this.push(nodeName + '.setPadding(' + edge + ', ' + value + ');');
this.push(nodeName + '.setPadding(' + edge + ', ' + toValueJava(value) + ');');
}},
YGNodeStyleSetPosition:{value:function(nodeName, edge, value) {
this.push(nodeName + '.setPosition(' + edge + ', ' + value + 'f);');
this.push(nodeName + '.setPosition(' + edge + ', ' + toValueJava(value) + 'f);');
}},
YGNodeStyleSetPositionType:{value:function(nodeName, value) {
this.push(nodeName + '.setPositionType(' + value + ');');
this.push(nodeName + '.setPositionType(' + toValueJava(value) + ');');
}},
YGNodeStyleSetWidth:{value:function(nodeName, value) {
this.push(nodeName + '.setWidth(' + value + 'f);');
this.push(nodeName + '.setWidth(' + toValueJava(value) + 'f);');
}},
});

View File

@@ -378,7 +378,7 @@ function pixelValue(e, value) {
switch (value) {
case 'auto': return e.YGUndefined;
case 'undefined': return e.YGUndefined;
default: return value.replace('px', '');
default: return value;
}
}

View File

@@ -0,0 +1,941 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPercentageTest.html
package com.facebook.yoga;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class YGPercentageTest {
@Test
public void test_percentage_width_height() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setWidth(30f);
root_child0.setHeight(30f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(140f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_position_left_top() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(400f);
root.setHeight(400f);
final YogaNode root_child0 = new YogaNode();
root_child0.setPosition(YogaEdge.LEFT, 10f);
root_child0.setPosition(YogaEdge.TOP, 20f);
root_child0.setWidth(45f);
root_child0.setHeight(55f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(400f, root.getLayoutWidth(), 0.0f);
assertEquals(400f, root.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child0.getLayoutX(), 0.0f);
assertEquals(80f, root_child0.getLayoutY(), 0.0f);
assertEquals(180f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(220f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(400f, root.getLayoutWidth(), 0.0f);
assertEquals(400f, root.getLayoutHeight(), 0.0f);
assertEquals(260f, root_child0.getLayoutX(), 0.0f);
assertEquals(80f, root_child0.getLayoutY(), 0.0f);
assertEquals(180f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(220f, root_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_position_bottom_right() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(500f);
root.setHeight(500f);
final YogaNode root_child0 = new YogaNode();
root_child0.setPosition(YogaEdge.RIGHT, 20f);
root_child0.setPosition(YogaEdge.BOTTOM, 10f);
root_child0.setWidth(55f);
root_child0.setHeight(15f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(500f, root.getLayoutWidth(), 0.0f);
assertEquals(500f, root.getLayoutHeight(), 0.0f);
assertEquals(-100f, root_child0.getLayoutX(), 0.0f);
assertEquals(-50f, root_child0.getLayoutY(), 0.0f);
assertEquals(275f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(75f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(500f, root.getLayoutWidth(), 0.0f);
assertEquals(500f, root.getLayoutHeight(), 0.0f);
assertEquals(125f, root_child0.getLayoutX(), 0.0f);
assertEquals(-50f, root_child0.getLayoutY(), 0.0f);
assertEquals(275f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(75f, root_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(1f);
root_child1.setFlexBasis(25f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(125f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(125f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(75f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(75f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(125f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(75f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_cross() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(1f);
root_child1.setFlexBasis(25f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(125f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(125f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(75f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(125f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(125f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(75f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_cross_min_height() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setMinHeight(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(2f);
root_child1.setMinHeight(10f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(140f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(140f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(60f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(140f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(140f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(60f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_main_max_height() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(10f);
root_child0.setMaxHeight(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(4f);
root_child1.setFlexBasis(10f);
root_child1.setMaxHeight(20f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(52f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(120f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(52f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(148f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(148f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(52f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(120f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(148f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_cross_max_height() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(10f);
root_child0.setMaxHeight(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(4f);
root_child1.setFlexBasis(10f);
root_child1.setMaxHeight(20f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(120f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(120f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(120f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(120f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_main_max_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(15f);
root_child0.setMaxWidth(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(4f);
root_child1.setFlexBasis(10f);
root_child1.setMaxWidth(20f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(120f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(120f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(120f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_cross_max_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(10f);
root_child0.setMaxWidth(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(4f);
root_child1.setFlexBasis(15f);
root_child1.setMaxWidth(20f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(120f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(120f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(160f, root_child1.getLayoutX(), 0.0f);
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_main_min_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(15f);
root_child0.setMinWidth(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(4f);
root_child1.setFlexBasis(10f);
root_child1.setMinWidth(20f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(120f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(120f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(80f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(120f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(80f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_cross_min_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(10f);
root_child0.setMinWidth(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(4f);
root_child1.setFlexBasis(15f);
root_child1.setMinWidth(20f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_multiple_nested_with_padding_margin_and_percentage_values() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(10f);
root_child0.setMargin(YogaEdge.LEFT, 5f);
root_child0.setMargin(YogaEdge.TOP, 5f);
root_child0.setMargin(YogaEdge.RIGHT, 5f);
root_child0.setMargin(YogaEdge.BOTTOM, 5f);
root_child0.setPadding(YogaEdge.LEFT, 3);
root_child0.setPadding(YogaEdge.TOP, 3);
root_child0.setPadding(YogaEdge.RIGHT, 3);
root_child0.setPadding(YogaEdge.BOTTOM, 3);
root_child0.setMinWidth(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.setMargin(YogaEdge.LEFT, 5f);
root_child0_child0.setMargin(YogaEdge.TOP, 5f);
root_child0_child0.setMargin(YogaEdge.RIGHT, 5f);
root_child0_child0.setMargin(YogaEdge.BOTTOM, 5f);
root_child0_child0.setPadding(YogaEdge.LEFT, 3);
root_child0_child0.setPadding(YogaEdge.TOP, 3);
root_child0_child0.setPadding(YogaEdge.RIGHT, 3);
root_child0_child0.setPadding(YogaEdge.BOTTOM, 3);
root_child0_child0.setWidth(50f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child0_child0 = new YogaNode();
root_child0_child0_child0.setMargin(YogaEdge.LEFT, 5f);
root_child0_child0_child0.setMargin(YogaEdge.TOP, 5f);
root_child0_child0_child0.setMargin(YogaEdge.RIGHT, 5f);
root_child0_child0_child0.setMargin(YogaEdge.BOTTOM, 5f);
root_child0_child0_child0.setPadding(YogaEdge.LEFT, 3);
root_child0_child0_child0.setPadding(YogaEdge.TOP, 3);
root_child0_child0_child0.setPadding(YogaEdge.RIGHT, 3);
root_child0_child0_child0.setPadding(YogaEdge.BOTTOM, 3);
root_child0_child0_child0.setWidth(45f);
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(4f);
root_child1.setFlexBasis(15f);
root_child1.setMinWidth(20f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(5f, root_child0.getLayoutX(), 0.0f);
assertEquals(5f, root_child0.getLayoutY(), 0.0f);
assertEquals(190f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(48f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(8f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(8f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(92f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(36f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(6f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(58f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(142f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(5f, root_child0.getLayoutX(), 0.0f);
assertEquals(5f, root_child0.getLayoutY(), 0.0f);
assertEquals(190f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(48f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(8f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(92f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(46f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(36f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(6f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(58f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(142f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_margin_should_calculate_based_only_on_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setWidth(200f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setMargin(YogaEdge.LEFT, 10f);
root_child0.setMargin(YogaEdge.TOP, 10f);
root_child0.setMargin(YogaEdge.RIGHT, 10f);
root_child0.setMargin(YogaEdge.BOTTOM, 10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.setWidth(10f);
root_child0_child0.setHeight(10f);
root_child0.addChildAt(root_child0_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0.getLayoutX(), 0.0f);
assertEquals(20f, root_child0.getLayoutY(), 0.0f);
assertEquals(160f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0.getLayoutX(), 0.0f);
assertEquals(20f, root_child0.getLayoutY(), 0.0f);
assertEquals(160f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(150f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_padding_should_calculate_based_only_on_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setWidth(200f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setPadding(YogaEdge.LEFT, 10);
root_child0.setPadding(YogaEdge.TOP, 10);
root_child0.setPadding(YogaEdge.RIGHT, 10);
root_child0.setPadding(YogaEdge.BOTTOM, 10);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.setWidth(10f);
root_child0_child0.setHeight(10f);
root_child0.addChildAt(root_child0_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(170f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_absolute_position() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setWidth(200f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPosition(YogaEdge.LEFT, 30f);
root_child0.setPosition(YogaEdge.TOP, 10f);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(60f, root_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(60f, root_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
}

View File

@@ -27,49 +27,49 @@ TEST(YogaTest, assert_default_values) {
ASSERT_EQ(YGOverflowVisible, YGNodeStyleGetOverflow(root));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexGrow(root));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexShrink(root));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetFlexBasis(root)));
ASSERT_FALSE(YGNodeStyleGetFlexBasis(root).unit != YGUnitUndefined);
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeLeft)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeTop)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeRight)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeBottom)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeStart)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeEnd)));
ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeLeft).unit != YGUnitUndefined);
ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeTop).unit != YGUnitUndefined);
ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeRight).unit != YGUnitUndefined);
ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeBottom).unit != YGUnitUndefined);
ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeStart).unit != YGUnitUndefined);
ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeEnd).unit != YGUnitUndefined);
ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeLeft));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeTop));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeRight));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeBottom));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMargin(root, YGEdgeStart)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMargin(root, YGEdgeEnd)));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeLeft).value);
ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeTop).value);
ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeRight).value);
ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeBottom).value);
ASSERT_FALSE(YGNodeStyleGetMargin(root, YGEdgeStart).unit != YGUnitUndefined);
ASSERT_FALSE(YGNodeStyleGetMargin(root, YGEdgeEnd).unit != YGUnitUndefined);
ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeLeft));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeTop));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeRight));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeBottom));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPadding(root, YGEdgeStart)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPadding(root, YGEdgeEnd)));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeLeft).value);
ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeTop).value);
ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeRight).value);
ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeBottom).value);
ASSERT_FALSE(YGNodeStyleGetPadding(root, YGEdgeStart).unit != YGUnitUndefined);
ASSERT_FALSE(YGNodeStyleGetPadding(root, YGEdgeEnd).unit != YGUnitUndefined);
ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeLeft));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeTop));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeRight));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeBottom));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetBorder(root, YGEdgeStart)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetBorder(root, YGEdgeEnd)));
ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetBorder(root, YGEdgeStart)));
ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetBorder(root, YGEdgeEnd)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetWidth(root)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetHeight(root)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMinWidth(root)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMinHeight(root)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMaxWidth(root)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMaxHeight(root)));
ASSERT_FALSE(YGNodeStyleGetWidth(root).unit != YGUnitUndefined);
ASSERT_FALSE(YGNodeStyleGetHeight(root).unit != YGUnitUndefined);
ASSERT_FALSE(YGNodeStyleGetMinWidth(root).unit != YGUnitUndefined);
ASSERT_FALSE(YGNodeStyleGetMinHeight(root).unit != YGUnitUndefined);
ASSERT_FALSE(YGNodeStyleGetMaxWidth(root).unit != YGUnitUndefined);
ASSERT_FALSE(YGNodeStyleGetMaxHeight(root).unit != YGUnitUndefined);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetRight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetBottom(root));
ASSERT_TRUE(YGValueIsUndefined(YGNodeLayoutGetWidth(root)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeLayoutGetHeight(root)));
ASSERT_TRUE(YGFloatIsUndefined(YGNodeLayoutGetWidth(root)));
ASSERT_TRUE(YGFloatIsUndefined(YGNodeLayoutGetHeight(root)));
ASSERT_EQ(YGDirectionInherit, YGNodeLayoutGetDirection(root));
YGNodeFreeRecursive(root);

View File

@@ -283,7 +283,7 @@ TEST(YogaTest, overflow_scroll_column) {
ASSERT_FLOAT_EQ(100, constraintList.constraints[0].width);
ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].widthMode);
ASSERT_TRUE(YGValueIsUndefined(constraintList.constraints[0].height));
ASSERT_TRUE(YGFloatIsUndefined(constraintList.constraints[0].height));
ASSERT_EQ(YGMeasureModeUndefined, constraintList.constraints[0].heightMode);
free(constraintList.constraints);
@@ -312,7 +312,7 @@ TEST(YogaTest, overflow_scroll_row) {
ASSERT_EQ(1, constraintList.length);
ASSERT_TRUE(YGValueIsUndefined(constraintList.constraints[0].width));
ASSERT_TRUE(YGFloatIsUndefined(constraintList.constraints[0].width));
ASSERT_EQ(YGMeasureModeUndefined, constraintList.constraints[0].widthMode);
ASSERT_FLOAT_EQ(100, constraintList.constraints[0].height);

919
tests/YGPercentageTest.cpp Normal file
View File

@@ -0,0 +1,919 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPercentageTest.html
#include <yoga/Yoga.h>
#include <gtest/gtest.h>
TEST(YogaTest, percentage_width_height) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidthPercent(root_child0, 30);
YGNodeStyleSetHeightPercent(root_child0, 30);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_position_left_top) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 400);
YGNodeStyleSetHeight(root, 400);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetPositionPercent(root_child0, YGEdgeLeft, 10);
YGNodeStyleSetPositionPercent(root_child0, YGEdgeTop, 20);
YGNodeStyleSetWidthPercent(root_child0, 45);
YGNodeStyleSetHeightPercent(root_child0, 55);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(220, YGNodeLayoutGetHeight(root_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(260, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(220, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_position_bottom_right) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 500);
YGNodeStyleSetHeight(root, 500);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetPositionPercent(root_child0, YGEdgeRight, 20);
YGNodeStyleSetPositionPercent(root_child0, YGEdgeBottom, 10);
YGNodeStyleSetWidthPercent(root_child0, 55);
YGNodeStyleSetHeightPercent(root_child0, 15);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(-100, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(-50, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(275, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(-50, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(275, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_flex_basis) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetFlexBasisPercent(root_child1, 25);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_flex_basis_cross) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetFlexBasisPercent(root_child1, 25);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_flex_basis_cross_min_height) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMinHeightPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 2);
YGNodeStyleSetMinHeightPercent(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(140, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(140, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(140, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(140, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_flex_basis_main_max_height) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 10);
YGNodeStyleSetMaxHeightPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 10);
YGNodeStyleSetMaxHeightPercent(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(52, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(52, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(148, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(148, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(52, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(148, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_flex_basis_cross_max_height) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 10);
YGNodeStyleSetMaxHeightPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 10);
YGNodeStyleSetMaxHeightPercent(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_flex_basis_main_max_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 15);
YGNodeStyleSetMaxWidthPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 10);
YGNodeStyleSetMaxWidthPercent(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_flex_basis_cross_max_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 10);
YGNodeStyleSetMaxWidthPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 15);
YGNodeStyleSetMaxWidthPercent(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_flex_basis_main_min_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 15);
YGNodeStyleSetMinWidthPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 10);
YGNodeStyleSetMinWidthPercent(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_flex_basis_cross_min_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 10);
YGNodeStyleSetMinWidthPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 15);
YGNodeStyleSetMinWidthPercent(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_values) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 5);
YGNodeStyleSetMargin(root_child0, YGEdgeTop, 5);
YGNodeStyleSetMargin(root_child0, YGEdgeRight, 5);
YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 5);
YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 3);
YGNodeStyleSetPadding(root_child0, YGEdgeTop, 3);
YGNodeStyleSetPadding(root_child0, YGEdgeRight, 3);
YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 3);
YGNodeStyleSetMinWidthPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
YGNodeStyleSetMargin(root_child0_child0, YGEdgeLeft, 5);
YGNodeStyleSetMargin(root_child0_child0, YGEdgeTop, 5);
YGNodeStyleSetMargin(root_child0_child0, YGEdgeRight, 5);
YGNodeStyleSetMargin(root_child0_child0, YGEdgeBottom, 5);
YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeLeft, 3);
YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeTop, 3);
YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeRight, 3);
YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeBottom, 3);
YGNodeStyleSetWidthPercent(root_child0_child0, 50);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child0_child0_child0 = YGNodeNew();
YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeLeft, 5);
YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeTop, 5);
YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeRight, 5);
YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeBottom, 5);
YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeLeft, 3);
YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeTop, 3);
YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeRight, 3);
YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeBottom, 3);
YGNodeStyleSetWidthPercent(root_child0_child0_child0, 45);
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 15);
YGNodeStyleSetMinWidthPercent(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(190, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(48, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(8, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(8, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(92, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child0_child0));
ASSERT_FLOAT_EQ(36, YGNodeLayoutGetWidth(root_child0_child0_child0));
ASSERT_FLOAT_EQ(6, YGNodeLayoutGetHeight(root_child0_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(58, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(142, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(190, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(48, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(8, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(92, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(46, YGNodeLayoutGetLeft(root_child0_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child0_child0));
ASSERT_FLOAT_EQ(36, YGNodeLayoutGetWidth(root_child0_child0_child0));
ASSERT_FLOAT_EQ(6, YGNodeLayoutGetHeight(root_child0_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(58, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(142, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_margin_should_calculate_based_only_on_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMarginPercent(root_child0, YGEdgeLeft, 10);
YGNodeStyleSetMarginPercent(root_child0, YGEdgeTop, 10);
YGNodeStyleSetMarginPercent(root_child0, YGEdgeRight, 10);
YGNodeStyleSetMarginPercent(root_child0, YGEdgeBottom, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0_child0, 10);
YGNodeStyleSetHeight(root_child0_child0, 10);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(160, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(160, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_padding_should_calculate_based_only_on_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeLeft, 10);
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeTop, 10);
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeRight, 10);
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeBottom, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0_child0, 10);
YGNodeStyleSetHeight(root_child0_child0, 10);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(170, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_absolute_position) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPositionPercent(root_child0, YGEdgeLeft, 30);
YGNodeStyleSetPositionPercent(root_child0, YGEdgeTop, 10);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}

View File

@@ -26,7 +26,7 @@ TEST(YogaTest, copy_style_modified) {
const YGNodeRef node0 = YGNodeNew();
ASSERT_FALSE(YGNodeIsDirty(node0));
ASSERT_EQ(YGFlexDirectionColumn, YGNodeStyleGetFlexDirection(node0));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMaxHeight(node0)));
ASSERT_FALSE(YGNodeStyleGetMaxHeight(node0).unit != YGUnitUndefined);
const YGNodeRef node1 = YGNodeNew();
YGNodeStyleSetFlexDirection(node1, YGFlexDirectionRow);
@@ -35,7 +35,7 @@ TEST(YogaTest, copy_style_modified) {
YGNodeCopyStyle(node0, node1);
ASSERT_TRUE(YGNodeIsDirty(node0));
ASSERT_EQ(YGFlexDirectionRow, YGNodeStyleGetFlexDirection(node0));
ASSERT_FLOAT_EQ(10, YGNodeStyleGetMaxHeight(node0));
ASSERT_FLOAT_EQ(10, YGNodeStyleGetMaxHeight(node0).value);
YGNodeFree(node0);
YGNodeFree(node1);

View File

@@ -21,6 +21,13 @@ typedef enum YGFlexDirection {
YGFlexDirectionRowReverse,
emilsjolander commented 2016-12-18 22:12:54 -08:00 (Migrated from github.com)
Review

YGUnitModeCount?? should be YGUnitCount probably. Did you forget to re-generate after changes?

YGUnitModeCount?? should be YGUnitCount probably. Did you forget to re-generate after changes?
} YGFlexDirection;
#define YGUnitCount 3
typedef enum YGUnit {
YGUnitUndefined,
YGUnitPixel,
YGUnitPercent,
} YGUnit;
#define YGMeasureModeCount 3
typedef enum YGMeasureMode {
YGMeasureModeUndefined,

File diff suppressed because it is too large Load Diff

View File

@@ -38,6 +38,11 @@ typedef struct YGSize {
float height;
emilsjolander commented 2016-12-18 22:13:11 -08:00 (Migrated from github.com)
Review

remove empty line

remove empty line
emilsjolander commented 2016-12-18 22:13:35 -08:00 (Migrated from github.com)
Review

space before { (actually just run format.sh)

space before { (actually just run format.sh)
woehrl01 commented 2016-12-19 10:23:01 -08:00 (Migrated from github.com)
Review

I would like to do this, but setting everything up on my maschine would be a huge job. As I have no linux runtime currently available, and also no clang localy. It would be greate if you could run this, after your import, if you don't mind. Same for enum.py, currently I have no python installed. If not I'll try my best to set this up locally, could take a while (the clang environment).

I would like to do this, but setting everything up on my maschine would be a huge job. As I have no linux runtime currently available, and also no clang localy. It would be greate if you could run this, after your import, if you don't mind. Same for enum.py, currently I have no python installed. If not I'll try my best to set this up locally, could take a while (the clang environment).
emilsjolander commented 2016-12-19 11:56:48 -08:00 (Migrated from github.com)
Review

isDefined

isDefined
woehrl01 commented 2016-12-19 12:09:04 -08:00 (Migrated from github.com)
Review

great idea!

great idea!
} YGSize;
typedef struct YGValue {
float value;
YGUnit unit;
} YGValue;
typedef struct YGNode *YGNodeRef;
typedef YGSize (*YGMeasureFunc)(YGNodeRef node,
float width,
@@ -83,7 +88,7 @@ WIN_EXPORT bool YGNodeIsDirty(const YGNodeRef node);
WIN_EXPORT void YGNodePrint(const YGNodeRef node, const YGPrintOptions options);
WIN_EXPORT bool YGValueIsUndefined(const float value);
WIN_EXPORT bool YGFloatIsUndefined(const float value);
emilsjolander commented 2016-12-18 22:16:31 -08:00 (Migrated from github.com)
Review

No reason to have this function as we export the defined member of YGValue

No reason to have this function as we export the `defined` member of `YGValue`
WIN_EXPORT bool YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode,
const float width,
@@ -108,12 +113,26 @@ WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const type paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node);
#define YG_NODE_STYLE_PROPERTY_UNIT(type, name, paramName) \
emilsjolander commented 2016-12-19 11:57:20 -08:00 (Migrated from github.com)
Review

##name##( -> ##name(

##name##( -> ##name(
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const float paramName); \
WIN_EXPORT void YGNodeStyleSet##name##Percent(const YGNodeRef node, const float paramName); \
emilsjolander commented 2016-12-18 22:18:49 -08:00 (Migrated from github.com)
Review

Let's remove the *WithUnit APIs and just use units everywhere. This makes the API smaller and more concise. Also it forces the user to think about units.

Let's remove the *WithUnit APIs and just use units everywhere. This makes the API smaller and more concise. Also it forces the user to think about units.
woehrl01 commented 2016-12-18 22:55:57 -08:00 (Migrated from github.com)
Review

How should we return the units in the getter? Should I use YGValue in both get + set or use (float, YGUnitPixel) in the set and return only the float in get?

How should we return the units in the getter? Should I use YGValue in both get + set or use (float, YGUnitPixel) in the set and return only the float in get?
emilsjolander commented 2016-12-18 23:09:51 -08:00 (Migrated from github.com)
Review

The getter should return a YGValue as well.

The getter should return a YGValue as well.
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node);
#define YG_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \
const YGEdge edge, \
const type paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge);
#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \
const YGEdge edge, \
const float paramName); \
WIN_EXPORT void YGNodeStyleSet##name##Percent(const YGNodeRef node, \
const YGEdge edge, \
const float paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge);
#define YG_NODE_LAYOUT_PROPERTY(type, name) \
WIN_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node);
@@ -135,19 +154,19 @@ YG_NODE_STYLE_PROPERTY(YGOverflow, Overflow, overflow);
WIN_EXPORT void YGNodeStyleSetFlex(const YGNodeRef node, const float flex);
YG_NODE_STYLE_PROPERTY(float, FlexGrow, flexGrow);
YG_NODE_STYLE_PROPERTY(float, FlexShrink, flexShrink);
YG_NODE_STYLE_PROPERTY(float, FlexBasis, flexBasis);
YG_NODE_STYLE_PROPERTY_UNIT(YGValue, FlexBasis, flexBasis);
YG_NODE_STYLE_EDGE_PROPERTY(float, Position, position);
YG_NODE_STYLE_EDGE_PROPERTY(float, Margin, margin);
YG_NODE_STYLE_EDGE_PROPERTY(float, Padding, padding);
YG_NODE_STYLE_EDGE_PROPERTY_UNIT(YGValue, Position, position);
YG_NODE_STYLE_EDGE_PROPERTY_UNIT(YGValue, Margin, margin);
YG_NODE_STYLE_EDGE_PROPERTY_UNIT(YGValue, Padding, padding);
YG_NODE_STYLE_EDGE_PROPERTY(float, Border, border);
YG_NODE_STYLE_PROPERTY(float, Width, width);
YG_NODE_STYLE_PROPERTY(float, Height, height);
YG_NODE_STYLE_PROPERTY(float, MinWidth, minWidth);
YG_NODE_STYLE_PROPERTY(float, MinHeight, minHeight);
YG_NODE_STYLE_PROPERTY(float, MaxWidth, maxWidth);
YG_NODE_STYLE_PROPERTY(float, MaxHeight, maxHeight);
YG_NODE_STYLE_PROPERTY_UNIT(YGValue, Width, width);
YG_NODE_STYLE_PROPERTY_UNIT(YGValue, Height, height);
YG_NODE_STYLE_PROPERTY_UNIT(YGValue, MinWidth, minWidth);
YG_NODE_STYLE_PROPERTY_UNIT(YGValue, MinHeight, minHeight);
YG_NODE_STYLE_PROPERTY_UNIT(YGValue, MaxWidth, maxWidth);
YG_NODE_STYLE_PROPERTY_UNIT(YGValue, MaxHeight, maxHeight);
// Yoga specific properties, not compatible with flexbox specification
// Aspect ratio control the size of the undefined dimension of a node.