diff --git a/YogaKit/Source/YGLayout.m b/YogaKit/Source/YGLayout.m index 01f3354f..e7634b49 100644 --- a/YogaKit/Source/YGLayout.m +++ b/YogaKit/Source/YGLayout.m @@ -85,6 +85,8 @@ YG_VALUE_EDGE_PROPERTY(lowercased_name##Horizontal, capitalized_name##Horizontal YG_VALUE_EDGE_PROPERTY(lowercased_name##Vertical, capitalized_name##Vertical, capitalized_name, YGEdgeVertical) \ YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, capitalized_name, YGEdgeAll) +static YGConfigRef globalConfig; + @interface YGLayout () @property (nonatomic, weak, readonly) UIView *view; @@ -99,14 +101,15 @@ YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, capitalized_name, YGEd + (void)initialize { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true); + globalConfig = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(globalConfig, YGExperimentalFeatureWebFlexBasis, true); } - (instancetype)initWithView:(UIView*)view { if (self = [super init]) { _view = view; - _node = YGNodeNew(); + _node = YGNodeNewWithConfig(globalConfig); YGNodeSetContext(_node, (__bridge void *) view); _isEnabled = NO; _isIncludedInLayout = YES; diff --git a/csharp/Facebook.Yoga/Native.cs b/csharp/Facebook.Yoga/Native.cs index 3f3db639..db83f3b9 100644 --- a/csharp/Facebook.Yoga/Native.cs +++ b/csharp/Facebook.Yoga/Native.cs @@ -75,6 +75,38 @@ namespace Facebook.Yoga #endif } + internal class YGConfigHandle : SafeHandle + { +#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__ + private GCHandle _managed; +#endif + + private YGConfigHandle() : base(IntPtr.Zero, true) + { + } + + public override bool IsInvalid + { + get + { + return this.handle == IntPtr.Zero; + } + } + + protected override bool ReleaseHandle() + { +#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__ + if (_managed.IsAllocated) + { + _managed.Free(); + } +#endif + Native.YGConfigFree(this.handle); + GC.KeepAlive(this); + return true; + } + } + [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGInteropSetLogger( [MarshalAs(UnmanagedType.FunctionPtr)] YogaLogger.Func func); @@ -82,22 +114,33 @@ namespace Facebook.Yoga [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern YGNodeHandle YGNodeNew(); + [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] + public static extern YGNodeHandle YGNodeNewWithConfig(YGConfigHandle config); + [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeFree(IntPtr node); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeReset(YGNodeHandle node); + [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] + public static extern YGConfigHandle YGConfigNew(); + + [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] + public static extern void YGConfigFree(IntPtr node); + [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern int YGNodeGetInstanceCount(); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - public static extern void YGSetExperimentalFeatureEnabled( + public static extern void YGConfigSetExperimentalFeatureEnabled( + YGConfigHandle config, YogaExperimentalFeature feature, bool enabled); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - public static extern bool YGIsExperimentalFeatureEnabled( + public static extern bool YGConfigIsExperimentalFeatureEnabled( + YGConfigHandle config, YogaExperimentalFeature feature); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] @@ -258,7 +301,7 @@ namespace Facebook.Yoga [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeStyleSetHeightPercent(YGNodeHandle node, float height); - + [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeStyleSetHeightAuto(YGNodeHandle node); diff --git a/csharp/Facebook.Yoga/YogaNode.cs b/csharp/Facebook.Yoga/YogaNode.cs index 8bf1c8b8..0bb1349f 100644 --- a/csharp/Facebook.Yoga/YogaNode.cs +++ b/csharp/Facebook.Yoga/YogaNode.cs @@ -21,6 +21,40 @@ using ObjCRuntime; namespace Facebook.Yoga { + public class YogaConfig + { + + private Native.YGConfigHandle _ygConfig; + + public YogaConfig() + { + _ygConfig = Native.YGConfigNew(); + if (_ygConfig.IsInvalid) + { + throw new InvalidOperationException("Failed to allocate native memory"); + } + } + + internal Native.YGConfigHandle Handle { + get { + return _ygConfig; + } + } + + public void SetExperimentalFeatureEnabled( + YogaExperimentalFeature feature, + bool enabled) + { + Native.YGConfigSetExperimentalFeatureEnabled(_ygConfig, feature, enabled); + } + + public bool IsExperimentalFeatureEnabled(YogaExperimentalFeature feature) + { + return Native.YGConfigIsExperimentalFeatureEnabled(_ygConfig, feature); + } + + } + public partial class YogaNode : IEnumerable { private Native.YGNodeHandle _ygNode; @@ -48,6 +82,17 @@ namespace Facebook.Yoga } } + public YogaNode(YogaConfig config) + { + YogaLogger.Initialize(); + + _ygNode = Native.YGNodeNewWithConfig(config.Handle); + if (_ygNode.IsInvalid) + { + throw new InvalidOperationException("Failed to allocate native memory"); + } + } + public YogaNode(YogaNode srcNode) : this() { @@ -681,17 +726,5 @@ namespace Facebook.Yoga { return Native.YGNodeGetInstanceCount(); } - - public static void SetExperimentalFeatureEnabled( - YogaExperimentalFeature feature, - bool enabled) - { - Native.YGSetExperimentalFeatureEnabled(feature, enabled); - } - - public static bool IsExperimentalFeatureEnabled(YogaExperimentalFeature feature) - { - return Native.YGIsExperimentalFeatureEnabled(feature); - } } } diff --git a/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs b/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs index 17296a2e..b2277bfb 100644 --- a/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs @@ -20,11 +20,13 @@ namespace Facebook.Yoga [Test] public void Test_absolute_layout_width_height_start_top() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; root_child0.Start = 10; root_child0.Top = 10; @@ -61,11 +63,13 @@ namespace Facebook.Yoga [Test] public void Test_absolute_layout_width_height_end_bottom() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; root_child0.End = 10; root_child0.Bottom = 10; @@ -102,11 +106,13 @@ namespace Facebook.Yoga [Test] public void Test_absolute_layout_start_top_end_bottom() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; root_child0.Start = 10; root_child0.Top = 10; @@ -143,11 +149,13 @@ namespace Facebook.Yoga [Test] public void Test_absolute_layout_width_height_start_top_end_bottom() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; root_child0.Start = 10; root_child0.Top = 10; @@ -186,19 +194,21 @@ namespace Facebook.Yoga [Test] public void Test_do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Overflow = YogaOverflow.Hidden; root.Width = 50; root.Height = 50; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; root_child0.Start = 0; root_child0.Top = 0; root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.Width = 100; root_child0_child0.Height = 100; root_child0.Insert(0, root_child0_child0); @@ -242,7 +252,9 @@ namespace Facebook.Yoga [Test] public void Test_absolute_layout_within_border() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.MarginLeft = 10; root.MarginTop = 10; root.MarginRight = 10; @@ -258,7 +270,7 @@ namespace Facebook.Yoga root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; root_child0.Left = 0; root_child0.Top = 0; @@ -266,7 +278,7 @@ namespace Facebook.Yoga root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.PositionType = YogaPositionType.Absolute; root_child1.Right = 0; root_child1.Bottom = 0; @@ -313,14 +325,16 @@ namespace Facebook.Yoga [Test] public void Test_absolute_layout_align_items_and_justify_content_center() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.Center; root.AlignItems = YogaAlign.Center; root.FlexGrow = 1; root.Width = 110; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; root_child0.Width = 60; root_child0.Height = 40; @@ -355,14 +369,16 @@ namespace Facebook.Yoga [Test] public void Test_absolute_layout_align_items_and_justify_content_flex_end() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.FlexEnd; root.AlignItems = YogaAlign.FlexEnd; root.FlexGrow = 1; root.Width = 110; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; root_child0.Width = 60; root_child0.Height = 40; @@ -397,13 +413,15 @@ namespace Facebook.Yoga [Test] public void Test_absolute_layout_justify_content_center() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.Center; root.FlexGrow = 1; root.Width = 110; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; root_child0.Width = 60; root_child0.Height = 40; @@ -438,13 +456,15 @@ namespace Facebook.Yoga [Test] public void Test_absolute_layout_align_items_center() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.Center; root.FlexGrow = 1; root.Width = 110; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; root_child0.Width = 60; root_child0.Height = 40; @@ -479,12 +499,14 @@ namespace Facebook.Yoga [Test] public void Test_absolute_layout_align_items_center_on_child_only() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexGrow = 1; root.Width = 110; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.AlignSelf = YogaAlign.Center; root_child0.PositionType = YogaPositionType.Absolute; root_child0.Width = 60; @@ -520,14 +542,16 @@ namespace Facebook.Yoga [Test] public void Test_absolute_layout_align_items_and_justify_content_center_and_top_position() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.Center; root.AlignItems = YogaAlign.Center; root.FlexGrow = 1; root.Width = 110; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; root_child0.Top = 10; root_child0.Width = 60; @@ -563,14 +587,16 @@ namespace Facebook.Yoga [Test] public void Test_absolute_layout_align_items_and_justify_content_center_and_bottom_position() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.Center; root.AlignItems = YogaAlign.Center; root.FlexGrow = 1; root.Width = 110; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; root_child0.Bottom = 10; root_child0.Width = 60; @@ -606,14 +632,16 @@ namespace Facebook.Yoga [Test] public void Test_absolute_layout_align_items_and_justify_content_center_and_left_position() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.Center; root.AlignItems = YogaAlign.Center; root.FlexGrow = 1; root.Width = 110; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; root_child0.Left = 5; root_child0.Width = 60; @@ -649,14 +677,16 @@ namespace Facebook.Yoga [Test] public void Test_absolute_layout_align_items_and_justify_content_center_and_right_position() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.Center; root.AlignItems = YogaAlign.Center; root.FlexGrow = 1; root.Width = 110; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; root_child0.Right = 5; root_child0.Width = 60; diff --git a/csharp/tests/Facebook.Yoga/YGAlignContentTest.cs b/csharp/tests/Facebook.Yoga/YGAlignContentTest.cs index 9fc045a6..487ed02a 100644 --- a/csharp/tests/Facebook.Yoga/YGAlignContentTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAlignContentTest.cs @@ -20,33 +20,35 @@ namespace Facebook.Yoga [Test] public void Test_align_content_flex_start() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Wrap = YogaWrap.Wrap; root.Width = 130; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root_child2.Height = 10; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 50; root_child3.Height = 10; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 50; root_child4.Height = 10; root.Insert(4, root_child4); @@ -120,30 +122,32 @@ namespace Facebook.Yoga [Test] public void Test_align_content_flex_start_without_height_on_children() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Wrap = YogaWrap.Wrap; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 50; root_child3.Height = 10; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 50; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; @@ -216,36 +220,38 @@ namespace Facebook.Yoga [Test] public void Test_align_content_flex_start_with_flex() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Wrap = YogaWrap.Wrap; root.Width = 100; root.Height = 120; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexBasis = 0.Percent(); root_child0.Width = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root_child1.FlexBasis = 0.Percent(); root_child1.Width = 50; root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.FlexGrow = 1; root_child3.FlexShrink = 1; root_child3.FlexBasis = 0.Percent(); root_child3.Width = 50; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 50; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; @@ -318,33 +324,35 @@ namespace Facebook.Yoga [Test] public void Test_align_content_flex_end() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignContent = YogaAlign.FlexEnd; root.Wrap = YogaWrap.Wrap; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root_child2.Height = 10; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 50; root_child3.Height = 10; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 50; root_child4.Height = 10; root.Insert(4, root_child4); @@ -418,29 +426,31 @@ namespace Facebook.Yoga [Test] public void Test_align_content_stretch() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignContent = YogaAlign.Stretch; root.Wrap = YogaWrap.Wrap; root.Width = 150; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 50; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 50; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; @@ -513,34 +523,36 @@ namespace Facebook.Yoga [Test] public void Test_align_content_spacebetween() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignContent = YogaAlign.SpaceBetween; root.Wrap = YogaWrap.Wrap; root.Width = 130; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root_child2.Height = 10; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 50; root_child3.Height = 10; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 50; root_child4.Height = 10; root.Insert(4, root_child4); @@ -614,34 +626,36 @@ namespace Facebook.Yoga [Test] public void Test_align_content_spacearound() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignContent = YogaAlign.SpaceAround; root.Wrap = YogaWrap.Wrap; root.Width = 140; root.Height = 120; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root_child2.Height = 10; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 50; root_child3.Height = 10; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 50; root_child4.Height = 10; root.Insert(4, root_child4); @@ -715,30 +729,32 @@ namespace Facebook.Yoga [Test] public void Test_align_content_stretch_row() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignContent = YogaAlign.Stretch; root.Wrap = YogaWrap.Wrap; root.Width = 150; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 50; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 50; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; @@ -811,36 +827,38 @@ namespace Facebook.Yoga [Test] public void Test_align_content_stretch_row_with_children() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignContent = YogaAlign.Stretch; root.Wrap = YogaWrap.Wrap; root.Width = 150; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.FlexGrow = 1; root_child0_child0.FlexShrink = 1; root_child0_child0.FlexBasis = 0.Percent(); root_child0.Insert(0, root_child0_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 50; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 50; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; @@ -923,36 +941,38 @@ namespace Facebook.Yoga [Test] public void Test_align_content_stretch_row_with_flex() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignContent = YogaAlign.Stretch; root.Wrap = YogaWrap.Wrap; root.Width = 150; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root_child1.FlexShrink = 1; root_child1.FlexBasis = 0.Percent(); root_child1.Width = 50; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.FlexGrow = 1; root_child3.FlexShrink = 1; root_child3.FlexBasis = 0.Percent(); root_child3.Width = 50; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 50; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; @@ -1025,35 +1045,37 @@ namespace Facebook.Yoga [Test] public void Test_align_content_stretch_row_with_flex_no_shrink() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignContent = YogaAlign.Stretch; root.Wrap = YogaWrap.Wrap; root.Width = 150; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root_child1.FlexShrink = 1; root_child1.FlexBasis = 0.Percent(); root_child1.Width = 50; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.FlexGrow = 1; root_child3.FlexBasis = 0.Percent(); root_child3.Width = 50; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 50; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; @@ -1126,18 +1148,20 @@ namespace Facebook.Yoga [Test] public void Test_align_content_stretch_row_with_margin() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignContent = YogaAlign.Stretch; root.Wrap = YogaWrap.Wrap; root.Width = 150; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.MarginLeft = 10; root_child1.MarginTop = 10; root_child1.MarginRight = 10; @@ -1145,11 +1169,11 @@ namespace Facebook.Yoga root_child1.Width = 50; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.MarginLeft = 10; root_child3.MarginTop = 10; root_child3.MarginRight = 10; @@ -1157,7 +1181,7 @@ namespace Facebook.Yoga root_child3.Width = 50; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 50; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; @@ -1230,18 +1254,20 @@ namespace Facebook.Yoga [Test] public void Test_align_content_stretch_row_with_padding() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignContent = YogaAlign.Stretch; root.Wrap = YogaWrap.Wrap; root.Width = 150; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.PaddingLeft = 10; root_child1.PaddingTop = 10; root_child1.PaddingRight = 10; @@ -1249,11 +1275,11 @@ namespace Facebook.Yoga root_child1.Width = 50; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.PaddingLeft = 10; root_child3.PaddingTop = 10; root_child3.PaddingRight = 10; @@ -1261,7 +1287,7 @@ namespace Facebook.Yoga root_child3.Width = 50; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 50; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; @@ -1334,18 +1360,20 @@ namespace Facebook.Yoga [Test] public void Test_align_content_stretch_row_with_single_row() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignContent = YogaAlign.Stretch; root.Wrap = YogaWrap.Wrap; root.Width = 150; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -1388,31 +1416,33 @@ namespace Facebook.Yoga [Test] public void Test_align_content_stretch_row_with_fixed_height() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignContent = YogaAlign.Stretch; root.Wrap = YogaWrap.Wrap; root.Width = 150; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 60; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 50; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 50; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; @@ -1485,31 +1515,33 @@ namespace Facebook.Yoga [Test] public void Test_align_content_stretch_row_with_max_height() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignContent = YogaAlign.Stretch; root.Wrap = YogaWrap.Wrap; root.Width = 150; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.MaxHeight = 20; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 50; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 50; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; @@ -1582,31 +1614,33 @@ namespace Facebook.Yoga [Test] public void Test_align_content_stretch_row_with_min_height() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignContent = YogaAlign.Stretch; root.Wrap = YogaWrap.Wrap; root.Width = 150; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.MinHeight = 80; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 50; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 50; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; @@ -1679,38 +1713,40 @@ namespace Facebook.Yoga [Test] public void Test_align_content_stretch_column() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignContent = YogaAlign.Stretch; root.Wrap = YogaWrap.Wrap; root.Width = 100; root.Height = 150; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.FlexGrow = 1; root_child0_child0.FlexShrink = 1; root_child0_child0.FlexBasis = 0.Percent(); root_child0.Insert(0, root_child0_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root_child1.FlexShrink = 1; root_child1.FlexBasis = 0.Percent(); root_child1.Height = 50; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Height = 50; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Height = 50; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Height = 50; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; @@ -1793,10 +1829,12 @@ namespace Facebook.Yoga [Test] public void Test_align_content_stretch_is_not_overriding_align_items() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignContent = YogaAlign.Stretch; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexDirection = YogaFlexDirection.Row; root_child0.AlignContent = YogaAlign.Stretch; root_child0.AlignItems = YogaAlign.Center; @@ -1804,7 +1842,7 @@ namespace Facebook.Yoga root_child0.Height = 100; root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.AlignContent = YogaAlign.Stretch; root_child0_child0.Width = 10; root_child0_child0.Height = 10; diff --git a/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs b/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs index 12efdf63..d5022c10 100644 --- a/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs @@ -20,11 +20,13 @@ namespace Facebook.Yoga [Test] public void Test_align_items_stretch() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; @@ -57,12 +59,14 @@ namespace Facebook.Yoga [Test] public void Test_align_items_center() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.Center; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 10; root_child0.Height = 10; root.Insert(0, root_child0); @@ -96,12 +100,14 @@ namespace Facebook.Yoga [Test] public void Test_align_items_flex_start() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.FlexStart; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 10; root_child0.Height = 10; root.Insert(0, root_child0); @@ -135,12 +141,14 @@ namespace Facebook.Yoga [Test] public void Test_align_items_flex_end() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.FlexEnd; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 10; root_child0.Height = 10; root.Insert(0, root_child0); @@ -174,18 +182,20 @@ namespace Facebook.Yoga [Test] public void Test_align_baseline() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.Baseline; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 20; root.Insert(1, root_child1); @@ -229,23 +239,25 @@ namespace Facebook.Yoga [Test] public void Test_align_baseline_child() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.Baseline; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 20; root.Insert(1, root_child1); - YogaNode root_child1_child0 = new YogaNode(); + YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.Width = 50; root_child1_child0.Height = 10; root_child1.Insert(0, root_child1_child0); @@ -299,40 +311,42 @@ namespace Facebook.Yoga [Test] public void Test_align_baseline_child_multiline() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.Baseline; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 60; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexDirection = YogaFlexDirection.Row; root_child1.Wrap = YogaWrap.Wrap; root_child1.Width = 50; root_child1.Height = 25; root.Insert(1, root_child1); - YogaNode root_child1_child0 = new YogaNode(); + YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.Width = 25; root_child1_child0.Height = 20; root_child1.Insert(0, root_child1_child0); - YogaNode root_child1_child1 = new YogaNode(); + YogaNode root_child1_child1 = new YogaNode(config); root_child1_child1.Width = 25; root_child1_child1.Height = 10; root_child1.Insert(1, root_child1_child1); - YogaNode root_child1_child2 = new YogaNode(); + YogaNode root_child1_child2 = new YogaNode(config); root_child1_child2.Width = 25; root_child1_child2.Height = 20; root_child1.Insert(2, root_child1_child2); - YogaNode root_child1_child3 = new YogaNode(); + YogaNode root_child1_child3 = new YogaNode(config); root_child1_child3.Width = 25; root_child1_child3.Height = 10; root_child1.Insert(3, root_child1_child3); @@ -416,41 +430,43 @@ namespace Facebook.Yoga [Test] public void Test_align_baseline_child_multiline_override() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.Baseline; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 60; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexDirection = YogaFlexDirection.Row; root_child1.Wrap = YogaWrap.Wrap; root_child1.Width = 50; root_child1.Height = 25; root.Insert(1, root_child1); - YogaNode root_child1_child0 = new YogaNode(); + YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.Width = 25; root_child1_child0.Height = 20; root_child1.Insert(0, root_child1_child0); - YogaNode root_child1_child1 = new YogaNode(); + YogaNode root_child1_child1 = new YogaNode(config); root_child1_child1.AlignSelf = YogaAlign.Baseline; root_child1_child1.Width = 25; root_child1_child1.Height = 10; root_child1.Insert(1, root_child1_child1); - YogaNode root_child1_child2 = new YogaNode(); + YogaNode root_child1_child2 = new YogaNode(config); root_child1_child2.Width = 25; root_child1_child2.Height = 20; root_child1.Insert(2, root_child1_child2); - YogaNode root_child1_child3 = new YogaNode(); + YogaNode root_child1_child3 = new YogaNode(config); root_child1_child3.AlignSelf = YogaAlign.Baseline; root_child1_child3.Width = 25; root_child1_child3.Height = 10; @@ -535,40 +551,42 @@ namespace Facebook.Yoga [Test] public void Test_align_baseline_child_multiline_no_override_on_secondline() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.Baseline; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 60; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexDirection = YogaFlexDirection.Row; root_child1.Wrap = YogaWrap.Wrap; root_child1.Width = 50; root_child1.Height = 25; root.Insert(1, root_child1); - YogaNode root_child1_child0 = new YogaNode(); + YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.Width = 25; root_child1_child0.Height = 20; root_child1.Insert(0, root_child1_child0); - YogaNode root_child1_child1 = new YogaNode(); + YogaNode root_child1_child1 = new YogaNode(config); root_child1_child1.Width = 25; root_child1_child1.Height = 10; root_child1.Insert(1, root_child1_child1); - YogaNode root_child1_child2 = new YogaNode(); + YogaNode root_child1_child2 = new YogaNode(config); root_child1_child2.Width = 25; root_child1_child2.Height = 20; root_child1.Insert(2, root_child1_child2); - YogaNode root_child1_child3 = new YogaNode(); + YogaNode root_child1_child3 = new YogaNode(config); root_child1_child3.AlignSelf = YogaAlign.Baseline; root_child1_child3.Width = 25; root_child1_child3.Height = 10; @@ -653,24 +671,26 @@ namespace Facebook.Yoga [Test] public void Test_align_baseline_child_top() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.Baseline; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Top = 10; root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 20; root.Insert(1, root_child1); - YogaNode root_child1_child0 = new YogaNode(); + YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.Width = 50; root_child1_child0.Height = 10; root_child1.Insert(0, root_child1_child0); @@ -724,24 +744,26 @@ namespace Facebook.Yoga [Test] public void Test_align_baseline_child_top2() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.Baseline; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Top = 5; root_child1.Width = 50; root_child1.Height = 20; root.Insert(1, root_child1); - YogaNode root_child1_child0 = new YogaNode(); + YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.Width = 50; root_child1_child0.Height = 10; root_child1.Insert(0, root_child1_child0); @@ -795,28 +817,30 @@ namespace Facebook.Yoga [Test] public void Test_align_baseline_double_nested_child() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.Baseline; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.Width = 50; root_child0_child0.Height = 20; root_child0.Insert(0, root_child0_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 20; root.Insert(1, root_child1); - YogaNode root_child1_child0 = new YogaNode(); + YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.Width = 50; root_child1_child0.Height = 15; root_child1.Insert(0, root_child1_child0); @@ -880,17 +904,19 @@ namespace Facebook.Yoga [Test] public void Test_align_baseline_column() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.Baseline; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 20; root.Insert(1, root_child1); @@ -934,13 +960,15 @@ namespace Facebook.Yoga [Test] public void Test_align_baseline_child_margin() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.Baseline; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginLeft = 5; root_child0.MarginTop = 5; root_child0.MarginRight = 5; @@ -949,12 +977,12 @@ namespace Facebook.Yoga root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 20; root.Insert(1, root_child1); - YogaNode root_child1_child0 = new YogaNode(); + YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.MarginLeft = 1; root_child1_child0.MarginTop = 1; root_child1_child0.MarginRight = 1; @@ -1012,7 +1040,9 @@ namespace Facebook.Yoga [Test] public void Test_align_baseline_child_padding() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.Baseline; root.PaddingLeft = 5; @@ -1022,12 +1052,12 @@ namespace Facebook.Yoga root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.PaddingLeft = 5; root_child1.PaddingTop = 5; root_child1.PaddingRight = 5; @@ -1036,7 +1066,7 @@ namespace Facebook.Yoga root_child1.Height = 20; root.Insert(1, root_child1); - YogaNode root_child1_child0 = new YogaNode(); + YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.Width = 50; root_child1_child0.Height = 10; root_child1.Insert(0, root_child1_child0); @@ -1090,39 +1120,41 @@ namespace Facebook.Yoga [Test] public void Test_align_baseline_multiline() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.Baseline; root.Wrap = YogaWrap.Wrap; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 20; root.Insert(1, root_child1); - YogaNode root_child1_child0 = new YogaNode(); + YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.Width = 50; root_child1_child0.Height = 10; root_child1.Insert(0, root_child1_child0); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root_child2.Height = 20; root.Insert(2, root_child2); - YogaNode root_child2_child0 = new YogaNode(); + YogaNode root_child2_child0 = new YogaNode(config); root_child2_child0.Width = 50; root_child2_child0.Height = 10; root_child2.Insert(0, root_child2_child0); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 50; root_child3.Height = 50; root.Insert(3, root_child3); @@ -1206,38 +1238,40 @@ namespace Facebook.Yoga [Test] public void Test_align_baseline_multiline_column() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.Baseline; root.Wrap = YogaWrap.Wrap; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 30; root_child1.Height = 50; root.Insert(1, root_child1); - YogaNode root_child1_child0 = new YogaNode(); + YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.Width = 20; root_child1_child0.Height = 20; root_child1.Insert(0, root_child1_child0); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 40; root_child2.Height = 70; root.Insert(2, root_child2); - YogaNode root_child2_child0 = new YogaNode(); + YogaNode root_child2_child0 = new YogaNode(config); root_child2_child0.Width = 10; root_child2_child0.Height = 10; root_child2.Insert(0, root_child2_child0); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 50; root_child3.Height = 20; root.Insert(3, root_child3); @@ -1321,38 +1355,40 @@ namespace Facebook.Yoga [Test] public void Test_align_baseline_multiline_column2() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.Baseline; root.Wrap = YogaWrap.Wrap; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 30; root_child1.Height = 50; root.Insert(1, root_child1); - YogaNode root_child1_child0 = new YogaNode(); + YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.Width = 20; root_child1_child0.Height = 20; root_child1.Insert(0, root_child1_child0); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 40; root_child2.Height = 70; root.Insert(2, root_child2); - YogaNode root_child2_child0 = new YogaNode(); + YogaNode root_child2_child0 = new YogaNode(config); root_child2_child0.Width = 10; root_child2_child0.Height = 10; root_child2.Insert(0, root_child2_child0); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 50; root_child3.Height = 20; root.Insert(3, root_child3); @@ -1436,39 +1472,41 @@ namespace Facebook.Yoga [Test] public void Test_align_baseline_multiline_row_and_column() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.Baseline; root.Wrap = YogaWrap.Wrap; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 50; root.Insert(1, root_child1); - YogaNode root_child1_child0 = new YogaNode(); + YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.Width = 50; root_child1_child0.Height = 10; root_child1.Insert(0, root_child1_child0); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root_child2.Height = 20; root.Insert(2, root_child2); - YogaNode root_child2_child0 = new YogaNode(); + YogaNode root_child2_child0 = new YogaNode(config); root_child2_child0.Width = 50; root_child2_child0.Height = 10; root_child2.Insert(0, root_child2_child0); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 50; root_child3.Height = 20; root.Insert(3, root_child3); diff --git a/csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs b/csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs index 7c04f45d..b7358b14 100644 --- a/csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs @@ -20,11 +20,13 @@ namespace Facebook.Yoga [Test] public void Test_align_self_center() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.AlignSelf = YogaAlign.Center; root_child0.Width = 10; root_child0.Height = 10; @@ -59,11 +61,13 @@ namespace Facebook.Yoga [Test] public void Test_align_self_flex_end() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.AlignSelf = YogaAlign.FlexEnd; root_child0.Width = 10; root_child0.Height = 10; @@ -98,11 +102,13 @@ namespace Facebook.Yoga [Test] public void Test_align_self_flex_start() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.AlignSelf = YogaAlign.FlexStart; root_child0.Width = 10; root_child0.Height = 10; @@ -137,12 +143,14 @@ namespace Facebook.Yoga [Test] public void Test_align_self_flex_end_override_flex_start() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.FlexStart; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.AlignSelf = YogaAlign.FlexEnd; root_child0.Width = 10; root_child0.Height = 10; @@ -177,24 +185,26 @@ namespace Facebook.Yoga [Test] public void Test_align_self_baseline() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.AlignSelf = YogaAlign.Baseline; root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.AlignSelf = YogaAlign.Baseline; root_child1.Width = 50; root_child1.Height = 20; root.Insert(1, root_child1); - YogaNode root_child1_child0 = new YogaNode(); + YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.Width = 50; root_child1_child0.Height = 10; root_child1.Insert(0, root_child1_child0); diff --git a/csharp/tests/Facebook.Yoga/YGBorderTest.cs b/csharp/tests/Facebook.Yoga/YGBorderTest.cs index ebfca861..d673abc9 100644 --- a/csharp/tests/Facebook.Yoga/YGBorderTest.cs +++ b/csharp/tests/Facebook.Yoga/YGBorderTest.cs @@ -20,7 +20,9 @@ namespace Facebook.Yoga [Test] public void Test_border_no_size() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.BorderLeftWidth = 10; root.BorderTopWidth = 10; root.BorderRightWidth = 10; @@ -45,13 +47,15 @@ namespace Facebook.Yoga [Test] public void Test_border_container_match_child() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.BorderLeftWidth = 10; root.BorderTopWidth = 10; root.BorderRightWidth = 10; root.BorderBottomWidth = 10; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 10; root_child0.Height = 10; root.Insert(0, root_child0); @@ -85,7 +89,9 @@ namespace Facebook.Yoga [Test] public void Test_border_flex_child() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.BorderLeftWidth = 10; root.BorderTopWidth = 10; root.BorderRightWidth = 10; @@ -93,7 +99,7 @@ namespace Facebook.Yoga root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.Width = 10; root.Insert(0, root_child0); @@ -127,7 +133,9 @@ namespace Facebook.Yoga [Test] public void Test_border_stretch_child() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.BorderLeftWidth = 10; root.BorderTopWidth = 10; root.BorderRightWidth = 10; @@ -135,7 +143,7 @@ namespace Facebook.Yoga root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; @@ -168,7 +176,9 @@ namespace Facebook.Yoga [Test] public void Test_border_center_child() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.Center; root.AlignItems = YogaAlign.Center; root.BorderStartWidth = 10; @@ -177,7 +187,7 @@ namespace Facebook.Yoga root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 10; root_child0.Height = 10; root.Insert(0, root_child0); diff --git a/csharp/tests/Facebook.Yoga/YGDimensionTest.cs b/csharp/tests/Facebook.Yoga/YGDimensionTest.cs index 7d1f6df7..1443572a 100644 --- a/csharp/tests/Facebook.Yoga/YGDimensionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGDimensionTest.cs @@ -20,9 +20,11 @@ namespace Facebook.Yoga [Test] public void Test_wrap_child() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); - YogaNode root_child0 = new YogaNode(); + YogaNode root = new YogaNode(config); + + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 100; root_child0.Height = 100; root.Insert(0, root_child0); @@ -56,12 +58,14 @@ namespace Facebook.Yoga [Test] public void Test_wrap_grandchild() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); - YogaNode root_child0 = new YogaNode(); + YogaNode root = new YogaNode(config); + + YogaNode root_child0 = new YogaNode(config); root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.Width = 100; root_child0_child0.Height = 100; root_child0.Insert(0, root_child0_child0); diff --git a/csharp/tests/Facebook.Yoga/YGDisplayTest.cs b/csharp/tests/Facebook.Yoga/YGDisplayTest.cs index ccaa35c8..02fd6fac 100644 --- a/csharp/tests/Facebook.Yoga/YGDisplayTest.cs +++ b/csharp/tests/Facebook.Yoga/YGDisplayTest.cs @@ -20,16 +20,18 @@ namespace Facebook.Yoga [Test] public void Test_display_none() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root_child1.Display = YogaDisplay.None; root.Insert(1, root_child1); @@ -73,16 +75,18 @@ namespace Facebook.Yoga [Test] public void Test_display_none_fixed_size() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 20; root_child1.Height = 20; root_child1.Display = YogaDisplay.None; @@ -127,12 +131,14 @@ namespace Facebook.Yoga [Test] public void Test_display_none_with_margin() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginLeft = 10; root_child0.MarginTop = 10; root_child0.MarginRight = 10; @@ -142,7 +148,7 @@ namespace Facebook.Yoga root_child0.Display = YogaDisplay.None; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -185,25 +191,27 @@ namespace Facebook.Yoga [Test] public void Test_display_none_with_child() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexShrink = 1; root_child0.FlexBasis = 0.Percent(); root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root_child1.FlexShrink = 1; root_child1.FlexBasis = 0.Percent(); root_child1.Display = YogaDisplay.None; root.Insert(1, root_child1); - YogaNode root_child1_child0 = new YogaNode(); + YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.FlexGrow = 1; root_child1_child0.FlexShrink = 1; root_child1_child0.FlexBasis = 0.Percent(); @@ -212,7 +220,7 @@ namespace Facebook.Yoga root_child1_child0.MinHeight = 0; root_child1.Insert(0, root_child1_child0); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.FlexGrow = 1; root_child2.FlexShrink = 1; root_child2.FlexBasis = 0.Percent(); @@ -277,16 +285,18 @@ namespace Facebook.Yoga [Test] public void Test_display_none_with_position() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root_child1.Top = 10; root_child1.Display = YogaDisplay.None; diff --git a/csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs b/csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs index bfb7a353..e473f05b 100644 --- a/csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs @@ -20,18 +20,20 @@ namespace Facebook.Yoga [Test] public void Test_flex_direction_column_no_height() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -84,19 +86,21 @@ namespace Facebook.Yoga [Test] public void Test_flex_direction_row_no_width() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -149,19 +153,21 @@ namespace Facebook.Yoga [Test] public void Test_flex_direction_column() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -214,20 +220,22 @@ namespace Facebook.Yoga [Test] public void Test_flex_direction_row() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -280,20 +288,22 @@ namespace Facebook.Yoga [Test] public void Test_flex_direction_column_reverse() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.ColumnReverse; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -346,20 +356,22 @@ namespace Facebook.Yoga [Test] public void Test_flex_direction_row_reverse() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.RowReverse; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; diff --git a/csharp/tests/Facebook.Yoga/YGFlexTest.cs b/csharp/tests/Facebook.Yoga/YGFlexTest.cs index b3c1e653..b980b540 100644 --- a/csharp/tests/Facebook.Yoga/YGFlexTest.cs +++ b/csharp/tests/Facebook.Yoga/YGFlexTest.cs @@ -20,16 +20,18 @@ namespace Facebook.Yoga [Test] public void Test_flex_basis_flex_grow_column() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexBasis = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -72,17 +74,19 @@ namespace Facebook.Yoga [Test] public void Test_flex_basis_flex_grow_row() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexBasis = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -125,16 +129,18 @@ namespace Facebook.Yoga [Test] public void Test_flex_basis_flex_shrink_column() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexShrink = 1; root_child0.FlexBasis = 100; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexBasis = 50; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -177,17 +183,19 @@ namespace Facebook.Yoga [Test] public void Test_flex_basis_flex_shrink_row() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexShrink = 1; root_child0.FlexBasis = 100; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexBasis = 50; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -230,21 +238,23 @@ namespace Facebook.Yoga [Test] public void Test_flex_shrink_to_zero() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Height = 75; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexShrink = 1; root_child1.Width = 50; root_child1.Height = 50; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root_child2.Height = 50; root.Insert(2, root_child2); @@ -298,22 +308,24 @@ namespace Facebook.Yoga [Test] public void Test_flex_basis_overrides_main_size() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexBasis = 50; root_child0.Height = 20; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.FlexGrow = 1; root_child2.Height = 10; root.Insert(2, root_child2); @@ -367,14 +379,16 @@ namespace Facebook.Yoga [Test] public void Test_flex_grow_shrink_at_most() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.FlexGrow = 1; root_child0_child0.FlexShrink = 1; root_child0.Insert(0, root_child0_child0); diff --git a/csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs b/csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs index 2a9a7536..2172dee7 100644 --- a/csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs +++ b/csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs @@ -20,26 +20,28 @@ namespace Facebook.Yoga [Test] public void Test_wrap_column() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Wrap = YogaWrap.Wrap; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 30; root_child0.Height = 30; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 30; root_child1.Height = 30; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 30; root_child2.Height = 30; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 30; root_child3.Height = 30; root.Insert(3, root_child3); @@ -103,27 +105,29 @@ namespace Facebook.Yoga [Test] public void Test_wrap_row() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Wrap = YogaWrap.Wrap; root.Width = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 30; root_child0.Height = 30; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 30; root_child1.Height = 30; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 30; root_child2.Height = 30; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 30; root_child3.Height = 30; root.Insert(3, root_child3); @@ -187,28 +191,30 @@ namespace Facebook.Yoga [Test] public void Test_wrap_row_align_items_flex_end() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.FlexEnd; root.Wrap = YogaWrap.Wrap; root.Width = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 30; root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 30; root_child1.Height = 20; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 30; root_child2.Height = 30; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 30; root_child3.Height = 30; root.Insert(3, root_child3); @@ -272,28 +278,30 @@ namespace Facebook.Yoga [Test] public void Test_wrap_row_align_items_center() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.Center; root.Wrap = YogaWrap.Wrap; root.Width = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 30; root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 30; root_child1.Height = 20; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 30; root_child2.Height = 30; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 30; root_child3.Height = 30; root.Insert(3, root_child3); @@ -357,18 +365,20 @@ namespace Facebook.Yoga [Test] public void Test_flex_wrap_children_with_min_main_overriding_flex_basis() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Wrap = YogaWrap.Wrap; root.Width = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexBasis = 50; root_child0.MinWidth = 55; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexBasis = 50; root_child1.MinWidth = 55; root_child1.Height = 50; @@ -413,24 +423,26 @@ namespace Facebook.Yoga [Test] public void Test_flex_wrap_wrap_to_child_height() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); - YogaNode root_child0 = new YogaNode(); + YogaNode root = new YogaNode(config); + + YogaNode root_child0 = new YogaNode(config); root_child0.FlexDirection = YogaFlexDirection.Row; root_child0.AlignItems = YogaAlign.FlexStart; root_child0.Wrap = YogaWrap.Wrap; root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.Width = 100; root_child0.Insert(0, root_child0_child0); - YogaNode root_child0_child0_child0 = new YogaNode(); + YogaNode root_child0_child0_child0 = new YogaNode(config); root_child0_child0_child0.Width = 100; root_child0_child0_child0.Height = 100; root_child0_child0.Insert(0, root_child0_child0_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 100; root_child1.Height = 100; root.Insert(1, root_child1); @@ -494,17 +506,19 @@ namespace Facebook.Yoga [Test] public void Test_flex_wrap_align_stretch_fits_one_row() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Wrap = YogaWrap.Wrap; root.Width = 150; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -547,32 +561,34 @@ namespace Facebook.Yoga [Test] public void Test_wrap_reverse_row_align_content_flex_start() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Wrap = YogaWrap.WrapReverse; root.Width = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 30; root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 30; root_child1.Height = 20; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 30; root_child2.Height = 30; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 30; root_child3.Height = 40; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 30; root_child4.Height = 50; root.Insert(4, root_child4); @@ -646,33 +662,35 @@ namespace Facebook.Yoga [Test] public void Test_wrap_reverse_row_align_content_center() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignContent = YogaAlign.Center; root.Wrap = YogaWrap.WrapReverse; root.Width = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 30; root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 30; root_child1.Height = 20; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 30; root_child2.Height = 30; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 30; root_child3.Height = 40; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 30; root_child4.Height = 50; root.Insert(4, root_child4); @@ -746,32 +764,34 @@ namespace Facebook.Yoga [Test] public void Test_wrap_reverse_row_single_line_different_size() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Wrap = YogaWrap.WrapReverse; root.Width = 300; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 30; root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 30; root_child1.Height = 20; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 30; root_child2.Height = 30; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 30; root_child3.Height = 40; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 30; root_child4.Height = 50; root.Insert(4, root_child4); @@ -845,33 +865,35 @@ namespace Facebook.Yoga [Test] public void Test_wrap_reverse_row_align_content_stretch() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignContent = YogaAlign.Stretch; root.Wrap = YogaWrap.WrapReverse; root.Width = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 30; root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 30; root_child1.Height = 20; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 30; root_child2.Height = 30; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 30; root_child3.Height = 40; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 30; root_child4.Height = 50; root.Insert(4, root_child4); @@ -945,33 +967,35 @@ namespace Facebook.Yoga [Test] public void Test_wrap_reverse_row_align_content_space_around() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignContent = YogaAlign.SpaceAround; root.Wrap = YogaWrap.WrapReverse; root.Width = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 30; root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 30; root_child1.Height = 20; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 30; root_child2.Height = 30; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 30; root_child3.Height = 40; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 30; root_child4.Height = 50; root.Insert(4, root_child4); @@ -1045,33 +1069,35 @@ namespace Facebook.Yoga [Test] public void Test_wrap_reverse_column_fixed_size() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.Center; root.Wrap = YogaWrap.WrapReverse; root.Width = 200; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 30; root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 30; root_child1.Height = 20; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 30; root_child2.Height = 30; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.Width = 30; root_child3.Height = 40; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.Width = 30; root_child4.Height = 50; root.Insert(4, root_child4); @@ -1145,22 +1171,24 @@ namespace Facebook.Yoga [Test] public void Test_wrapped_row_within_align_items_center() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.Center; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexDirection = YogaFlexDirection.Row; root_child0.Wrap = YogaWrap.Wrap; root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.Width = 150; root_child0_child0.Height = 80; root_child0.Insert(0, root_child0_child0); - YogaNode root_child0_child1 = new YogaNode(); + YogaNode root_child0_child1 = new YogaNode(config); root_child0_child1.Width = 80; root_child0_child1.Height = 80; root_child0.Insert(1, root_child0_child1); @@ -1214,22 +1242,24 @@ namespace Facebook.Yoga [Test] public void Test_wrapped_row_within_align_items_flex_start() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.FlexStart; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexDirection = YogaFlexDirection.Row; root_child0.Wrap = YogaWrap.Wrap; root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.Width = 150; root_child0_child0.Height = 80; root_child0.Insert(0, root_child0_child0); - YogaNode root_child0_child1 = new YogaNode(); + YogaNode root_child0_child1 = new YogaNode(config); root_child0_child1.Width = 80; root_child0_child1.Height = 80; root_child0.Insert(1, root_child0_child1); @@ -1283,22 +1313,24 @@ namespace Facebook.Yoga [Test] public void Test_wrapped_row_within_align_items_flex_end() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.FlexEnd; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexDirection = YogaFlexDirection.Row; root_child0.Wrap = YogaWrap.Wrap; root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.Width = 150; root_child0_child0.Height = 80; root_child0.Insert(0, root_child0_child0); - YogaNode root_child0_child1 = new YogaNode(); + YogaNode root_child0_child1 = new YogaNode(config); root_child0_child1.Width = 80; root_child0_child1.Height = 80; root_child0.Insert(1, root_child0_child1); diff --git a/csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs b/csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs index 02f22ba9..7073164a 100644 --- a/csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs +++ b/csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs @@ -20,20 +20,22 @@ namespace Facebook.Yoga [Test] public void Test_justify_content_row_flex_start() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 102; root.Height = 102; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -86,21 +88,23 @@ namespace Facebook.Yoga [Test] public void Test_justify_content_row_flex_end() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.FlexEnd; root.Width = 102; root.Height = 102; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -153,21 +157,23 @@ namespace Facebook.Yoga [Test] public void Test_justify_content_row_center() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.Center; root.Width = 102; root.Height = 102; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -220,21 +226,23 @@ namespace Facebook.Yoga [Test] public void Test_justify_content_row_space_between() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.SpaceBetween; root.Width = 102; root.Height = 102; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -287,21 +295,23 @@ namespace Facebook.Yoga [Test] public void Test_justify_content_row_space_around() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.SpaceAround; root.Width = 102; root.Height = 102; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -354,18 +364,20 @@ namespace Facebook.Yoga [Test] public void Test_justify_content_column_flex_start() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 102; root.Height = 102; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -418,20 +430,22 @@ namespace Facebook.Yoga [Test] public void Test_justify_content_column_flex_end() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.FlexEnd; root.Width = 102; root.Height = 102; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -484,20 +498,22 @@ namespace Facebook.Yoga [Test] public void Test_justify_content_column_center() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.Center; root.Width = 102; root.Height = 102; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -550,20 +566,22 @@ namespace Facebook.Yoga [Test] public void Test_justify_content_column_space_between() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.SpaceBetween; root.Width = 102; root.Height = 102; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -616,20 +634,22 @@ namespace Facebook.Yoga [Test] public void Test_justify_content_column_space_around() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.SpaceAround; root.Width = 102; root.Height = 102; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Height = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; diff --git a/csharp/tests/Facebook.Yoga/YGMarginTest.cs b/csharp/tests/Facebook.Yoga/YGMarginTest.cs index ec0e11ab..fb019502 100644 --- a/csharp/tests/Facebook.Yoga/YGMarginTest.cs +++ b/csharp/tests/Facebook.Yoga/YGMarginTest.cs @@ -20,12 +20,14 @@ namespace Facebook.Yoga [Test] public void Test_margin_start() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginStart = 10; root_child0.Width = 10; root.Insert(0, root_child0); @@ -59,11 +61,13 @@ namespace Facebook.Yoga [Test] public void Test_margin_top() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginTop = 10; root_child0.Height = 10; root.Insert(0, root_child0); @@ -97,13 +101,15 @@ namespace Facebook.Yoga [Test] public void Test_margin_end() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.FlexEnd; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginEnd = 10; root_child0.Width = 10; root.Insert(0, root_child0); @@ -137,12 +143,14 @@ namespace Facebook.Yoga [Test] public void Test_margin_bottom() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.FlexEnd; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginBottom = 10; root_child0.Height = 10; root.Insert(0, root_child0); @@ -176,12 +184,14 @@ namespace Facebook.Yoga [Test] public void Test_margin_and_flex_row() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.MarginStart = 10; root_child0.MarginEnd = 10; @@ -216,11 +226,13 @@ namespace Facebook.Yoga [Test] public void Test_margin_and_flex_column() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.MarginTop = 10; root_child0.MarginBottom = 10; @@ -255,12 +267,14 @@ namespace Facebook.Yoga [Test] public void Test_margin_and_stretch_row() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.MarginTop = 10; root_child0.MarginBottom = 10; @@ -295,11 +309,13 @@ namespace Facebook.Yoga [Test] public void Test_margin_and_stretch_column() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.MarginStart = 10; root_child0.MarginEnd = 10; @@ -334,17 +350,19 @@ namespace Facebook.Yoga [Test] public void Test_margin_with_sibling_row() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.MarginEnd = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -387,16 +405,18 @@ namespace Facebook.Yoga [Test] public void Test_margin_with_sibling_column() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.MarginBottom = 10; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -439,18 +459,20 @@ namespace Facebook.Yoga [Test] public void Test_margin_auto_bottom() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.Center; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginBottom = YogaValue.Auto(); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 50; root.Insert(1, root_child1); @@ -494,18 +516,20 @@ namespace Facebook.Yoga [Test] public void Test_margin_auto_top() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.Center; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginTop = YogaValue.Auto(); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 50; root.Insert(1, root_child1); @@ -549,19 +573,21 @@ namespace Facebook.Yoga [Test] public void Test_margin_auto_bottom_and_top() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.Center; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginTop = YogaValue.Auto(); root_child0.MarginBottom = YogaValue.Auto(); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 50; root.Insert(1, root_child1); @@ -605,19 +631,21 @@ namespace Facebook.Yoga [Test] public void Test_margin_auto_bottom_and_top_justify_center() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.Center; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginTop = YogaValue.Auto(); root_child0.MarginBottom = YogaValue.Auto(); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 50; root.Insert(1, root_child1); @@ -661,24 +689,26 @@ namespace Facebook.Yoga [Test] public void Test_margin_auto_mutiple_children_column() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.Center; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginTop = YogaValue.Auto(); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.MarginTop = YogaValue.Auto(); root_child1.Width = 50; root_child1.Height = 50; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root_child2.Height = 50; root.Insert(2, root_child2); @@ -732,25 +762,27 @@ namespace Facebook.Yoga [Test] public void Test_margin_auto_mutiple_children_row() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.Center; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginRight = YogaValue.Auto(); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.MarginRight = YogaValue.Auto(); root_child1.Width = 50; root_child1.Height = 50; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root_child2.Height = 50; root.Insert(2, root_child2); @@ -804,20 +836,22 @@ namespace Facebook.Yoga [Test] public void Test_margin_auto_left_and_right_column() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.Center; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginLeft = YogaValue.Auto(); root_child0.MarginRight = YogaValue.Auto(); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 50; root.Insert(1, root_child1); @@ -861,18 +895,20 @@ namespace Facebook.Yoga [Test] public void Test_margin_auto_left_and_right() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginLeft = YogaValue.Auto(); root_child0.MarginRight = YogaValue.Auto(); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 50; root.Insert(1, root_child1); @@ -1028,19 +1064,21 @@ namespace Facebook.Yoga [Test] public void Test_margin_auto_left_and_right_column_and_center() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.Center; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginLeft = YogaValue.Auto(); root_child0.MarginRight = YogaValue.Auto(); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 50; root.Insert(1, root_child1); @@ -1084,18 +1122,20 @@ namespace Facebook.Yoga [Test] public void Test_margin_auto_left() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.Center; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginLeft = YogaValue.Auto(); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 50; root.Insert(1, root_child1); @@ -1139,18 +1179,20 @@ namespace Facebook.Yoga [Test] public void Test_margin_auto_right() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.Center; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginRight = YogaValue.Auto(); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 50; root.Insert(1, root_child1); @@ -1194,19 +1236,21 @@ namespace Facebook.Yoga [Test] public void Test_margin_auto_left_and_right_strech() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginLeft = YogaValue.Auto(); root_child0.MarginRight = YogaValue.Auto(); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 50; root.Insert(1, root_child1); @@ -1250,18 +1294,20 @@ namespace Facebook.Yoga [Test] public void Test_margin_auto_top_and_bottom_strech() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MarginTop = YogaValue.Auto(); root_child0.MarginBottom = YogaValue.Auto(); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 50; root.Insert(1, root_child1); diff --git a/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs b/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs index 7ebfa382..080e6777 100644 --- a/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs @@ -20,11 +20,13 @@ namespace Facebook.Yoga [Test] public void Test_max_width() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MaxWidth = 50; root_child0.Height = 10; root.Insert(0, root_child0); @@ -58,12 +60,14 @@ namespace Facebook.Yoga [Test] public void Test_max_height() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 10; root_child0.MaxHeight = 50; root.Insert(0, root_child0); @@ -97,16 +101,18 @@ namespace Facebook.Yoga [Test] public void Test_min_height() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.MinHeight = 60; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -149,17 +155,19 @@ namespace Facebook.Yoga [Test] public void Test_min_width() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.MinWidth = 60; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -202,13 +210,15 @@ namespace Facebook.Yoga [Test] public void Test_justify_content_min_max() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.Center; root.Width = 100; root.MinHeight = 100; root.MaxHeight = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 60; root_child0.Height = 60; root.Insert(0, root_child0); @@ -242,13 +252,15 @@ namespace Facebook.Yoga [Test] public void Test_align_items_min_max() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.Center; root.MinWidth = 100; root.MaxWidth = 200; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 60; root_child0.Height = 60; root.Insert(0, root_child0); @@ -282,22 +294,24 @@ namespace Facebook.Yoga [Test] public void Test_justify_content_overflow_min_max() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.Center; root.MinHeight = 100; root.MaxHeight = 110; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root_child1.Height = 50; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 50; root_child2.Height = 50; root.Insert(2, root_child2); @@ -351,19 +365,20 @@ namespace Facebook.Yoga [Test] public void Test_flex_grow_to_min() { - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.MinFlexFix, true); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.MinFlexFix, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.Width = 100; root.MinHeight = 100; root.MaxHeight = 500; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexShrink = 1; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Height = 50; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -401,26 +416,25 @@ namespace Facebook.Yoga Assert.AreEqual(50f, root_child1.LayoutY); Assert.AreEqual(100f, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutHeight); - - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.MinFlexFix, false); } [Test] public void Test_flex_grow_in_at_most_container() { - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.MinFlexFix, true); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.MinFlexFix, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.FlexStart; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexDirection = YogaFlexDirection.Row; root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.FlexGrow = 1; root_child0_child0.FlexBasis = 0; root_child0.Insert(0, root_child0_child0); @@ -459,23 +473,23 @@ namespace Facebook.Yoga Assert.AreEqual(0f, root_child0_child0.LayoutY); Assert.AreEqual(0f, root_child0_child0.LayoutWidth); Assert.AreEqual(0f, root_child0_child0.LayoutHeight); - - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.MinFlexFix, false); } [Test] public void Test_flex_grow_within_max_width() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 200; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexDirection = YogaFlexDirection.Row; root_child0.MaxWidth = 100; root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.FlexGrow = 1; root_child0_child0.Height = 20; root_child0.Insert(0, root_child0_child0); @@ -519,16 +533,18 @@ namespace Facebook.Yoga [Test] public void Test_flex_grow_within_constrained_max_width() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 200; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexDirection = YogaFlexDirection.Row; root_child0.MaxWidth = 300; root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.FlexGrow = 1; root_child0_child0.Height = 20; root_child0.Insert(0, root_child0_child0); @@ -572,16 +588,18 @@ namespace Facebook.Yoga [Test] public void Test_flex_grow_within_constrained_min_row() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.MinWidth = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Width = 50; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -624,14 +642,16 @@ namespace Facebook.Yoga [Test] public void Test_flex_grow_within_constrained_min_column() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.MinHeight = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Height = 50; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -674,21 +694,23 @@ namespace Facebook.Yoga [Test] public void Test_flex_grow_within_constrained_max_row() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexDirection = YogaFlexDirection.Row; root_child0.MaxWidth = 100; root_child0.Height = 100; root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.FlexShrink = 1; root_child0_child0.FlexBasis = 100; root_child0.Insert(0, root_child0_child0); - YogaNode root_child0_child1 = new YogaNode(); + YogaNode root_child0_child1 = new YogaNode(config); root_child0_child1.Width = 50; root_child0.Insert(1, root_child0_child1); root.StyleDirection = YogaDirection.LTR; @@ -741,16 +763,18 @@ namespace Facebook.Yoga [Test] public void Test_flex_grow_within_constrained_max_column() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.MaxHeight = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexShrink = 1; root_child0.FlexBasis = 100; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.Height = 50; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -793,7 +817,9 @@ namespace Facebook.Yoga [Test] public void Test_min_width_overrides_width() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 50; root.MinWidth = 100; root.StyleDirection = YogaDirection.LTR; @@ -816,7 +842,9 @@ namespace Facebook.Yoga [Test] public void Test_max_width_overrides_width() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 200; root.MaxWidth = 100; root.StyleDirection = YogaDirection.LTR; @@ -839,7 +867,9 @@ namespace Facebook.Yoga [Test] public void Test_min_height_overrides_height() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Height = 50; root.MinHeight = 100; root.StyleDirection = YogaDirection.LTR; @@ -862,7 +892,9 @@ namespace Facebook.Yoga [Test] public void Test_max_height_overrides_height() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Height = 200; root.MaxHeight = 100; root.StyleDirection = YogaDirection.LTR; @@ -885,12 +917,14 @@ namespace Facebook.Yoga [Test] public void Test_min_max_percent_no_width_height() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.AlignItems = YogaAlign.FlexStart; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.MinWidth = 10.Percent(); root_child0.MaxWidth = 10.Percent(); root_child0.MinHeight = 10.Percent(); diff --git a/csharp/tests/Facebook.Yoga/YGPaddingTest.cs b/csharp/tests/Facebook.Yoga/YGPaddingTest.cs index 004b0d68..dd6402f5 100644 --- a/csharp/tests/Facebook.Yoga/YGPaddingTest.cs +++ b/csharp/tests/Facebook.Yoga/YGPaddingTest.cs @@ -20,7 +20,9 @@ namespace Facebook.Yoga [Test] public void Test_padding_no_size() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.PaddingLeft = 10; root.PaddingTop = 10; root.PaddingRight = 10; @@ -45,13 +47,15 @@ namespace Facebook.Yoga [Test] public void Test_padding_container_match_child() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.PaddingLeft = 10; root.PaddingTop = 10; root.PaddingRight = 10; root.PaddingBottom = 10; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 10; root_child0.Height = 10; root.Insert(0, root_child0); @@ -85,7 +89,9 @@ namespace Facebook.Yoga [Test] public void Test_padding_flex_child() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.PaddingLeft = 10; root.PaddingTop = 10; root.PaddingRight = 10; @@ -93,7 +99,7 @@ namespace Facebook.Yoga root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.Width = 10; root.Insert(0, root_child0); @@ -127,7 +133,9 @@ namespace Facebook.Yoga [Test] public void Test_padding_stretch_child() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.PaddingLeft = 10; root.PaddingTop = 10; root.PaddingRight = 10; @@ -135,7 +143,7 @@ namespace Facebook.Yoga root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; @@ -168,7 +176,9 @@ namespace Facebook.Yoga [Test] public void Test_padding_center_child() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.Center; root.AlignItems = YogaAlign.Center; root.PaddingStart = 10; @@ -177,7 +187,7 @@ namespace Facebook.Yoga root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 10; root_child0.Height = 10; root.Insert(0, root_child0); @@ -211,13 +221,15 @@ namespace Facebook.Yoga [Test] public void Test_child_with_padding_align_end() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.FlexEnd; root.AlignItems = YogaAlign.FlexEnd; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.PaddingLeft = 20; root_child0.PaddingTop = 20; root_child0.PaddingRight = 20; diff --git a/csharp/tests/Facebook.Yoga/YGPercentageTest.cs b/csharp/tests/Facebook.Yoga/YGPercentageTest.cs index d35427e1..8c176f49 100644 --- a/csharp/tests/Facebook.Yoga/YGPercentageTest.cs +++ b/csharp/tests/Facebook.Yoga/YGPercentageTest.cs @@ -20,14 +20,15 @@ namespace Facebook.Yoga [Test] public void Test_percentage_width_height() { - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 30.Percent(); root_child0.Height = 30.Percent(); root.Insert(0, root_child0); @@ -56,21 +57,20 @@ namespace Facebook.Yoga 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); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 400; root.Height = 400; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Left = 10.Percent(); root_child0.Top = 20.Percent(); root_child0.Width = 45.Percent(); @@ -101,21 +101,20 @@ namespace Facebook.Yoga 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); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 500; root.Height = 500; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Right = 20.Percent(); root_child0.Bottom = 10.Percent(); root_child0.Width = 55.Percent(); @@ -146,26 +145,25 @@ namespace Facebook.Yoga 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); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexBasis = 50.Percent(); root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root_child1.FlexBasis = 25.Percent(); root.Insert(1, root_child1); @@ -204,25 +202,24 @@ namespace Facebook.Yoga 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); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexBasis = 50.Percent(); root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root_child1.FlexBasis = 25.Percent(); root.Insert(1, root_child1); @@ -261,25 +258,24 @@ namespace Facebook.Yoga 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); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.MinHeight = 60.Percent(); root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 2; root_child1.MinHeight = 10.Percent(); root.Insert(1, root_child1); @@ -318,27 +314,26 @@ namespace Facebook.Yoga 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); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexBasis = 10.Percent(); root_child0.MaxHeight = 60.Percent(); root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 4; root_child1.FlexBasis = 10.Percent(); root_child1.MaxHeight = 20.Percent(); @@ -378,26 +373,25 @@ namespace Facebook.Yoga 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); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexBasis = 10.Percent(); root_child0.MaxHeight = 60.Percent(); root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 4; root_child1.FlexBasis = 10.Percent(); root_child1.MaxHeight = 20.Percent(); @@ -437,27 +431,26 @@ namespace Facebook.Yoga 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); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexBasis = 15.Percent(); root_child0.MaxWidth = 60.Percent(); root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 4; root_child1.FlexBasis = 10.Percent(); root_child1.MaxWidth = 20.Percent(); @@ -497,26 +490,25 @@ namespace Facebook.Yoga 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); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexBasis = 10.Percent(); root_child0.MaxWidth = 60.Percent(); root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 4; root_child1.FlexBasis = 15.Percent(); root_child1.MaxWidth = 20.Percent(); @@ -556,27 +548,26 @@ namespace Facebook.Yoga 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); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexBasis = 15.Percent(); root_child0.MinWidth = 60.Percent(); root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 4; root_child1.FlexBasis = 10.Percent(); root_child1.MinWidth = 20.Percent(); @@ -616,26 +607,25 @@ namespace Facebook.Yoga 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); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexBasis = 10.Percent(); root_child0.MinWidth = 60.Percent(); root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 4; root_child1.FlexBasis = 15.Percent(); root_child1.MinWidth = 20.Percent(); @@ -675,20 +665,19 @@ namespace Facebook.Yoga 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); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.Width = 200; root.Height = 200; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexBasis = 10.Percent(); root_child0.MarginLeft = 5; @@ -702,7 +691,7 @@ namespace Facebook.Yoga root_child0.MinWidth = 60.Percent(); root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.MarginLeft = 5; root_child0_child0.MarginTop = 5; root_child0_child0.MarginRight = 5; @@ -714,7 +703,7 @@ namespace Facebook.Yoga root_child0_child0.Width = 50.Percent(); root_child0.Insert(0, root_child0_child0); - YogaNode root_child0_child0_child0 = new YogaNode(); + YogaNode root_child0_child0_child0 = new YogaNode(config); root_child0_child0_child0.MarginLeft = 5.Percent(); root_child0_child0_child0.MarginTop = 5.Percent(); root_child0_child0_child0.MarginRight = 5.Percent(); @@ -726,7 +715,7 @@ namespace Facebook.Yoga root_child0_child0_child0.Width = 45.Percent(); root_child0_child0.Insert(0, root_child0_child0_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 4; root_child1.FlexBasis = 15.Percent(); root_child1.MinWidth = 20.Percent(); @@ -786,20 +775,19 @@ namespace Facebook.Yoga 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); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.Width = 200; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.MarginLeft = 10.Percent(); root_child0.MarginTop = 10.Percent(); @@ -807,7 +795,7 @@ namespace Facebook.Yoga root_child0.MarginBottom = 10.Percent(); root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.Width = 10; root_child0_child0.Height = 10; root_child0.Insert(0, root_child0_child0); @@ -846,20 +834,19 @@ namespace Facebook.Yoga 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); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.Width = 200; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.PaddingLeft = 10.Percent(); root_child0.PaddingTop = 10.Percent(); @@ -867,7 +854,7 @@ namespace Facebook.Yoga root_child0.PaddingBottom = 10.Percent(); root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.Width = 10; root_child0_child0.Height = 10; root_child0.Insert(0, root_child0_child0); @@ -906,20 +893,19 @@ namespace Facebook.Yoga 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); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.Width = 200; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; root_child0.Left = 30.Percent(); root_child0.Top = 10.Percent(); @@ -951,16 +937,16 @@ namespace Facebook.Yoga Assert.AreEqual(10f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_percentage_width_height_undefined_parent_size() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); - YogaNode root_child0 = new YogaNode(); + YogaNode root = new YogaNode(config); + + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 50.Percent(); root_child0.Height = 50.Percent(); root.Insert(0, root_child0); @@ -994,24 +980,26 @@ namespace Facebook.Yoga [Test] public void Test_percent_within_flex_grow() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 350; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 100; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root.Insert(1, root_child1); - YogaNode root_child1_child0 = new YogaNode(); + YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.Width = 100.Percent(); root_child1.Insert(0, root_child1_child0); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.Width = 100; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; diff --git a/csharp/tests/Facebook.Yoga/YGRoundingTest.cs b/csharp/tests/Facebook.Yoga/YGRoundingTest.cs index c37e6a22..f1a60944 100644 --- a/csharp/tests/Facebook.Yoga/YGRoundingTest.cs +++ b/csharp/tests/Facebook.Yoga/YGRoundingTest.cs @@ -20,22 +20,23 @@ namespace Facebook.Yoga [Test] public void Test_rounding_flex_basis_flex_grow_row_width_of_100() { - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.FlexGrow = 1; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -83,37 +84,36 @@ namespace Facebook.Yoga Assert.AreEqual(0f, root_child2.LayoutY); Assert.AreEqual(33f, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutHeight); - - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_flex_basis_flex_grow_row_prime_number_width() { - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 113; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.FlexGrow = 1; root.Insert(2, root_child2); - YogaNode root_child3 = new YogaNode(); + YogaNode root_child3 = new YogaNode(config); root_child3.FlexGrow = 1; root.Insert(3, root_child3); - YogaNode root_child4 = new YogaNode(); + YogaNode root_child4 = new YogaNode(config); root_child4.FlexGrow = 1; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; @@ -181,30 +181,29 @@ namespace Facebook.Yoga Assert.AreEqual(0f, root_child4.LayoutY); Assert.AreEqual(23f, root_child4.LayoutWidth); Assert.AreEqual(100f, root_child4.LayoutHeight); - - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_flex_basis_flex_shrink_row() { - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.FlexDirection = YogaFlexDirection.Row; root.Width = 101; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexShrink = 1; root_child0.FlexBasis = 100; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexBasis = 25; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.FlexBasis = 25; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -252,31 +251,30 @@ namespace Facebook.Yoga Assert.AreEqual(0f, root_child2.LayoutY); Assert.AreEqual(25f, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutHeight); - - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_flex_basis_overrides_main_size() { - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 113; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexBasis = 50; root_child0.Height = 20; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.FlexGrow = 1; root_child2.Height = 10; root.Insert(2, root_child2); @@ -325,31 +323,30 @@ namespace Facebook.Yoga Assert.AreEqual(89f, root_child2.LayoutY); Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_total_fractial() { - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.Width = 87.4f; root.Height = 113.4f; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 0.7f; root_child0.FlexBasis = 50.3f; root_child0.Height = 20.3f; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1.6f; root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.FlexGrow = 1.1f; root_child2.Height = 10.7f; root.Insert(2, root_child2); @@ -398,45 +395,44 @@ namespace Facebook.Yoga Assert.AreEqual(89f, root_child2.LayoutY); Assert.AreEqual(87f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_total_fractial_nested() { - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.Width = 87.4f; root.Height = 113.4f; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 0.7f; root_child0.FlexBasis = 50.3f; root_child0.Height = 20.3f; root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.FlexGrow = 1; root_child0_child0.FlexBasis = 0.3f; root_child0_child0.Bottom = 13.3f; root_child0_child0.Height = 9.9f; root_child0.Insert(0, root_child0_child0); - YogaNode root_child0_child1 = new YogaNode(); + YogaNode root_child0_child1 = new YogaNode(config); root_child0_child1.FlexGrow = 4; root_child0_child1.FlexBasis = 0.3f; root_child0_child1.Top = 13.3f; root_child0_child1.Height = 1.1f; root_child0.Insert(1, root_child0_child1); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1.6f; root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.FlexGrow = 1.1f; root_child2.Height = 10.7f; root.Insert(2, root_child2); @@ -505,31 +501,30 @@ namespace Facebook.Yoga Assert.AreEqual(89f, root_child2.LayoutY); Assert.AreEqual(87f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_fractial_input_1() { - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 113.4f; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexBasis = 50; root_child0.Height = 20; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.FlexGrow = 1; root_child2.Height = 10; root.Insert(2, root_child2); @@ -578,31 +573,30 @@ namespace Facebook.Yoga Assert.AreEqual(89f, root_child2.LayoutY); Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_fractial_input_2() { - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 113.6f; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexBasis = 50; root_child0.Height = 20; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.FlexGrow = 1; root_child2.Height = 10; root.Insert(2, root_child2); @@ -651,32 +645,31 @@ namespace Facebook.Yoga Assert.AreEqual(89f, root_child2.LayoutY); Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(25f, root_child2.LayoutHeight); - - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_fractial_input_3() { - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.Top = 0.3f; root.Width = 100; root.Height = 113.4f; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexBasis = 50; root_child0.Height = 20; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.FlexGrow = 1; root_child2.Height = 10; root.Insert(2, root_child2); @@ -725,32 +718,31 @@ namespace Facebook.Yoga Assert.AreEqual(89f, root_child2.LayoutY); Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_fractial_input_4() { - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaConfig config = new YogaConfig(); + config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - YogaNode root = new YogaNode(); + YogaNode root = new YogaNode(config); root.Top = 0.7f; root.Width = 100; root.Height = 113.4f; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; root_child0.FlexBasis = 50; root_child0.Height = 20; root.Insert(0, root_child0); - YogaNode root_child1 = new YogaNode(); + YogaNode root_child1 = new YogaNode(config); root_child1.FlexGrow = 1; root_child1.Height = 10; root.Insert(1, root_child1); - YogaNode root_child2 = new YogaNode(); + YogaNode root_child2 = new YogaNode(config); root_child2.FlexGrow = 1; root_child2.Height = 10; root.Insert(2, root_child2); @@ -799,8 +791,6 @@ namespace Facebook.Yoga Assert.AreEqual(89f, root_child2.LayoutY); Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - - YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } } diff --git a/csharp/tests/Facebook.Yoga/YGSizeOverflowTest.cs b/csharp/tests/Facebook.Yoga/YGSizeOverflowTest.cs index dc666fc3..36702089 100644 --- a/csharp/tests/Facebook.Yoga/YGSizeOverflowTest.cs +++ b/csharp/tests/Facebook.Yoga/YGSizeOverflowTest.cs @@ -20,14 +20,16 @@ namespace Facebook.Yoga [Test] public void Test_nested_overflowing_child() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.Width = 200; root_child0_child0.Height = 200; root_child0.Insert(0, root_child0_child0); @@ -71,16 +73,18 @@ namespace Facebook.Yoga [Test] public void Test_nested_overflowing_child_in_constraint_parent() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 100; root_child0.Height = 100; root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.Width = 200; root_child0_child0.Height = 200; root_child0.Insert(0, root_child0_child0); @@ -124,15 +128,17 @@ namespace Facebook.Yoga [Test] public void Test_parent_wrap_child_size_overflowing_parent() { - YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); root.Width = 100; root.Height = 100; - YogaNode root_child0 = new YogaNode(); + YogaNode root_child0 = new YogaNode(config); root_child0.Width = 100; root.Insert(0, root_child0); - YogaNode root_child0_child0 = new YogaNode(); + YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.Width = 100; root_child0_child0.Height = 200; root_child0.Insert(0, root_child0_child0); diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js index 0622c8a4..459681b8 100644 --- a/gentest/gentest-cpp.js +++ b/gentest/gentest-cpp.js @@ -40,16 +40,15 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { this.push('TEST(YogaTest, ' + name + ') {'); this.pushIndent(); - if (experiments.length > 0) { - for (var i in experiments) { - this.push('YGSetExperimentalFeatureEnabled(YGExperimentalFeature' + experiments[i] +', true);'); - } - this.push(''); + this.push('const YGConfigRef config = YGConfigNew();') + for (var i in experiments) { + this.push('YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeature' + experiments[i] +', true);'); } + this.push(''); }}, emitTestTreePrologue:{value:function(nodeName) { - this.push('const YGNodeRef ' + nodeName + ' = YGNodeNew();'); + this.push('const YGNodeRef ' + nodeName + ' = YGNodeNewWithConfig(config);'); }}, emitTestEpilogue:{value:function(experiments) { @@ -58,12 +57,8 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { 'YGNodeFreeRecursive(root);', ]); - if (experiments.length > 0) { - this.push(''); - for (var i in experiments) { - this.push('YGSetExperimentalFeatureEnabled(YGExperimentalFeature' + experiments[i] +', false);'); - } - } + this.push(''); + this.push('YGConfigFree(config);') this.popIndent(); this.push([ @@ -127,7 +122,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { YGAuto:{value:'YGAuto'}, - YGNodeCalculateLayout:{value:function(node, dir) { + YGNodeCalculateLayout:{value:function(node, dir, experiments) { this.push('YGNodeCalculateLayout(' + node + ', YGUndefined, YGUndefined, ' + dir + ');'); }}, diff --git a/gentest/gentest-cs.js b/gentest/gentest-cs.js index 57a20211..0bfe5cdc 100644 --- a/gentest/gentest-cs.js +++ b/gentest/gentest-cs.js @@ -53,25 +53,18 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { this.push('{'); this.pushIndent(); - if (experiments.length > 0) { - for (var i in experiments) { - this.push('YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.' + experiments[i] +', true);'); - } - this.push(''); + this.push('YogaConfig config = new YogaConfig();') + for (var i in experiments) { + this.push('config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.' + experiments[i] +', true);'); } + this.push(''); }}, emitTestTreePrologue:{value:function(nodeName) { - this.push('YogaNode ' + nodeName + ' = new YogaNode();'); + this.push('YogaNode ' + nodeName + ' = new YogaNode(config);'); }}, emitTestEpilogue:{value:function(experiments) { - if (experiments.length > 0) { - this.push(''); - for (var i in experiments) { - this.push('YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.' + experiments[i] +', false);'); - } - } this.popIndent(); this.push([ @@ -142,7 +135,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { YGWrapWrap:{value:'YogaWrap.Wrap'}, YGWrapWrapReverse:{value: 'YogaWrap.WrapReverse'}, - YGNodeCalculateLayout:{value:function(node, dir) { + YGNodeCalculateLayout:{value:function(node, dir, experiments) { this.push(node + '.StyleDirection = ' + dir + ';'); this.push(node + '.CalculateLayout();'); }}, diff --git a/gentest/gentest-java.js b/gentest/gentest-java.js index 69fb7bb9..26a02bc5 100644 --- a/gentest/gentest-java.js +++ b/gentest/gentest-java.js @@ -58,26 +58,18 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { this.push('public void test_' + name + '() {'); this.pushIndent(); - if (experiments.length > 0) { - for (var i in experiments) { - this.push('YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.' + toJavaUpper(experiments[i]) +', true);'); - } - this.push(''); + this.push("YogaConfig config = new YogaConfig();") + for (var i in experiments) { + this.push('config.setExperimentalFeatureEnabled(YogaExperimentalFeature.' + toJavaUpper(experiments[i]) +', true);'); } + this.push(''); }}, emitTestTreePrologue:{value:function(nodeName) { - this.push('final YogaNode ' + nodeName + ' = new YogaNode();'); + this.push('final YogaNode ' + nodeName + ' = new YogaNode(config);'); }}, emitTestEpilogue:{value:function(experiments) { - if (experiments.length > 0) { - this.push(''); - for (var i in experiments) { - this.push('YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.' + toJavaUpper(experiments[i]) +', false);'); - } - } - this.popIndent(); this.push([ '}', @@ -145,7 +137,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { YGWrapWrap:{value:'YogaWrap.WRAP'}, YGWrapWrapReverse:{value: 'YogaWrap.WRAP_REVERSE'}, - YGNodeCalculateLayout:{value:function(node, dir) { + YGNodeCalculateLayout:{value:function(node, dir, experiments) { this.push(node + '.setDirection(' + dir + ');'); this.push(node + '.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);'); }}, diff --git a/gentest/gentest-javascript.js b/gentest/gentest-javascript.js index 7e8dbf25..497fdb04 100644 --- a/gentest/gentest-javascript.js +++ b/gentest/gentest-javascript.js @@ -56,7 +56,7 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, { }}, emitTestTreePrologue:{value:function(nodeName) { - this.push('var ' + nodeName + ' = Yoga.Node.create();'); + this.push('var ' + nodeName + ' = Yoga.Node.create(config);'); }}, emitTestEpilogue:{value:function(experiments) { @@ -140,7 +140,7 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, { YGDisplayFlex:{value:'Yoga.DISPLAY_FLEX'}, YGDisplayNone:{value:'Yoga.DISPLAY_NONE'}, - YGNodeCalculateLayout:{value:function(node, dir) { + YGNodeCalculateLayout:{value:function(node, dir, experiments) { this.push(node + '.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, ' + dir + ');'); }}, diff --git a/gentest/gentest.js b/gentest/gentest.js index a26cd7cd..b5759630 100755 --- a/gentest/gentest.js +++ b/gentest/gentest.js @@ -93,13 +93,13 @@ function printTest(e, LTRContainer, RTLContainer, genericContainer) { 'root', null); - e.YGNodeCalculateLayout('root', e.YGDirectionLTR); + e.YGNodeCalculateLayout('root', e.YGDirectionLTR, genericLayoutTree[i].experiments); e.push(''); assertTestTree(e, LTRLayoutTree[i], 'root', null); e.push(''); - e.YGNodeCalculateLayout('root', e.YGDirectionRTL); + e.YGNodeCalculateLayout('root', e.YGDirectionRTL, genericLayoutTree[i].experiments); e.push(''); assertTestTree(e, RTLLayoutTree[i], 'root', null); diff --git a/java/com/facebook/yoga/YogaConfig.java b/java/com/facebook/yoga/YogaConfig.java new file mode 100644 index 00000000..716a212e --- /dev/null +++ b/java/com/facebook/yoga/YogaConfig.java @@ -0,0 +1,49 @@ +/** + * 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. + */ + +package com.facebook.yoga; + +import com.facebook.proguard.annotations.DoNotStrip; +import com.facebook.soloader.SoLoader; + +@DoNotStrip +public class YogaConfig { + + static { + SoLoader.loadLibrary("yoga"); + } + + long mNativePointer; + + private native long jni_YGConfigNew(); + public YogaConfig() { + mNativePointer = jni_YGConfigNew(); + if (mNativePointer == 0) { + throw new IllegalStateException("Failed to allocate native memory"); + } + } + + private native void jni_YGConfigFree(long nativePointer); + @Override + protected void finalize() throws Throwable { + try { + jni_YGConfigFree(mNativePointer); + } finally { + super.finalize(); + } + } + + private native void jni_YGConfigSetExperimentalFeatureEnabled( + long nativePointer, + int feature, + boolean enabled); + public void setExperimentalFeatureEnabled(YogaExperimentalFeature feature, boolean enabled) { + jni_YGConfigSetExperimentalFeatureEnabled(mNativePointer, feature.intValue(), enabled); + } +} diff --git a/java/com/facebook/yoga/YogaNode.java b/java/com/facebook/yoga/YogaNode.java index 94f16a99..3772c4f1 100644 --- a/java/com/facebook/yoga/YogaNode.java +++ b/java/com/facebook/yoga/YogaNode.java @@ -35,20 +35,6 @@ public class YogaNode implements YogaNodeAPI { jni_YGSetLogger(logger); } - private static native void jni_YGSetExperimentalFeatureEnabled( - int feature, - boolean enabled); - public static void setExperimentalFeatureEnabled( - YogaExperimentalFeature feature, - boolean enabled) { - jni_YGSetExperimentalFeatureEnabled(feature.intValue(), enabled); - } - - private static native boolean jni_YGIsExperimentalFeatureEnabled(int feature); - public static boolean isExperimentalFeatureEnabled(YogaExperimentalFeature feature) { - return jni_YGIsExperimentalFeatureEnabled(feature.intValue()); - } - private YogaNode mParent; private List mChildren; private YogaMeasureFunction mMeasureFunction; @@ -104,6 +90,14 @@ public class YogaNode implements YogaNodeAPI { } } + private native long jni_YGNodeNewWithConfig(long configPointer); + public YogaNode(YogaConfig config) { + mNativePointer = jni_YGNodeNewWithConfig(config.mNativePointer); + if (mNativePointer == 0) { + throw new IllegalStateException("Failed to allocate native memory"); + } + } + private native void jni_YGNodeFree(long nativePointer); @Override protected void finalize() throws Throwable { diff --git a/java/jni/YGJNI.cpp b/java/jni/YGJNI.cpp index 15f6d46f..72e704c8 100644 --- a/java/jni/YGJNI.cpp +++ b/java/jni/YGJNI.cpp @@ -150,6 +150,10 @@ static inline YGNodeRef _jlong2YGNodeRef(jlong addr) { return reinterpret_cast(static_cast(addr)); } +static inline YGConfigRef _jlong2YGConfigRef(jlong addr) { + return reinterpret_cast(static_cast(addr)); +} + void jni_YGSetLogger(alias_ref clazz, alias_ref logger) { if (jLogger) { jLogger->releaseAlias(); @@ -171,18 +175,6 @@ void jni_YGLog(alias_ref clazz, jint level, jstring message) { Environment::current()->ReleaseStringUTFChars(message, nMessage); } -void jni_YGSetExperimentalFeatureEnabled(alias_ref clazz, jint feature, jboolean enabled) { - YGSetExperimentalFeatureEnabled(static_cast(feature), enabled); -} - -jboolean jni_YGIsExperimentalFeatureEnabled(alias_ref clazz, jint feature) { - return YGIsExperimentalFeatureEnabled(static_cast(feature)); -} - -jint jni_YGNodeGetInstanceCount(alias_ref clazz) { - return YGNodeGetInstanceCount(); -} - jlong jni_YGNodeNew(alias_ref thiz) { const YGNodeRef node = YGNodeNew(); YGNodeSetContext(node, new weak_ref(make_weak(thiz))); @@ -190,6 +182,13 @@ jlong jni_YGNodeNew(alias_ref thiz) { return reinterpret_cast(node); } +jlong jni_YGNodeNewWithConfig(alias_ref thiz, jlong configPointer) { + const YGNodeRef node = YGNodeNewWithConfig(_jlong2YGConfigRef(configPointer)); + YGNodeSetContext(node, new weak_ref(make_weak(thiz))); + YGNodeSetPrintFunc(node, YGPrint); + return reinterpret_cast(node); +} + void jni_YGNodeFree(alias_ref thiz, jlong nativePointer) { const YGNodeRef node = _jlong2YGNodeRef(nativePointer); delete YGNodeJobject(node); @@ -368,6 +367,24 @@ YG_NODE_JNI_STYLE_UNIT_PROP(MaxHeight); // Yoga specific properties, not compatible with flexbox specification YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio); +jlong jni_YGConfigNew(alias_ref) { + return reinterpret_cast(YGConfigNew()); +} + +void jni_YGConfigFree(alias_ref, jlong nativePointer) { + const YGConfigRef config = _jlong2YGConfigRef(nativePointer); + YGConfigFree(config); +} + +void jni_YGConfigSetExperimentalFeatureEnabled(alias_ref, jlong nativePointer, jint feature, jboolean enabled) { + const YGConfigRef config = _jlong2YGConfigRef(nativePointer); + YGConfigSetExperimentalFeatureEnabled(config, static_cast(feature), enabled); +} + +jint jni_YGNodeGetInstanceCount(alias_ref clazz) { + return YGNodeGetInstanceCount(); +} + #define YGMakeNativeMethod(name) makeNativeMethod(#name, name) jint JNI_OnLoad(JavaVM *vm, void *) { @@ -375,6 +392,7 @@ jint JNI_OnLoad(JavaVM *vm, void *) { registerNatives("com/facebook/yoga/YogaNode", { YGMakeNativeMethod(jni_YGNodeNew), + YGMakeNativeMethod(jni_YGNodeNewWithConfig), YGMakeNativeMethod(jni_YGNodeFree), YGMakeNativeMethod(jni_YGNodeReset), YGMakeNativeMethod(jni_YGNodeInsertChild), @@ -452,8 +470,12 @@ jint JNI_OnLoad(JavaVM *vm, void *) { YGMakeNativeMethod(jni_YGNodeGetInstanceCount), YGMakeNativeMethod(jni_YGSetLogger), YGMakeNativeMethod(jni_YGLog), - YGMakeNativeMethod(jni_YGSetExperimentalFeatureEnabled), - YGMakeNativeMethod(jni_YGIsExperimentalFeatureEnabled), + }); + registerNatives("com/facebook/yoga/YogaConfig", + { + YGMakeNativeMethod(jni_YGConfigNew), + YGMakeNativeMethod(jni_YGConfigFree), + YGMakeNativeMethod(jni_YGConfigSetExperimentalFeatureEnabled), }); }); } diff --git a/java/tests/com/facebook/yoga/YGAbsolutePositionTest.java b/java/tests/com/facebook/yoga/YGAbsolutePositionTest.java index 8d1d1977..ca9978e3 100644 --- a/java/tests/com/facebook/yoga/YGAbsolutePositionTest.java +++ b/java/tests/com/facebook/yoga/YGAbsolutePositionTest.java @@ -18,11 +18,13 @@ import static org.junit.Assert.assertEquals; public class YGAbsolutePositionTest { @Test public void test_absolute_layout_width_height_start_top() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setPosition(YogaEdge.START, 10f); root_child0.setPosition(YogaEdge.TOP, 10f); @@ -58,11 +60,13 @@ public class YGAbsolutePositionTest { @Test public void test_absolute_layout_width_height_end_bottom() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setPosition(YogaEdge.END, 10f); root_child0.setPosition(YogaEdge.BOTTOM, 10f); @@ -98,11 +102,13 @@ public class YGAbsolutePositionTest { @Test public void test_absolute_layout_start_top_end_bottom() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setPosition(YogaEdge.START, 10f); root_child0.setPosition(YogaEdge.TOP, 10f); @@ -138,11 +144,13 @@ public class YGAbsolutePositionTest { @Test public void test_absolute_layout_width_height_start_top_end_bottom() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setPosition(YogaEdge.START, 10f); root_child0.setPosition(YogaEdge.TOP, 10f); @@ -180,19 +188,21 @@ public class YGAbsolutePositionTest { @Test public void test_do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setOverflow(YogaOverflow.HIDDEN); root.setWidth(50f); root.setHeight(50f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setPosition(YogaEdge.START, 0f); root_child0.setPosition(YogaEdge.TOP, 0f); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setWidth(100f); root_child0_child0.setHeight(100f); root_child0.addChildAt(root_child0_child0, 0); @@ -235,7 +245,9 @@ public class YGAbsolutePositionTest { @Test public void test_absolute_layout_within_border() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setMargin(YogaEdge.LEFT, 10f); root.setMargin(YogaEdge.TOP, 10f); root.setMargin(YogaEdge.RIGHT, 10f); @@ -251,7 +263,7 @@ public class YGAbsolutePositionTest { root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setPosition(YogaEdge.LEFT, 0f); root_child0.setPosition(YogaEdge.TOP, 0f); @@ -259,7 +271,7 @@ public class YGAbsolutePositionTest { root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setPositionType(YogaPositionType.ABSOLUTE); root_child1.setPosition(YogaEdge.RIGHT, 0f); root_child1.setPosition(YogaEdge.BOTTOM, 0f); @@ -305,14 +317,16 @@ public class YGAbsolutePositionTest { @Test public void test_absolute_layout_align_items_and_justify_content_center() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setJustifyContent(YogaJustify.CENTER); root.setAlignItems(YogaAlign.CENTER); root.setFlexGrow(1f); root.setWidth(110f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setWidth(60f); root_child0.setHeight(40f); @@ -346,14 +360,16 @@ public class YGAbsolutePositionTest { @Test public void test_absolute_layout_align_items_and_justify_content_flex_end() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setJustifyContent(YogaJustify.FLEX_END); root.setAlignItems(YogaAlign.FLEX_END); root.setFlexGrow(1f); root.setWidth(110f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setWidth(60f); root_child0.setHeight(40f); @@ -387,13 +403,15 @@ public class YGAbsolutePositionTest { @Test public void test_absolute_layout_justify_content_center() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setJustifyContent(YogaJustify.CENTER); root.setFlexGrow(1f); root.setWidth(110f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setWidth(60f); root_child0.setHeight(40f); @@ -427,13 +445,15 @@ public class YGAbsolutePositionTest { @Test public void test_absolute_layout_align_items_center() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.CENTER); root.setFlexGrow(1f); root.setWidth(110f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setWidth(60f); root_child0.setHeight(40f); @@ -467,12 +487,14 @@ public class YGAbsolutePositionTest { @Test public void test_absolute_layout_align_items_center_on_child_only() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexGrow(1f); root.setWidth(110f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setAlignSelf(YogaAlign.CENTER); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setWidth(60f); @@ -507,14 +529,16 @@ public class YGAbsolutePositionTest { @Test public void test_absolute_layout_align_items_and_justify_content_center_and_top_position() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setJustifyContent(YogaJustify.CENTER); root.setAlignItems(YogaAlign.CENTER); root.setFlexGrow(1f); root.setWidth(110f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setPosition(YogaEdge.TOP, 10f); root_child0.setWidth(60f); @@ -549,14 +573,16 @@ public class YGAbsolutePositionTest { @Test public void test_absolute_layout_align_items_and_justify_content_center_and_bottom_position() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setJustifyContent(YogaJustify.CENTER); root.setAlignItems(YogaAlign.CENTER); root.setFlexGrow(1f); root.setWidth(110f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setPosition(YogaEdge.BOTTOM, 10f); root_child0.setWidth(60f); @@ -591,14 +617,16 @@ public class YGAbsolutePositionTest { @Test public void test_absolute_layout_align_items_and_justify_content_center_and_left_position() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setJustifyContent(YogaJustify.CENTER); root.setAlignItems(YogaAlign.CENTER); root.setFlexGrow(1f); root.setWidth(110f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setPosition(YogaEdge.LEFT, 5f); root_child0.setWidth(60f); @@ -633,14 +661,16 @@ public class YGAbsolutePositionTest { @Test public void test_absolute_layout_align_items_and_justify_content_center_and_right_position() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setJustifyContent(YogaJustify.CENTER); root.setAlignItems(YogaAlign.CENTER); root.setFlexGrow(1f); root.setWidth(110f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setPosition(YogaEdge.RIGHT, 5f); root_child0.setWidth(60f); diff --git a/java/tests/com/facebook/yoga/YGAlignContentTest.java b/java/tests/com/facebook/yoga/YGAlignContentTest.java index 5b456f2d..17921c73 100644 --- a/java/tests/com/facebook/yoga/YGAlignContentTest.java +++ b/java/tests/com/facebook/yoga/YGAlignContentTest.java @@ -18,33 +18,35 @@ import static org.junit.Assert.assertEquals; public class YGAlignContentTest { @Test public void test_align_content_flex_start() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWrap(YogaWrap.WRAP); root.setWidth(130f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(50f); root_child3.setHeight(10f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(50f); root_child4.setHeight(10f); root.addChildAt(root_child4, 4); @@ -117,30 +119,32 @@ public class YGAlignContentTest { @Test public void test_align_content_flex_start_without_height_on_children() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(50f); root_child3.setHeight(10f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(50f); root.addChildAt(root_child4, 4); root.setDirection(YogaDirection.LTR); @@ -212,36 +216,38 @@ public class YGAlignContentTest { @Test public void test_align_content_flex_start_with_flex() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); root.setHeight(120f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexBasisPercent(0f); root_child0.setWidth(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root_child1.setFlexBasisPercent(0f); root_child1.setWidth(50f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setFlexGrow(1f); root_child3.setFlexShrink(1f); root_child3.setFlexBasisPercent(0f); root_child3.setWidth(50f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(50f); root.addChildAt(root_child4, 4); root.setDirection(YogaDirection.LTR); @@ -313,33 +319,35 @@ public class YGAlignContentTest { @Test public void test_align_content_flex_end() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignContent(YogaAlign.FLEX_END); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(50f); root_child3.setHeight(10f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(50f); root_child4.setHeight(10f); root.addChildAt(root_child4, 4); @@ -412,29 +420,31 @@ public class YGAlignContentTest { @Test public void test_align_content_stretch() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignContent(YogaAlign.STRETCH); root.setWrap(YogaWrap.WRAP); root.setWidth(150f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(50f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(50f); root.addChildAt(root_child4, 4); root.setDirection(YogaDirection.LTR); @@ -506,34 +516,36 @@ public class YGAlignContentTest { @Test public void test_align_content_spacebetween() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignContent(YogaAlign.SPACE_BETWEEN); root.setWrap(YogaWrap.WRAP); root.setWidth(130f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(50f); root_child3.setHeight(10f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(50f); root_child4.setHeight(10f); root.addChildAt(root_child4, 4); @@ -606,34 +618,36 @@ public class YGAlignContentTest { @Test public void test_align_content_spacearound() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignContent(YogaAlign.SPACE_AROUND); root.setWrap(YogaWrap.WRAP); root.setWidth(140f); root.setHeight(120f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(50f); root_child3.setHeight(10f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(50f); root_child4.setHeight(10f); root.addChildAt(root_child4, 4); @@ -706,30 +720,32 @@ public class YGAlignContentTest { @Test public void test_align_content_stretch_row() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignContent(YogaAlign.STRETCH); root.setWrap(YogaWrap.WRAP); root.setWidth(150f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(50f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(50f); root.addChildAt(root_child4, 4); root.setDirection(YogaDirection.LTR); @@ -801,36 +817,38 @@ public class YGAlignContentTest { @Test public void test_align_content_stretch_row_with_children() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignContent(YogaAlign.STRETCH); root.setWrap(YogaWrap.WRAP); root.setWidth(150f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setFlexGrow(1f); root_child0_child0.setFlexShrink(1f); root_child0_child0.setFlexBasisPercent(0f); root_child0.addChildAt(root_child0_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(50f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(50f); root.addChildAt(root_child4, 4); root.setDirection(YogaDirection.LTR); @@ -912,36 +930,38 @@ public class YGAlignContentTest { @Test public void test_align_content_stretch_row_with_flex() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignContent(YogaAlign.STRETCH); root.setWrap(YogaWrap.WRAP); root.setWidth(150f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root_child1.setFlexShrink(1f); root_child1.setFlexBasisPercent(0f); root_child1.setWidth(50f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setFlexGrow(1f); root_child3.setFlexShrink(1f); root_child3.setFlexBasisPercent(0f); root_child3.setWidth(50f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(50f); root.addChildAt(root_child4, 4); root.setDirection(YogaDirection.LTR); @@ -1013,35 +1033,37 @@ public class YGAlignContentTest { @Test public void test_align_content_stretch_row_with_flex_no_shrink() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignContent(YogaAlign.STRETCH); root.setWrap(YogaWrap.WRAP); root.setWidth(150f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root_child1.setFlexShrink(1f); root_child1.setFlexBasisPercent(0f); root_child1.setWidth(50f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setFlexGrow(1f); root_child3.setFlexBasisPercent(0f); root_child3.setWidth(50f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(50f); root.addChildAt(root_child4, 4); root.setDirection(YogaDirection.LTR); @@ -1113,18 +1135,20 @@ public class YGAlignContentTest { @Test public void test_align_content_stretch_row_with_margin() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignContent(YogaAlign.STRETCH); root.setWrap(YogaWrap.WRAP); root.setWidth(150f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setMargin(YogaEdge.LEFT, 10f); root_child1.setMargin(YogaEdge.TOP, 10f); root_child1.setMargin(YogaEdge.RIGHT, 10f); @@ -1132,11 +1156,11 @@ public class YGAlignContentTest { root_child1.setWidth(50f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setMargin(YogaEdge.LEFT, 10f); root_child3.setMargin(YogaEdge.TOP, 10f); root_child3.setMargin(YogaEdge.RIGHT, 10f); @@ -1144,7 +1168,7 @@ public class YGAlignContentTest { root_child3.setWidth(50f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(50f); root.addChildAt(root_child4, 4); root.setDirection(YogaDirection.LTR); @@ -1216,18 +1240,20 @@ public class YGAlignContentTest { @Test public void test_align_content_stretch_row_with_padding() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignContent(YogaAlign.STRETCH); root.setWrap(YogaWrap.WRAP); root.setWidth(150f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setPadding(YogaEdge.LEFT, 10); root_child1.setPadding(YogaEdge.TOP, 10); root_child1.setPadding(YogaEdge.RIGHT, 10); @@ -1235,11 +1261,11 @@ public class YGAlignContentTest { root_child1.setWidth(50f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setPadding(YogaEdge.LEFT, 10); root_child3.setPadding(YogaEdge.TOP, 10); root_child3.setPadding(YogaEdge.RIGHT, 10); @@ -1247,7 +1273,7 @@ public class YGAlignContentTest { root_child3.setWidth(50f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(50f); root.addChildAt(root_child4, 4); root.setDirection(YogaDirection.LTR); @@ -1319,18 +1345,20 @@ public class YGAlignContentTest { @Test public void test_align_content_stretch_row_with_single_row() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignContent(YogaAlign.STRETCH); root.setWrap(YogaWrap.WRAP); root.setWidth(150f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -1372,31 +1400,33 @@ public class YGAlignContentTest { @Test public void test_align_content_stretch_row_with_fixed_height() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignContent(YogaAlign.STRETCH); root.setWrap(YogaWrap.WRAP); root.setWidth(150f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(60f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(50f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(50f); root.addChildAt(root_child4, 4); root.setDirection(YogaDirection.LTR); @@ -1468,31 +1498,33 @@ public class YGAlignContentTest { @Test public void test_align_content_stretch_row_with_max_height() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignContent(YogaAlign.STRETCH); root.setWrap(YogaWrap.WRAP); root.setWidth(150f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setMaxHeight(20f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(50f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(50f); root.addChildAt(root_child4, 4); root.setDirection(YogaDirection.LTR); @@ -1564,31 +1596,33 @@ public class YGAlignContentTest { @Test public void test_align_content_stretch_row_with_min_height() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignContent(YogaAlign.STRETCH); root.setWrap(YogaWrap.WRAP); root.setWidth(150f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setMinHeight(80f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(50f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(50f); root.addChildAt(root_child4, 4); root.setDirection(YogaDirection.LTR); @@ -1660,38 +1694,40 @@ public class YGAlignContentTest { @Test public void test_align_content_stretch_column() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignContent(YogaAlign.STRETCH); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); root.setHeight(150f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setFlexGrow(1f); root_child0_child0.setFlexShrink(1f); root_child0_child0.setFlexBasisPercent(0f); root_child0.addChildAt(root_child0_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root_child1.setFlexShrink(1f); root_child1.setFlexBasisPercent(0f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setHeight(50f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setHeight(50f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setHeight(50f); root.addChildAt(root_child4, 4); root.setDirection(YogaDirection.LTR); @@ -1773,10 +1809,12 @@ public class YGAlignContentTest { @Test public void test_align_content_stretch_is_not_overriding_align_items() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignContent(YogaAlign.STRETCH); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexDirection(YogaFlexDirection.ROW); root_child0.setAlignContent(YogaAlign.STRETCH); root_child0.setAlignItems(YogaAlign.CENTER); @@ -1784,7 +1822,7 @@ public class YGAlignContentTest { root_child0.setHeight(100f); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setAlignContent(YogaAlign.STRETCH); root_child0_child0.setWidth(10f); root_child0_child0.setHeight(10f); diff --git a/java/tests/com/facebook/yoga/YGAlignItemsTest.java b/java/tests/com/facebook/yoga/YGAlignItemsTest.java index 76fe9f7f..0b9533fb 100644 --- a/java/tests/com/facebook/yoga/YGAlignItemsTest.java +++ b/java/tests/com/facebook/yoga/YGAlignItemsTest.java @@ -18,11 +18,13 @@ import static org.junit.Assert.assertEquals; public class YGAlignItemsTest { @Test public void test_align_items_stretch() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(YogaDirection.LTR); @@ -54,12 +56,14 @@ public class YGAlignItemsTest { @Test public void test_align_items_center() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.CENTER); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); @@ -92,12 +96,14 @@ public class YGAlignItemsTest { @Test public void test_align_items_flex_start() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.FLEX_START); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); @@ -130,12 +136,14 @@ public class YGAlignItemsTest { @Test public void test_align_items_flex_end() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.FLEX_END); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); @@ -168,18 +176,20 @@ public class YGAlignItemsTest { @Test public void test_align_baseline() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.BASELINE); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); @@ -222,23 +232,25 @@ public class YGAlignItemsTest { @Test public void test_align_baseline_child() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.BASELINE); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); - final YogaNode root_child1_child0 = new YogaNode(); + final YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.setWidth(50f); root_child1_child0.setHeight(10f); root_child1.addChildAt(root_child1_child0, 0); @@ -291,40 +303,42 @@ public class YGAlignItemsTest { @Test public void test_align_baseline_child_multiline() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.BASELINE); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(60f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexDirection(YogaFlexDirection.ROW); root_child1.setWrap(YogaWrap.WRAP); root_child1.setWidth(50f); root_child1.setHeight(25f); root.addChildAt(root_child1, 1); - final YogaNode root_child1_child0 = new YogaNode(); + final YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.setWidth(25f); root_child1_child0.setHeight(20f); root_child1.addChildAt(root_child1_child0, 0); - final YogaNode root_child1_child1 = new YogaNode(); + final YogaNode root_child1_child1 = new YogaNode(config); root_child1_child1.setWidth(25f); root_child1_child1.setHeight(10f); root_child1.addChildAt(root_child1_child1, 1); - final YogaNode root_child1_child2 = new YogaNode(); + final YogaNode root_child1_child2 = new YogaNode(config); root_child1_child2.setWidth(25f); root_child1_child2.setHeight(20f); root_child1.addChildAt(root_child1_child2, 2); - final YogaNode root_child1_child3 = new YogaNode(); + final YogaNode root_child1_child3 = new YogaNode(config); root_child1_child3.setWidth(25f); root_child1_child3.setHeight(10f); root_child1.addChildAt(root_child1_child3, 3); @@ -407,41 +421,43 @@ public class YGAlignItemsTest { @Test public void test_align_baseline_child_multiline_override() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.BASELINE); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(60f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexDirection(YogaFlexDirection.ROW); root_child1.setWrap(YogaWrap.WRAP); root_child1.setWidth(50f); root_child1.setHeight(25f); root.addChildAt(root_child1, 1); - final YogaNode root_child1_child0 = new YogaNode(); + final YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.setWidth(25f); root_child1_child0.setHeight(20f); root_child1.addChildAt(root_child1_child0, 0); - final YogaNode root_child1_child1 = new YogaNode(); + final YogaNode root_child1_child1 = new YogaNode(config); root_child1_child1.setAlignSelf(YogaAlign.BASELINE); root_child1_child1.setWidth(25f); root_child1_child1.setHeight(10f); root_child1.addChildAt(root_child1_child1, 1); - final YogaNode root_child1_child2 = new YogaNode(); + final YogaNode root_child1_child2 = new YogaNode(config); root_child1_child2.setWidth(25f); root_child1_child2.setHeight(20f); root_child1.addChildAt(root_child1_child2, 2); - final YogaNode root_child1_child3 = new YogaNode(); + final YogaNode root_child1_child3 = new YogaNode(config); root_child1_child3.setAlignSelf(YogaAlign.BASELINE); root_child1_child3.setWidth(25f); root_child1_child3.setHeight(10f); @@ -525,40 +541,42 @@ public class YGAlignItemsTest { @Test public void test_align_baseline_child_multiline_no_override_on_secondline() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.BASELINE); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(60f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexDirection(YogaFlexDirection.ROW); root_child1.setWrap(YogaWrap.WRAP); root_child1.setWidth(50f); root_child1.setHeight(25f); root.addChildAt(root_child1, 1); - final YogaNode root_child1_child0 = new YogaNode(); + final YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.setWidth(25f); root_child1_child0.setHeight(20f); root_child1.addChildAt(root_child1_child0, 0); - final YogaNode root_child1_child1 = new YogaNode(); + final YogaNode root_child1_child1 = new YogaNode(config); root_child1_child1.setWidth(25f); root_child1_child1.setHeight(10f); root_child1.addChildAt(root_child1_child1, 1); - final YogaNode root_child1_child2 = new YogaNode(); + final YogaNode root_child1_child2 = new YogaNode(config); root_child1_child2.setWidth(25f); root_child1_child2.setHeight(20f); root_child1.addChildAt(root_child1_child2, 2); - final YogaNode root_child1_child3 = new YogaNode(); + final YogaNode root_child1_child3 = new YogaNode(config); root_child1_child3.setAlignSelf(YogaAlign.BASELINE); root_child1_child3.setWidth(25f); root_child1_child3.setHeight(10f); @@ -642,24 +660,26 @@ public class YGAlignItemsTest { @Test public void test_align_baseline_child_top() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.BASELINE); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPosition(YogaEdge.TOP, 10f); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); - final YogaNode root_child1_child0 = new YogaNode(); + final YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.setWidth(50f); root_child1_child0.setHeight(10f); root_child1.addChildAt(root_child1_child0, 0); @@ -712,24 +732,26 @@ public class YGAlignItemsTest { @Test public void test_align_baseline_child_top2() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.BASELINE); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setPosition(YogaEdge.TOP, 5f); root_child1.setWidth(50f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); - final YogaNode root_child1_child0 = new YogaNode(); + final YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.setWidth(50f); root_child1_child0.setHeight(10f); root_child1.addChildAt(root_child1_child0, 0); @@ -782,28 +804,30 @@ public class YGAlignItemsTest { @Test public void test_align_baseline_double_nested_child() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.BASELINE); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setWidth(50f); root_child0_child0.setHeight(20f); root_child0.addChildAt(root_child0_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); - final YogaNode root_child1_child0 = new YogaNode(); + final YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.setWidth(50f); root_child1_child0.setHeight(15f); root_child1.addChildAt(root_child1_child0, 0); @@ -866,17 +890,19 @@ public class YGAlignItemsTest { @Test public void test_align_baseline_column() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.BASELINE); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); @@ -919,13 +945,15 @@ public class YGAlignItemsTest { @Test public void test_align_baseline_child_margin() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.BASELINE); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMargin(YogaEdge.LEFT, 5f); root_child0.setMargin(YogaEdge.TOP, 5f); root_child0.setMargin(YogaEdge.RIGHT, 5f); @@ -934,12 +962,12 @@ public class YGAlignItemsTest { root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); - final YogaNode root_child1_child0 = new YogaNode(); + final YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.setMargin(YogaEdge.LEFT, 1f); root_child1_child0.setMargin(YogaEdge.TOP, 1f); root_child1_child0.setMargin(YogaEdge.RIGHT, 1f); @@ -996,7 +1024,9 @@ public class YGAlignItemsTest { @Test public void test_align_baseline_child_padding() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.BASELINE); root.setPadding(YogaEdge.LEFT, 5); @@ -1006,12 +1036,12 @@ public class YGAlignItemsTest { root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setPadding(YogaEdge.LEFT, 5); root_child1.setPadding(YogaEdge.TOP, 5); root_child1.setPadding(YogaEdge.RIGHT, 5); @@ -1020,7 +1050,7 @@ public class YGAlignItemsTest { root_child1.setHeight(20f); root.addChildAt(root_child1, 1); - final YogaNode root_child1_child0 = new YogaNode(); + final YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.setWidth(50f); root_child1_child0.setHeight(10f); root_child1.addChildAt(root_child1_child0, 0); @@ -1073,39 +1103,41 @@ public class YGAlignItemsTest { @Test public void test_align_baseline_multiline() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.BASELINE); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); - final YogaNode root_child1_child0 = new YogaNode(); + final YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.setWidth(50f); root_child1_child0.setHeight(10f); root_child1.addChildAt(root_child1_child0, 0); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root_child2.setHeight(20f); root.addChildAt(root_child2, 2); - final YogaNode root_child2_child0 = new YogaNode(); + final YogaNode root_child2_child0 = new YogaNode(config); root_child2_child0.setWidth(50f); root_child2_child0.setHeight(10f); root_child2.addChildAt(root_child2_child0, 0); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(50f); root_child3.setHeight(50f); root.addChildAt(root_child3, 3); @@ -1188,38 +1220,40 @@ public class YGAlignItemsTest { @Test public void test_align_baseline_multiline_column() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.BASELINE); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(30f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); - final YogaNode root_child1_child0 = new YogaNode(); + final YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.setWidth(20f); root_child1_child0.setHeight(20f); root_child1.addChildAt(root_child1_child0, 0); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(40f); root_child2.setHeight(70f); root.addChildAt(root_child2, 2); - final YogaNode root_child2_child0 = new YogaNode(); + final YogaNode root_child2_child0 = new YogaNode(config); root_child2_child0.setWidth(10f); root_child2_child0.setHeight(10f); root_child2.addChildAt(root_child2_child0, 0); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(50f); root_child3.setHeight(20f); root.addChildAt(root_child3, 3); @@ -1302,38 +1336,40 @@ public class YGAlignItemsTest { @Test public void test_align_baseline_multiline_column2() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.BASELINE); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(30f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); - final YogaNode root_child1_child0 = new YogaNode(); + final YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.setWidth(20f); root_child1_child0.setHeight(20f); root_child1.addChildAt(root_child1_child0, 0); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(40f); root_child2.setHeight(70f); root.addChildAt(root_child2, 2); - final YogaNode root_child2_child0 = new YogaNode(); + final YogaNode root_child2_child0 = new YogaNode(config); root_child2_child0.setWidth(10f); root_child2_child0.setHeight(10f); root_child2.addChildAt(root_child2_child0, 0); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(50f); root_child3.setHeight(20f); root.addChildAt(root_child3, 3); @@ -1416,39 +1452,41 @@ public class YGAlignItemsTest { @Test public void test_align_baseline_multiline_row_and_column() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.BASELINE); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); - final YogaNode root_child1_child0 = new YogaNode(); + final YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.setWidth(50f); root_child1_child0.setHeight(10f); root_child1.addChildAt(root_child1_child0, 0); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root_child2.setHeight(20f); root.addChildAt(root_child2, 2); - final YogaNode root_child2_child0 = new YogaNode(); + final YogaNode root_child2_child0 = new YogaNode(config); root_child2_child0.setWidth(50f); root_child2_child0.setHeight(10f); root_child2.addChildAt(root_child2_child0, 0); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(50f); root_child3.setHeight(20f); root.addChildAt(root_child3, 3); diff --git a/java/tests/com/facebook/yoga/YGAlignSelfTest.java b/java/tests/com/facebook/yoga/YGAlignSelfTest.java index 6b69ac6a..2b00a83d 100644 --- a/java/tests/com/facebook/yoga/YGAlignSelfTest.java +++ b/java/tests/com/facebook/yoga/YGAlignSelfTest.java @@ -18,11 +18,13 @@ import static org.junit.Assert.assertEquals; public class YGAlignSelfTest { @Test public void test_align_self_center() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setAlignSelf(YogaAlign.CENTER); root_child0.setWidth(10f); root_child0.setHeight(10f); @@ -56,11 +58,13 @@ public class YGAlignSelfTest { @Test public void test_align_self_flex_end() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setAlignSelf(YogaAlign.FLEX_END); root_child0.setWidth(10f); root_child0.setHeight(10f); @@ -94,11 +98,13 @@ public class YGAlignSelfTest { @Test public void test_align_self_flex_start() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setAlignSelf(YogaAlign.FLEX_START); root_child0.setWidth(10f); root_child0.setHeight(10f); @@ -132,12 +138,14 @@ public class YGAlignSelfTest { @Test public void test_align_self_flex_end_override_flex_start() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.FLEX_START); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setAlignSelf(YogaAlign.FLEX_END); root_child0.setWidth(10f); root_child0.setHeight(10f); @@ -171,24 +179,26 @@ public class YGAlignSelfTest { @Test public void test_align_self_baseline() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setAlignSelf(YogaAlign.BASELINE); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setAlignSelf(YogaAlign.BASELINE); root_child1.setWidth(50f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); - final YogaNode root_child1_child0 = new YogaNode(); + final YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.setWidth(50f); root_child1_child0.setHeight(10f); root_child1.addChildAt(root_child1_child0, 0); diff --git a/java/tests/com/facebook/yoga/YGBorderTest.java b/java/tests/com/facebook/yoga/YGBorderTest.java index 595204fd..099e007c 100644 --- a/java/tests/com/facebook/yoga/YGBorderTest.java +++ b/java/tests/com/facebook/yoga/YGBorderTest.java @@ -18,7 +18,9 @@ import static org.junit.Assert.assertEquals; public class YGBorderTest { @Test public void test_border_no_size() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setBorder(YogaEdge.LEFT, 10f); root.setBorder(YogaEdge.TOP, 10f); root.setBorder(YogaEdge.RIGHT, 10f); @@ -42,13 +44,15 @@ public class YGBorderTest { @Test public void test_border_container_match_child() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setBorder(YogaEdge.LEFT, 10f); root.setBorder(YogaEdge.TOP, 10f); root.setBorder(YogaEdge.RIGHT, 10f); root.setBorder(YogaEdge.BOTTOM, 10f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); @@ -81,7 +85,9 @@ public class YGBorderTest { @Test public void test_border_flex_child() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setBorder(YogaEdge.LEFT, 10f); root.setBorder(YogaEdge.TOP, 10f); root.setBorder(YogaEdge.RIGHT, 10f); @@ -89,7 +95,7 @@ public class YGBorderTest { root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); @@ -122,7 +128,9 @@ public class YGBorderTest { @Test public void test_border_stretch_child() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setBorder(YogaEdge.LEFT, 10f); root.setBorder(YogaEdge.TOP, 10f); root.setBorder(YogaEdge.RIGHT, 10f); @@ -130,7 +138,7 @@ public class YGBorderTest { root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(YogaDirection.LTR); @@ -162,7 +170,9 @@ public class YGBorderTest { @Test public void test_border_center_child() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setJustifyContent(YogaJustify.CENTER); root.setAlignItems(YogaAlign.CENTER); root.setBorder(YogaEdge.START, 10f); @@ -171,7 +181,7 @@ public class YGBorderTest { root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); diff --git a/java/tests/com/facebook/yoga/YGDimensionTest.java b/java/tests/com/facebook/yoga/YGDimensionTest.java index fcef929e..4c27faad 100644 --- a/java/tests/com/facebook/yoga/YGDimensionTest.java +++ b/java/tests/com/facebook/yoga/YGDimensionTest.java @@ -18,9 +18,11 @@ import static org.junit.Assert.assertEquals; public class YGDimensionTest { @Test public void test_wrap_child() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root = new YogaNode(config); + + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(100f); root_child0.setHeight(100f); root.addChildAt(root_child0, 0); @@ -53,12 +55,14 @@ public class YGDimensionTest { @Test public void test_wrap_grandchild() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root = new YogaNode(config); + + final YogaNode root_child0 = new YogaNode(config); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setWidth(100f); root_child0_child0.setHeight(100f); root_child0.addChildAt(root_child0_child0, 0); diff --git a/java/tests/com/facebook/yoga/YGDisplayTest.java b/java/tests/com/facebook/yoga/YGDisplayTest.java index 5620792b..0670aae3 100644 --- a/java/tests/com/facebook/yoga/YGDisplayTest.java +++ b/java/tests/com/facebook/yoga/YGDisplayTest.java @@ -18,16 +18,18 @@ import static org.junit.Assert.assertEquals; public class YGDisplayTest { @Test public void test_display_none() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root_child1.setDisplay(YogaDisplay.NONE); root.addChildAt(root_child1, 1); @@ -70,16 +72,18 @@ public class YGDisplayTest { @Test public void test_display_none_fixed_size() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(20f); root_child1.setHeight(20f); root_child1.setDisplay(YogaDisplay.NONE); @@ -123,12 +127,14 @@ public class YGDisplayTest { @Test public void test_display_none_with_margin() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMargin(YogaEdge.LEFT, 10f); root_child0.setMargin(YogaEdge.TOP, 10f); root_child0.setMargin(YogaEdge.RIGHT, 10f); @@ -138,7 +144,7 @@ public class YGDisplayTest { root_child0.setDisplay(YogaDisplay.NONE); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -180,25 +186,27 @@ public class YGDisplayTest { @Test public void test_display_none_with_child() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexShrink(1f); root_child0.setFlexBasisPercent(0f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root_child1.setFlexShrink(1f); root_child1.setFlexBasisPercent(0f); root_child1.setDisplay(YogaDisplay.NONE); root.addChildAt(root_child1, 1); - final YogaNode root_child1_child0 = new YogaNode(); + final YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.setFlexGrow(1f); root_child1_child0.setFlexShrink(1f); root_child1_child0.setFlexBasisPercent(0f); @@ -207,7 +215,7 @@ public class YGDisplayTest { root_child1_child0.setMinHeight(0f); root_child1.addChildAt(root_child1_child0, 0); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setFlexGrow(1f); root_child2.setFlexShrink(1f); root_child2.setFlexBasisPercent(0f); @@ -271,16 +279,18 @@ public class YGDisplayTest { @Test public void test_display_none_with_position() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root_child1.setPosition(YogaEdge.TOP, 10f); root_child1.setDisplay(YogaDisplay.NONE); diff --git a/java/tests/com/facebook/yoga/YGFlexDirectionTest.java b/java/tests/com/facebook/yoga/YGFlexDirectionTest.java index c726b943..2f7f77e5 100644 --- a/java/tests/com/facebook/yoga/YGFlexDirectionTest.java +++ b/java/tests/com/facebook/yoga/YGFlexDirectionTest.java @@ -18,18 +18,20 @@ import static org.junit.Assert.assertEquals; public class YGFlexDirectionTest { @Test public void test_flex_direction_column_no_height() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -81,19 +83,21 @@ public class YGFlexDirectionTest { @Test public void test_flex_direction_row_no_width() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -145,19 +149,21 @@ public class YGFlexDirectionTest { @Test public void test_flex_direction_column() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -209,20 +215,22 @@ public class YGFlexDirectionTest { @Test public void test_flex_direction_row() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -274,20 +282,22 @@ public class YGFlexDirectionTest { @Test public void test_flex_direction_column_reverse() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -339,20 +349,22 @@ public class YGFlexDirectionTest { @Test public void test_flex_direction_row_reverse() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW_REVERSE); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); diff --git a/java/tests/com/facebook/yoga/YGFlexTest.java b/java/tests/com/facebook/yoga/YGFlexTest.java index 2d6d8ad4..7460ac39 100644 --- a/java/tests/com/facebook/yoga/YGFlexTest.java +++ b/java/tests/com/facebook/yoga/YGFlexTest.java @@ -18,16 +18,18 @@ import static org.junit.Assert.assertEquals; public class YGFlexTest { @Test public void test_flex_basis_flex_grow_column() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -69,17 +71,19 @@ public class YGFlexTest { @Test public void test_flex_basis_flex_grow_row() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -121,16 +125,18 @@ public class YGFlexTest { @Test public void test_flex_basis_flex_shrink_column() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexShrink(1f); root_child0.setFlexBasis(100f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexBasis(50f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -172,17 +178,19 @@ public class YGFlexTest { @Test public void test_flex_basis_flex_shrink_row() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexShrink(1f); root_child0.setFlexBasis(100f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexBasis(50f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -224,21 +232,23 @@ public class YGFlexTest { @Test public void test_flex_shrink_to_zero() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setHeight(75f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexShrink(1f); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root_child2.setHeight(50f); root.addChildAt(root_child2, 2); @@ -291,22 +301,24 @@ public class YGFlexTest { @Test public void test_flex_basis_overrides_main_size() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); root_child0.setHeight(20f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setFlexGrow(1f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); @@ -359,14 +371,16 @@ public class YGFlexTest { @Test public void test_flex_grow_shrink_at_most() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setFlexGrow(1f); root_child0_child0.setFlexShrink(1f); root_child0.addChildAt(root_child0_child0, 0); diff --git a/java/tests/com/facebook/yoga/YGFlexWrapTest.java b/java/tests/com/facebook/yoga/YGFlexWrapTest.java index e25aa79f..20e984d6 100644 --- a/java/tests/com/facebook/yoga/YGFlexWrapTest.java +++ b/java/tests/com/facebook/yoga/YGFlexWrapTest.java @@ -18,26 +18,28 @@ import static org.junit.Assert.assertEquals; public class YGFlexWrapTest { @Test public void test_wrap_column() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWrap(YogaWrap.WRAP); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(30f); root_child0.setHeight(30f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(30f); root_child1.setHeight(30f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(30f); root_child2.setHeight(30f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(30f); root_child3.setHeight(30f); root.addChildAt(root_child3, 3); @@ -100,27 +102,29 @@ public class YGFlexWrapTest { @Test public void test_wrap_row() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(30f); root_child0.setHeight(30f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(30f); root_child1.setHeight(30f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(30f); root_child2.setHeight(30f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(30f); root_child3.setHeight(30f); root.addChildAt(root_child3, 3); @@ -183,28 +187,30 @@ public class YGFlexWrapTest { @Test public void test_wrap_row_align_items_flex_end() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.FLEX_END); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(30f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(30f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(30f); root_child2.setHeight(30f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(30f); root_child3.setHeight(30f); root.addChildAt(root_child3, 3); @@ -267,28 +273,30 @@ public class YGFlexWrapTest { @Test public void test_wrap_row_align_items_center() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.CENTER); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(30f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(30f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(30f); root_child2.setHeight(30f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(30f); root_child3.setHeight(30f); root.addChildAt(root_child3, 3); @@ -351,18 +359,20 @@ public class YGFlexWrapTest { @Test public void test_flex_wrap_children_with_min_main_overriding_flex_basis() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexBasis(50f); root_child0.setMinWidth(55f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexBasis(50f); root_child1.setMinWidth(55f); root_child1.setHeight(50f); @@ -406,24 +416,26 @@ public class YGFlexWrapTest { @Test public void test_flex_wrap_wrap_to_child_height() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root = new YogaNode(config); + + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexDirection(YogaFlexDirection.ROW); root_child0.setAlignItems(YogaAlign.FLEX_START); root_child0.setWrap(YogaWrap.WRAP); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setWidth(100f); root_child0.addChildAt(root_child0_child0, 0); - final YogaNode root_child0_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0_child0 = new YogaNode(config); root_child0_child0_child0.setWidth(100f); root_child0_child0_child0.setHeight(100f); root_child0_child0.addChildAt(root_child0_child0_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(100f); root_child1.setHeight(100f); root.addChildAt(root_child1, 1); @@ -486,17 +498,19 @@ public class YGFlexWrapTest { @Test public void test_flex_wrap_align_stretch_fits_one_row() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWrap(YogaWrap.WRAP); root.setWidth(150f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -538,32 +552,34 @@ public class YGFlexWrapTest { @Test public void test_wrap_reverse_row_align_content_flex_start() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWrap(YogaWrap.WRAP_REVERSE); root.setWidth(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(30f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(30f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(30f); root_child2.setHeight(30f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(30f); root_child3.setHeight(40f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(30f); root_child4.setHeight(50f); root.addChildAt(root_child4, 4); @@ -636,33 +652,35 @@ public class YGFlexWrapTest { @Test public void test_wrap_reverse_row_align_content_center() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignContent(YogaAlign.CENTER); root.setWrap(YogaWrap.WRAP_REVERSE); root.setWidth(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(30f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(30f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(30f); root_child2.setHeight(30f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(30f); root_child3.setHeight(40f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(30f); root_child4.setHeight(50f); root.addChildAt(root_child4, 4); @@ -735,32 +753,34 @@ public class YGFlexWrapTest { @Test public void test_wrap_reverse_row_single_line_different_size() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWrap(YogaWrap.WRAP_REVERSE); root.setWidth(300f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(30f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(30f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(30f); root_child2.setHeight(30f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(30f); root_child3.setHeight(40f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(30f); root_child4.setHeight(50f); root.addChildAt(root_child4, 4); @@ -833,33 +853,35 @@ public class YGFlexWrapTest { @Test public void test_wrap_reverse_row_align_content_stretch() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignContent(YogaAlign.STRETCH); root.setWrap(YogaWrap.WRAP_REVERSE); root.setWidth(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(30f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(30f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(30f); root_child2.setHeight(30f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(30f); root_child3.setHeight(40f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(30f); root_child4.setHeight(50f); root.addChildAt(root_child4, 4); @@ -932,33 +954,35 @@ public class YGFlexWrapTest { @Test public void test_wrap_reverse_row_align_content_space_around() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignContent(YogaAlign.SPACE_AROUND); root.setWrap(YogaWrap.WRAP_REVERSE); root.setWidth(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(30f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(30f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(30f); root_child2.setHeight(30f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(30f); root_child3.setHeight(40f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(30f); root_child4.setHeight(50f); root.addChildAt(root_child4, 4); @@ -1031,33 +1055,35 @@ public class YGFlexWrapTest { @Test public void test_wrap_reverse_column_fixed_size() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.CENTER); root.setWrap(YogaWrap.WRAP_REVERSE); root.setWidth(200f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(30f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(30f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(30f); root_child2.setHeight(30f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setWidth(30f); root_child3.setHeight(40f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setWidth(30f); root_child4.setHeight(50f); root.addChildAt(root_child4, 4); @@ -1130,22 +1156,24 @@ public class YGFlexWrapTest { @Test public void test_wrapped_row_within_align_items_center() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.CENTER); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexDirection(YogaFlexDirection.ROW); root_child0.setWrap(YogaWrap.WRAP); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setWidth(150f); root_child0_child0.setHeight(80f); root_child0.addChildAt(root_child0_child0, 0); - final YogaNode root_child0_child1 = new YogaNode(); + final YogaNode root_child0_child1 = new YogaNode(config); root_child0_child1.setWidth(80f); root_child0_child1.setHeight(80f); root_child0.addChildAt(root_child0_child1, 1); @@ -1198,22 +1226,24 @@ public class YGFlexWrapTest { @Test public void test_wrapped_row_within_align_items_flex_start() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.FLEX_START); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexDirection(YogaFlexDirection.ROW); root_child0.setWrap(YogaWrap.WRAP); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setWidth(150f); root_child0_child0.setHeight(80f); root_child0.addChildAt(root_child0_child0, 0); - final YogaNode root_child0_child1 = new YogaNode(); + final YogaNode root_child0_child1 = new YogaNode(config); root_child0_child1.setWidth(80f); root_child0_child1.setHeight(80f); root_child0.addChildAt(root_child0_child1, 1); @@ -1266,22 +1296,24 @@ public class YGFlexWrapTest { @Test public void test_wrapped_row_within_align_items_flex_end() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.FLEX_END); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexDirection(YogaFlexDirection.ROW); root_child0.setWrap(YogaWrap.WRAP); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setWidth(150f); root_child0_child0.setHeight(80f); root_child0.addChildAt(root_child0_child0, 0); - final YogaNode root_child0_child1 = new YogaNode(); + final YogaNode root_child0_child1 = new YogaNode(config); root_child0_child1.setWidth(80f); root_child0_child1.setHeight(80f); root_child0.addChildAt(root_child0_child1, 1); diff --git a/java/tests/com/facebook/yoga/YGJustifyContentTest.java b/java/tests/com/facebook/yoga/YGJustifyContentTest.java index 62985de9..2728389b 100644 --- a/java/tests/com/facebook/yoga/YGJustifyContentTest.java +++ b/java/tests/com/facebook/yoga/YGJustifyContentTest.java @@ -18,20 +18,22 @@ import static org.junit.Assert.assertEquals; public class YGJustifyContentTest { @Test public void test_justify_content_row_flex_start() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(102f); root.setHeight(102f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -83,21 +85,23 @@ public class YGJustifyContentTest { @Test public void test_justify_content_row_flex_end() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setJustifyContent(YogaJustify.FLEX_END); root.setWidth(102f); root.setHeight(102f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -149,21 +153,23 @@ public class YGJustifyContentTest { @Test public void test_justify_content_row_center() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setJustifyContent(YogaJustify.CENTER); root.setWidth(102f); root.setHeight(102f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -215,21 +221,23 @@ public class YGJustifyContentTest { @Test public void test_justify_content_row_space_between() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setJustifyContent(YogaJustify.SPACE_BETWEEN); root.setWidth(102f); root.setHeight(102f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -281,21 +289,23 @@ public class YGJustifyContentTest { @Test public void test_justify_content_row_space_around() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setJustifyContent(YogaJustify.SPACE_AROUND); root.setWidth(102f); root.setHeight(102f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -347,18 +357,20 @@ public class YGJustifyContentTest { @Test public void test_justify_content_column_flex_start() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(102f); root.setHeight(102f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -410,20 +422,22 @@ public class YGJustifyContentTest { @Test public void test_justify_content_column_flex_end() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setJustifyContent(YogaJustify.FLEX_END); root.setWidth(102f); root.setHeight(102f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -475,20 +489,22 @@ public class YGJustifyContentTest { @Test public void test_justify_content_column_center() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setJustifyContent(YogaJustify.CENTER); root.setWidth(102f); root.setHeight(102f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -540,20 +556,22 @@ public class YGJustifyContentTest { @Test public void test_justify_content_column_space_between() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setJustifyContent(YogaJustify.SPACE_BETWEEN); root.setWidth(102f); root.setHeight(102f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -605,20 +623,22 @@ public class YGJustifyContentTest { @Test public void test_justify_content_column_space_around() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setJustifyContent(YogaJustify.SPACE_AROUND); root.setWidth(102f); root.setHeight(102f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); diff --git a/java/tests/com/facebook/yoga/YGMarginTest.java b/java/tests/com/facebook/yoga/YGMarginTest.java index 699f56b0..7ff9854d 100644 --- a/java/tests/com/facebook/yoga/YGMarginTest.java +++ b/java/tests/com/facebook/yoga/YGMarginTest.java @@ -18,12 +18,14 @@ import static org.junit.Assert.assertEquals; public class YGMarginTest { @Test public void test_margin_start() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMargin(YogaEdge.START, 10f); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); @@ -56,11 +58,13 @@ public class YGMarginTest { @Test public void test_margin_top() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMargin(YogaEdge.TOP, 10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); @@ -93,13 +97,15 @@ public class YGMarginTest { @Test public void test_margin_end() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setJustifyContent(YogaJustify.FLEX_END); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMargin(YogaEdge.END, 10f); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); @@ -132,12 +138,14 @@ public class YGMarginTest { @Test public void test_margin_bottom() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setJustifyContent(YogaJustify.FLEX_END); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMargin(YogaEdge.BOTTOM, 10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); @@ -170,12 +178,14 @@ public class YGMarginTest { @Test public void test_margin_and_flex_row() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setMargin(YogaEdge.START, 10f); root_child0.setMargin(YogaEdge.END, 10f); @@ -209,11 +219,13 @@ public class YGMarginTest { @Test public void test_margin_and_flex_column() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setMargin(YogaEdge.TOP, 10f); root_child0.setMargin(YogaEdge.BOTTOM, 10f); @@ -247,12 +259,14 @@ public class YGMarginTest { @Test public void test_margin_and_stretch_row() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setMargin(YogaEdge.TOP, 10f); root_child0.setMargin(YogaEdge.BOTTOM, 10f); @@ -286,11 +300,13 @@ public class YGMarginTest { @Test public void test_margin_and_stretch_column() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setMargin(YogaEdge.START, 10f); root_child0.setMargin(YogaEdge.END, 10f); @@ -324,17 +340,19 @@ public class YGMarginTest { @Test public void test_margin_with_sibling_row() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setMargin(YogaEdge.END, 10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -376,16 +394,18 @@ public class YGMarginTest { @Test public void test_margin_with_sibling_column() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setMargin(YogaEdge.BOTTOM, 10f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -427,18 +447,20 @@ public class YGMarginTest { @Test public void test_margin_auto_bottom() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.CENTER); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMarginAuto(YogaEdge.BOTTOM); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); @@ -481,18 +503,20 @@ public class YGMarginTest { @Test public void test_margin_auto_top() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.CENTER); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMarginAuto(YogaEdge.TOP); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); @@ -535,19 +559,21 @@ public class YGMarginTest { @Test public void test_margin_auto_bottom_and_top() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.CENTER); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMarginAuto(YogaEdge.TOP); root_child0.setMarginAuto(YogaEdge.BOTTOM); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); @@ -590,19 +616,21 @@ public class YGMarginTest { @Test public void test_margin_auto_bottom_and_top_justify_center() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setJustifyContent(YogaJustify.CENTER); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMarginAuto(YogaEdge.TOP); root_child0.setMarginAuto(YogaEdge.BOTTOM); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); @@ -645,24 +673,26 @@ public class YGMarginTest { @Test public void test_margin_auto_mutiple_children_column() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.CENTER); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMarginAuto(YogaEdge.TOP); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setMarginAuto(YogaEdge.TOP); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root_child2.setHeight(50f); root.addChildAt(root_child2, 2); @@ -715,25 +745,27 @@ public class YGMarginTest { @Test public void test_margin_auto_mutiple_children_row() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.CENTER); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMarginAuto(YogaEdge.RIGHT); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setMarginAuto(YogaEdge.RIGHT); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root_child2.setHeight(50f); root.addChildAt(root_child2, 2); @@ -786,20 +818,22 @@ public class YGMarginTest { @Test public void test_margin_auto_left_and_right_column() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.CENTER); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMarginAuto(YogaEdge.LEFT); root_child0.setMarginAuto(YogaEdge.RIGHT); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); @@ -842,18 +876,20 @@ public class YGMarginTest { @Test public void test_margin_auto_left_and_right() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMarginAuto(YogaEdge.LEFT); root_child0.setMarginAuto(YogaEdge.RIGHT); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); @@ -1006,19 +1042,21 @@ public class YGMarginTest { @Test public void test_margin_auto_left_and_right_column_and_center() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.CENTER); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMarginAuto(YogaEdge.LEFT); root_child0.setMarginAuto(YogaEdge.RIGHT); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); @@ -1061,18 +1099,20 @@ public class YGMarginTest { @Test public void test_margin_auto_left() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.CENTER); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMarginAuto(YogaEdge.LEFT); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); @@ -1115,18 +1155,20 @@ public class YGMarginTest { @Test public void test_margin_auto_right() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.CENTER); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMarginAuto(YogaEdge.RIGHT); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); @@ -1169,19 +1211,21 @@ public class YGMarginTest { @Test public void test_margin_auto_left_and_right_strech() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMarginAuto(YogaEdge.LEFT); root_child0.setMarginAuto(YogaEdge.RIGHT); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); @@ -1224,18 +1268,20 @@ public class YGMarginTest { @Test public void test_margin_auto_top_and_bottom_strech() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMarginAuto(YogaEdge.TOP); root_child0.setMarginAuto(YogaEdge.BOTTOM); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); diff --git a/java/tests/com/facebook/yoga/YGMinMaxDimensionTest.java b/java/tests/com/facebook/yoga/YGMinMaxDimensionTest.java index d1e33a46..4855ae2a 100644 --- a/java/tests/com/facebook/yoga/YGMinMaxDimensionTest.java +++ b/java/tests/com/facebook/yoga/YGMinMaxDimensionTest.java @@ -18,11 +18,13 @@ import static org.junit.Assert.assertEquals; public class YGMinMaxDimensionTest { @Test public void test_max_width() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMaxWidth(50f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); @@ -55,12 +57,14 @@ public class YGMinMaxDimensionTest { @Test public void test_max_height() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(10f); root_child0.setMaxHeight(50f); root.addChildAt(root_child0, 0); @@ -93,16 +97,18 @@ public class YGMinMaxDimensionTest { @Test public void test_min_height() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setMinHeight(60f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -144,17 +150,19 @@ public class YGMinMaxDimensionTest { @Test public void test_min_width() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setMinWidth(60f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -196,13 +204,15 @@ public class YGMinMaxDimensionTest { @Test public void test_justify_content_min_max() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setJustifyContent(YogaJustify.CENTER); root.setWidth(100f); root.setMinHeight(100f); root.setMaxHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(60f); root_child0.setHeight(60f); root.addChildAt(root_child0, 0); @@ -235,13 +245,15 @@ public class YGMinMaxDimensionTest { @Test public void test_align_items_min_max() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.CENTER); root.setMinWidth(100f); root.setMaxWidth(200f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(60f); root_child0.setHeight(60f); root.addChildAt(root_child0, 0); @@ -274,22 +286,24 @@ public class YGMinMaxDimensionTest { @Test public void test_justify_content_overflow_min_max() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setJustifyContent(YogaJustify.CENTER); root.setMinHeight(100f); root.setMaxHeight(110f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(50f); root_child2.setHeight(50f); root.addChildAt(root_child2, 2); @@ -342,19 +356,20 @@ public class YGMinMaxDimensionTest { @Test public void test_flex_grow_to_min() { - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_FLEX_FIX, true); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_FLEX_FIX, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setMinHeight(100f); root.setMaxHeight(500f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexShrink(1f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -392,25 +407,24 @@ public class YGMinMaxDimensionTest { assertEquals(50f, root_child1.getLayoutY(), 0.0f); assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); - - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_FLEX_FIX, false); } @Test public void test_flex_grow_in_at_most_container() { - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_FLEX_FIX, true); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_FLEX_FIX, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.FLEX_START); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexDirection(YogaFlexDirection.ROW); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setFlexGrow(1f); root_child0_child0.setFlexBasis(0f); root_child0.addChildAt(root_child0_child0, 0); @@ -449,22 +463,22 @@ public class YGMinMaxDimensionTest { assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f); - - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_FLEX_FIX, false); } @Test public void test_flex_grow_within_max_width() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(200f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexDirection(YogaFlexDirection.ROW); root_child0.setMaxWidth(100f); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setFlexGrow(1f); root_child0_child0.setHeight(20f); root_child0.addChildAt(root_child0_child0, 0); @@ -507,16 +521,18 @@ public class YGMinMaxDimensionTest { @Test public void test_flex_grow_within_constrained_max_width() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(200f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexDirection(YogaFlexDirection.ROW); root_child0.setMaxWidth(300f); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setFlexGrow(1f); root_child0_child0.setHeight(20f); root_child0.addChildAt(root_child0_child0, 0); @@ -559,16 +575,18 @@ public class YGMinMaxDimensionTest { @Test public void test_flex_grow_within_constrained_min_row() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setMinWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setWidth(50f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -610,14 +628,16 @@ public class YGMinMaxDimensionTest { @Test public void test_flex_grow_within_constrained_min_column() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setMinHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -659,21 +679,23 @@ public class YGMinMaxDimensionTest { @Test public void test_flex_grow_within_constrained_max_row() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexDirection(YogaFlexDirection.ROW); root_child0.setMaxWidth(100f); root_child0.setHeight(100f); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setFlexShrink(1f); root_child0_child0.setFlexBasis(100f); root_child0.addChildAt(root_child0_child0, 0); - final YogaNode root_child0_child1 = new YogaNode(); + final YogaNode root_child0_child1 = new YogaNode(config); root_child0_child1.setWidth(50f); root_child0.addChildAt(root_child0_child1, 1); root.setDirection(YogaDirection.LTR); @@ -725,16 +747,18 @@ public class YGMinMaxDimensionTest { @Test public void test_flex_grow_within_constrained_max_column() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setMaxHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexShrink(1f); root_child0.setFlexBasis(100f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -776,7 +800,9 @@ public class YGMinMaxDimensionTest { @Test public void test_min_width_overrides_width() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(50f); root.setMinWidth(100f); root.setDirection(YogaDirection.LTR); @@ -798,7 +824,9 @@ public class YGMinMaxDimensionTest { @Test public void test_max_width_overrides_width() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(200f); root.setMaxWidth(100f); root.setDirection(YogaDirection.LTR); @@ -820,7 +848,9 @@ public class YGMinMaxDimensionTest { @Test public void test_min_height_overrides_height() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setHeight(50f); root.setMinHeight(100f); root.setDirection(YogaDirection.LTR); @@ -842,7 +872,9 @@ public class YGMinMaxDimensionTest { @Test public void test_max_height_overrides_height() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setHeight(200f); root.setMaxHeight(100f); root.setDirection(YogaDirection.LTR); @@ -864,12 +896,14 @@ public class YGMinMaxDimensionTest { @Test public void test_min_max_percent_no_width_height() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setAlignItems(YogaAlign.FLEX_START); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setMinWidthPercent(10f); root_child0.setMaxWidthPercent(10f); root_child0.setMinHeightPercent(10f); diff --git a/java/tests/com/facebook/yoga/YGPaddingTest.java b/java/tests/com/facebook/yoga/YGPaddingTest.java index 4b3fb653..3c621d1b 100644 --- a/java/tests/com/facebook/yoga/YGPaddingTest.java +++ b/java/tests/com/facebook/yoga/YGPaddingTest.java @@ -18,7 +18,9 @@ import static org.junit.Assert.assertEquals; public class YGPaddingTest { @Test public void test_padding_no_size() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setPadding(YogaEdge.LEFT, 10); root.setPadding(YogaEdge.TOP, 10); root.setPadding(YogaEdge.RIGHT, 10); @@ -42,13 +44,15 @@ public class YGPaddingTest { @Test public void test_padding_container_match_child() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setPadding(YogaEdge.LEFT, 10); root.setPadding(YogaEdge.TOP, 10); root.setPadding(YogaEdge.RIGHT, 10); root.setPadding(YogaEdge.BOTTOM, 10); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); @@ -81,7 +85,9 @@ public class YGPaddingTest { @Test public void test_padding_flex_child() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setPadding(YogaEdge.LEFT, 10); root.setPadding(YogaEdge.TOP, 10); root.setPadding(YogaEdge.RIGHT, 10); @@ -89,7 +95,7 @@ public class YGPaddingTest { root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); @@ -122,7 +128,9 @@ public class YGPaddingTest { @Test public void test_padding_stretch_child() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setPadding(YogaEdge.LEFT, 10); root.setPadding(YogaEdge.TOP, 10); root.setPadding(YogaEdge.RIGHT, 10); @@ -130,7 +138,7 @@ public class YGPaddingTest { root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(YogaDirection.LTR); @@ -162,7 +170,9 @@ public class YGPaddingTest { @Test public void test_padding_center_child() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setJustifyContent(YogaJustify.CENTER); root.setAlignItems(YogaAlign.CENTER); root.setPadding(YogaEdge.START, 10); @@ -171,7 +181,7 @@ public class YGPaddingTest { root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); @@ -204,13 +214,15 @@ public class YGPaddingTest { @Test public void test_child_with_padding_align_end() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setJustifyContent(YogaJustify.FLEX_END); root.setAlignItems(YogaAlign.FLEX_END); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPadding(YogaEdge.LEFT, 20); root_child0.setPadding(YogaEdge.TOP, 20); root_child0.setPadding(YogaEdge.RIGHT, 20); diff --git a/java/tests/com/facebook/yoga/YGPercentageTest.java b/java/tests/com/facebook/yoga/YGPercentageTest.java index 8da5322f..47b51622 100644 --- a/java/tests/com/facebook/yoga/YGPercentageTest.java +++ b/java/tests/com/facebook/yoga/YGPercentageTest.java @@ -18,14 +18,15 @@ import static org.junit.Assert.assertEquals; public class YGPercentageTest { @Test public void test_percentage_width_height() { - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidthPercent(30f); root_child0.setHeightPercent(30f); root.addChildAt(root_child0, 0); @@ -54,20 +55,19 @@ public class YGPercentageTest { 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); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(400f); root.setHeight(400f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPositionPercent(YogaEdge.LEFT, 10f); root_child0.setPositionPercent(YogaEdge.TOP, 20f); root_child0.setWidthPercent(45f); @@ -98,20 +98,19 @@ public class YGPercentageTest { 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); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(500f); root.setHeight(500f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPositionPercent(YogaEdge.RIGHT, 20f); root_child0.setPositionPercent(YogaEdge.BOTTOM, 10f); root_child0.setWidthPercent(55f); @@ -142,25 +141,24 @@ public class YGPercentageTest { 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); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexBasisPercent(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root_child1.setFlexBasisPercent(25f); root.addChildAt(root_child1, 1); @@ -199,24 +197,23 @@ public class YGPercentageTest { 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); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexBasisPercent(50f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root_child1.setFlexBasisPercent(25f); root.addChildAt(root_child1, 1); @@ -255,24 +252,23 @@ public class YGPercentageTest { 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); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setMinHeightPercent(60f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(2f); root_child1.setMinHeightPercent(10f); root.addChildAt(root_child1, 1); @@ -311,26 +307,25 @@ public class YGPercentageTest { 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); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexBasisPercent(10f); root_child0.setMaxHeightPercent(60f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(4f); root_child1.setFlexBasisPercent(10f); root_child1.setMaxHeightPercent(20f); @@ -370,25 +365,24 @@ public class YGPercentageTest { 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); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexBasisPercent(10f); root_child0.setMaxHeightPercent(60f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(4f); root_child1.setFlexBasisPercent(10f); root_child1.setMaxHeightPercent(20f); @@ -428,26 +422,25 @@ public class YGPercentageTest { 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); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexBasisPercent(15f); root_child0.setMaxWidthPercent(60f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(4f); root_child1.setFlexBasisPercent(10f); root_child1.setMaxWidthPercent(20f); @@ -487,25 +480,24 @@ public class YGPercentageTest { 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); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexBasisPercent(10f); root_child0.setMaxWidthPercent(60f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(4f); root_child1.setFlexBasisPercent(15f); root_child1.setMaxWidthPercent(20f); @@ -545,26 +537,25 @@ public class YGPercentageTest { 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); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexBasisPercent(15f); root_child0.setMinWidthPercent(60f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(4f); root_child1.setFlexBasisPercent(10f); root_child1.setMinWidthPercent(20f); @@ -604,25 +595,24 @@ public class YGPercentageTest { 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); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexBasisPercent(10f); root_child0.setMinWidthPercent(60f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(4f); root_child1.setFlexBasisPercent(15f); root_child1.setMinWidthPercent(20f); @@ -662,19 +652,18 @@ public class YGPercentageTest { 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); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setWidth(200f); root.setHeight(200f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexBasisPercent(10f); root_child0.setMargin(YogaEdge.LEFT, 5f); @@ -688,7 +677,7 @@ public class YGPercentageTest { root_child0.setMinWidthPercent(60f); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setMargin(YogaEdge.LEFT, 5f); root_child0_child0.setMargin(YogaEdge.TOP, 5f); root_child0_child0.setMargin(YogaEdge.RIGHT, 5f); @@ -700,7 +689,7 @@ public class YGPercentageTest { root_child0_child0.setWidthPercent(50f); root_child0.addChildAt(root_child0_child0, 0); - final YogaNode root_child0_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0_child0 = new YogaNode(config); root_child0_child0_child0.setMarginPercent(YogaEdge.LEFT, 5f); root_child0_child0_child0.setMarginPercent(YogaEdge.TOP, 5f); root_child0_child0_child0.setMarginPercent(YogaEdge.RIGHT, 5f); @@ -712,7 +701,7 @@ public class YGPercentageTest { root_child0_child0_child0.setWidthPercent(45f); root_child0_child0.addChildAt(root_child0_child0_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(4f); root_child1.setFlexBasisPercent(15f); root_child1.setMinWidthPercent(20f); @@ -772,19 +761,18 @@ public class YGPercentageTest { 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); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setWidth(200f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setMarginPercent(YogaEdge.LEFT, 10f); root_child0.setMarginPercent(YogaEdge.TOP, 10f); @@ -792,7 +780,7 @@ public class YGPercentageTest { root_child0.setMarginPercent(YogaEdge.BOTTOM, 10f); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setWidth(10f); root_child0_child0.setHeight(10f); root_child0.addChildAt(root_child0_child0, 0); @@ -831,19 +819,18 @@ public class YGPercentageTest { 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); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setWidth(200f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setPaddingPercent(YogaEdge.LEFT, 10); root_child0.setPaddingPercent(YogaEdge.TOP, 10); @@ -851,7 +838,7 @@ public class YGPercentageTest { root_child0.setPaddingPercent(YogaEdge.BOTTOM, 10); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setWidth(10f); root_child0_child0.setHeight(10f); root_child0.addChildAt(root_child0_child0, 0); @@ -890,19 +877,18 @@ public class YGPercentageTest { 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); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setWidth(200f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setPositionPercent(YogaEdge.LEFT, 30f); root_child0.setPositionPercent(YogaEdge.TOP, 10f); @@ -934,15 +920,15 @@ public class YGPercentageTest { 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); } @Test public void test_percentage_width_height_undefined_parent_size() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root = new YogaNode(config); + + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidthPercent(50f); root_child0.setHeightPercent(50f); root.addChildAt(root_child0, 0); @@ -975,24 +961,26 @@ public class YGPercentageTest { @Test public void test_percent_within_flex_grow() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(350f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(100f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); - final YogaNode root_child1_child0 = new YogaNode(); + final YogaNode root_child1_child0 = new YogaNode(config); root_child1_child0.setWidthPercent(100f); root_child1.addChildAt(root_child1_child0, 0); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setWidth(100f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); diff --git a/java/tests/com/facebook/yoga/YGRoundingTest.java b/java/tests/com/facebook/yoga/YGRoundingTest.java index da59ee3c..ae2202df 100644 --- a/java/tests/com/facebook/yoga/YGRoundingTest.java +++ b/java/tests/com/facebook/yoga/YGRoundingTest.java @@ -18,22 +18,23 @@ import static org.junit.Assert.assertEquals; public class YGRoundingTest { @Test public void test_rounding_flex_basis_flex_grow_row_width_of_100() { - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setFlexGrow(1f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -81,36 +82,35 @@ public class YGRoundingTest { assertEquals(0f, root_child2.getLayoutY(), 0.0f); assertEquals(33f, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); - - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_flex_basis_flex_grow_row_prime_number_width() { - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(113f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setFlexGrow(1f); root.addChildAt(root_child2, 2); - final YogaNode root_child3 = new YogaNode(); + final YogaNode root_child3 = new YogaNode(config); root_child3.setFlexGrow(1f); root.addChildAt(root_child3, 3); - final YogaNode root_child4 = new YogaNode(); + final YogaNode root_child4 = new YogaNode(config); root_child4.setFlexGrow(1f); root.addChildAt(root_child4, 4); root.setDirection(YogaDirection.LTR); @@ -178,29 +178,28 @@ public class YGRoundingTest { assertEquals(0f, root_child4.getLayoutY(), 0.0f); assertEquals(23f, root_child4.getLayoutWidth(), 0.0f); assertEquals(100f, root_child4.getLayoutHeight(), 0.0f); - - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_flex_basis_flex_shrink_row() { - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(101f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexShrink(1f); root_child0.setFlexBasis(100f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexBasis(25f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setFlexBasis(25f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -248,30 +247,29 @@ public class YGRoundingTest { assertEquals(0f, root_child2.getLayoutY(), 0.0f); assertEquals(25f, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); - - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_flex_basis_overrides_main_size() { - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(113f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); root_child0.setHeight(20f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setFlexGrow(1f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); @@ -320,30 +318,29 @@ public class YGRoundingTest { assertEquals(89f, root_child2.getLayoutY(), 0.0f); assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_total_fractial() { - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setWidth(87.4f); root.setHeight(113.4f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(0.7f); root_child0.setFlexBasis(50.3f); root_child0.setHeight(20.3f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1.6f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setFlexGrow(1.1f); root_child2.setHeight(10.7f); root.addChildAt(root_child2, 2); @@ -392,44 +389,43 @@ public class YGRoundingTest { assertEquals(89f, root_child2.getLayoutY(), 0.0f); assertEquals(87f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_total_fractial_nested() { - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setWidth(87.4f); root.setHeight(113.4f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(0.7f); root_child0.setFlexBasis(50.3f); root_child0.setHeight(20.3f); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setFlexGrow(1f); root_child0_child0.setFlexBasis(0.3f); root_child0_child0.setPosition(YogaEdge.BOTTOM, 13.3f); root_child0_child0.setHeight(9.9f); root_child0.addChildAt(root_child0_child0, 0); - final YogaNode root_child0_child1 = new YogaNode(); + final YogaNode root_child0_child1 = new YogaNode(config); root_child0_child1.setFlexGrow(4f); root_child0_child1.setFlexBasis(0.3f); root_child0_child1.setPosition(YogaEdge.TOP, 13.3f); root_child0_child1.setHeight(1.1f); root_child0.addChildAt(root_child0_child1, 1); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1.6f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setFlexGrow(1.1f); root_child2.setHeight(10.7f); root.addChildAt(root_child2, 2); @@ -498,30 +494,29 @@ public class YGRoundingTest { assertEquals(89f, root_child2.getLayoutY(), 0.0f); assertEquals(87f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_fractial_input_1() { - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(113.4f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); root_child0.setHeight(20f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setFlexGrow(1f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); @@ -570,30 +565,29 @@ public class YGRoundingTest { assertEquals(89f, root_child2.getLayoutY(), 0.0f); assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_fractial_input_2() { - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(113.6f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); root_child0.setHeight(20f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setFlexGrow(1f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); @@ -642,31 +636,30 @@ public class YGRoundingTest { assertEquals(89f, root_child2.getLayoutY(), 0.0f); assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(25f, root_child2.getLayoutHeight(), 0.0f); - - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_fractial_input_3() { - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setPosition(YogaEdge.TOP, 0.3f); root.setWidth(100f); root.setHeight(113.4f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); root_child0.setHeight(20f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setFlexGrow(1f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); @@ -715,31 +708,30 @@ public class YGRoundingTest { assertEquals(89f, root_child2.getLayoutY(), 0.0f); assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_fractial_input_4() { - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaConfig config = new YogaConfig(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final YogaNode root = new YogaNode(); + final YogaNode root = new YogaNode(config); root.setPosition(YogaEdge.TOP, 0.7f); root.setWidth(100f); root.setHeight(113.4f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); root_child0.setHeight(20f); root.addChildAt(root_child0, 0); - final YogaNode root_child1 = new YogaNode(); + final YogaNode root_child1 = new YogaNode(config); root_child1.setFlexGrow(1f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final YogaNode root_child2 = new YogaNode(); + final YogaNode root_child2 = new YogaNode(config); root_child2.setFlexGrow(1f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); @@ -788,8 +780,6 @@ public class YGRoundingTest { assertEquals(89f, root_child2.getLayoutY(), 0.0f); assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - - YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } } diff --git a/java/tests/com/facebook/yoga/YGSizeOverflowTest.java b/java/tests/com/facebook/yoga/YGSizeOverflowTest.java index d54719a3..28201ce9 100644 --- a/java/tests/com/facebook/yoga/YGSizeOverflowTest.java +++ b/java/tests/com/facebook/yoga/YGSizeOverflowTest.java @@ -18,14 +18,16 @@ import static org.junit.Assert.assertEquals; public class YGSizeOverflowTest { @Test public void test_nested_overflowing_child() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setWidth(200f); root_child0_child0.setHeight(200f); root_child0.addChildAt(root_child0_child0, 0); @@ -68,16 +70,18 @@ public class YGSizeOverflowTest { @Test public void test_nested_overflowing_child_in_constraint_parent() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(100f); root_child0.setHeight(100f); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setWidth(200f); root_child0_child0.setHeight(200f); root_child0.addChildAt(root_child0_child0, 0); @@ -120,15 +124,17 @@ public class YGSizeOverflowTest { @Test public void test_parent_wrap_child_size_overflowing_parent() { - final YogaNode root = new YogaNode(); + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); root.setWidth(100f); root.setHeight(100f); - final YogaNode root_child0 = new YogaNode(); + final YogaNode root_child0 = new YogaNode(config); root_child0.setWidth(100f); root.addChildAt(root_child0, 0); - final YogaNode root_child0_child0 = new YogaNode(); + final YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.setWidth(100f); root_child0_child0.setHeight(200f); root_child0.addChildAt(root_child0_child0, 0); diff --git a/javascript/sources/Config.hh b/javascript/sources/Config.hh new file mode 100644 index 00000000..f7091353 --- /dev/null +++ b/javascript/sources/Config.hh @@ -0,0 +1,49 @@ +/** + * 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. + */ + +#pragma once + +#include +#include +#include + +class Config { +private: + YGConfigRef m_config; + + Config(void) + : m_config(YGConfigNew()) + {} + +public: + + static Config * create(void) + { + return new Config(); + } + + static void destroy(Config * config) + { + delete config; + } + + ~Config(void) + { + YGConfigFree(m_config); + } + + void setExperimentalFeatureEnabled(int feature, bool enabled) + { + YGConfigSetExperimentalFeatureEnabled(m_config, static_cast(feature), enabled); + } + + Config(Config const &) = delete; + + Config const & operator=(Config const &) = delete; +}; diff --git a/javascript/sources/Node.cc b/javascript/sources/Node.cc index d7e2ddd1..32da21a1 100644 --- a/javascript/sources/Node.cc +++ b/javascript/sources/Node.cc @@ -14,6 +14,7 @@ #include "./Node.hh" #include "./Layout.hh" #include "./Size.hh" +#include "./Config.hh" static YGSize globalMeasureFunc(YGNodeRef nodeRef, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode) { diff --git a/javascript/sources/Node.hh b/javascript/sources/Node.hh index 7ee3f76d..061d85a5 100644 --- a/javascript/sources/Node.hh +++ b/javascript/sources/Node.hh @@ -18,12 +18,14 @@ #include "./Layout.hh" #include "./Size.hh" #include "./Value.hh" +#include "./Config.hh" class Node { public: static Node * create(void); + static Node * create(Config * config); static void destroy(Node * node); public: diff --git a/javascript/sources/global.cc b/javascript/sources/global.cc index 67e4adce..56bb281f 100644 --- a/javascript/sources/global.cc +++ b/javascript/sources/global.cc @@ -11,16 +11,6 @@ #include "./global.hh" -void setExperimentalFeatureEnabled(int feature, bool enabled) -{ - YGSetExperimentalFeatureEnabled(static_cast(feature), enabled); -} - -bool isExperimentalFeatureEnabled(int feature) -{ - return YGIsExperimentalFeatureEnabled(static_cast(feature)); -} - unsigned getInstanceCount(void) { return YGNodeGetInstanceCount(); diff --git a/javascript/sources/global.hh b/javascript/sources/global.hh index 026c6a93..e4a55113 100644 --- a/javascript/sources/global.hh +++ b/javascript/sources/global.hh @@ -9,7 +9,4 @@ #pragma once -void setExperimentalFeatureEnabled(int feature, bool enabled); -bool isExperimentalFeatureEnabled(int feature); - unsigned getInstanceCount(void); diff --git a/javascript/sources/nbind.cc b/javascript/sources/nbind.cc index c15d0567..0be5a636 100644 --- a/javascript/sources/nbind.cc +++ b/javascript/sources/nbind.cc @@ -13,6 +13,7 @@ #include "./Layout.hh" #include "./Size.hh" #include "./Value.hh" +#include "./Config.hh" #include "./global.hh" #define NBIND_DUPLICATE_POINTERS true @@ -21,8 +22,6 @@ NBIND_GLOBAL() { - function(setExperimentalFeatureEnabled); - function(isExperimentalFeatureEnabled); function(getInstanceCount); } @@ -43,6 +42,13 @@ NBIND_CLASS(Value) construct(); } +NBIND_CLASS(Config) +{ + method(create); + method(destroy); + method(setExperimentalFeatureEnabled); +} + NBIND_CLASS(Node) { method(create); diff --git a/javascript/tests/Facebook.Yoga/YGAbsolutePositionTest.js b/javascript/tests/Facebook.Yoga/YGAbsolutePositionTest.js index f9d5511d..5130a821 100644 --- a/javascript/tests/Facebook.Yoga/YGAbsolutePositionTest.js +++ b/javascript/tests/Facebook.Yoga/YGAbsolutePositionTest.js @@ -13,11 +13,11 @@ var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY); it("absolute_layout_width_height_start_top", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE); root_child0.setPosition(Yoga.EDGE_START, 10); root_child0.setPosition(Yoga.EDGE_TOP, 10); @@ -55,11 +55,11 @@ it("absolute_layout_width_height_start_top", function () { }); it("absolute_layout_width_height_end_bottom", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE); root_child0.setPosition(Yoga.EDGE_END, 10); root_child0.setPosition(Yoga.EDGE_BOTTOM, 10); @@ -97,11 +97,11 @@ it("absolute_layout_width_height_end_bottom", function () { }); it("absolute_layout_start_top_end_bottom", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE); root_child0.setPosition(Yoga.EDGE_START, 10); root_child0.setPosition(Yoga.EDGE_TOP, 10); @@ -139,11 +139,11 @@ it("absolute_layout_start_top_end_bottom", function () { }); it("absolute_layout_width_height_start_top_end_bottom", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE); root_child0.setPosition(Yoga.EDGE_START, 10); root_child0.setPosition(Yoga.EDGE_TOP, 10); @@ -183,19 +183,19 @@ it("absolute_layout_width_height_start_top_end_bottom", function () { }); it("do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setOverflow(Yoga.OVERFLOW_HIDDEN); root.setWidth(50); root.setHeight(50); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE); root_child0.setPosition(Yoga.EDGE_START, 0); root_child0.setPosition(Yoga.EDGE_TOP, 0); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setWidth(100); root_child0_child0.setHeight(100); root_child0.insertChild(root_child0_child0, 0); @@ -240,7 +240,7 @@ it("do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent }); it("absolute_layout_within_border", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setMargin(Yoga.EDGE_LEFT, 10); root.setMargin(Yoga.EDGE_TOP, 10); root.setMargin(Yoga.EDGE_RIGHT, 10); @@ -256,7 +256,7 @@ it("absolute_layout_within_border", function () { root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE); root_child0.setPosition(Yoga.EDGE_LEFT, 0); root_child0.setPosition(Yoga.EDGE_TOP, 0); @@ -264,7 +264,7 @@ it("absolute_layout_within_border", function () { root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE); root_child1.setPosition(Yoga.EDGE_RIGHT, 0); root_child1.setPosition(Yoga.EDGE_BOTTOM, 0); @@ -312,14 +312,14 @@ it("absolute_layout_within_border", function () { }); it("absolute_layout_align_items_and_justify_content_center", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setJustifyContent(Yoga.JUSTIFY_CENTER); root.setAlignItems(Yoga.ALIGN_CENTER); root.setFlexGrow(1); root.setWidth(110); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE); root_child0.setWidth(60); root_child0.setHeight(40); @@ -355,14 +355,14 @@ it("absolute_layout_align_items_and_justify_content_center", function () { }); it("absolute_layout_align_items_and_justify_content_flex_end", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setJustifyContent(Yoga.JUSTIFY_FLEX_END); root.setAlignItems(Yoga.ALIGN_FLEX_END); root.setFlexGrow(1); root.setWidth(110); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE); root_child0.setWidth(60); root_child0.setHeight(40); @@ -398,13 +398,13 @@ it("absolute_layout_align_items_and_justify_content_flex_end", function () { }); it("absolute_layout_justify_content_center", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setJustifyContent(Yoga.JUSTIFY_CENTER); root.setFlexGrow(1); root.setWidth(110); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE); root_child0.setWidth(60); root_child0.setHeight(40); @@ -440,13 +440,13 @@ it("absolute_layout_justify_content_center", function () { }); it("absolute_layout_align_items_center", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_CENTER); root.setFlexGrow(1); root.setWidth(110); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE); root_child0.setWidth(60); root_child0.setHeight(40); @@ -482,12 +482,12 @@ it("absolute_layout_align_items_center", function () { }); it("absolute_layout_align_items_center_on_child_only", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexGrow(1); root.setWidth(110); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setAlignSelf(Yoga.ALIGN_CENTER); root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE); root_child0.setWidth(60); @@ -524,14 +524,14 @@ it("absolute_layout_align_items_center_on_child_only", function () { }); it("absolute_layout_align_items_and_justify_content_center_and_top_position", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setJustifyContent(Yoga.JUSTIFY_CENTER); root.setAlignItems(Yoga.ALIGN_CENTER); root.setFlexGrow(1); root.setWidth(110); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE); root_child0.setPosition(Yoga.EDGE_TOP, 10); root_child0.setWidth(60); @@ -568,14 +568,14 @@ it("absolute_layout_align_items_and_justify_content_center_and_top_position", fu }); it("absolute_layout_align_items_and_justify_content_center_and_bottom_position", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setJustifyContent(Yoga.JUSTIFY_CENTER); root.setAlignItems(Yoga.ALIGN_CENTER); root.setFlexGrow(1); root.setWidth(110); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE); root_child0.setPosition(Yoga.EDGE_BOTTOM, 10); root_child0.setWidth(60); @@ -612,14 +612,14 @@ it("absolute_layout_align_items_and_justify_content_center_and_bottom_position", }); it("absolute_layout_align_items_and_justify_content_center_and_left_position", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setJustifyContent(Yoga.JUSTIFY_CENTER); root.setAlignItems(Yoga.ALIGN_CENTER); root.setFlexGrow(1); root.setWidth(110); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE); root_child0.setPosition(Yoga.EDGE_LEFT, 5); root_child0.setWidth(60); @@ -656,14 +656,14 @@ it("absolute_layout_align_items_and_justify_content_center_and_left_position", f }); it("absolute_layout_align_items_and_justify_content_center_and_right_position", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setJustifyContent(Yoga.JUSTIFY_CENTER); root.setAlignItems(Yoga.ALIGN_CENTER); root.setFlexGrow(1); root.setWidth(110); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE); root_child0.setPosition(Yoga.EDGE_RIGHT, 5); root_child0.setWidth(60); diff --git a/javascript/tests/Facebook.Yoga/YGAlignContentTest.js b/javascript/tests/Facebook.Yoga/YGAlignContentTest.js index dd29d565..a2f26cd7 100644 --- a/javascript/tests/Facebook.Yoga/YGAlignContentTest.js +++ b/javascript/tests/Facebook.Yoga/YGAlignContentTest.js @@ -13,33 +13,33 @@ var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY); it("align_content_flex_start", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(130); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root_child2.setHeight(10); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(50); root_child3.setHeight(10); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(50); root_child4.setHeight(10); root.insertChild(root_child4, 4); @@ -114,30 +114,30 @@ it("align_content_flex_start", function () { }); it("align_content_flex_start_without_height_on_children", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(50); root_child3.setHeight(10); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(50); root.insertChild(root_child4, 4); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -211,36 +211,36 @@ it("align_content_flex_start_without_height_on_children", function () { }); it("align_content_flex_start_with_flex", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(100); root.setHeight(120); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexBasis("0%"); root_child0.setWidth(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root_child1.setFlexBasis("0%"); root_child1.setWidth(50); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setFlexGrow(1); root_child3.setFlexShrink(1); root_child3.setFlexBasis("0%"); root_child3.setWidth(50); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(50); root.insertChild(root_child4, 4); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -314,33 +314,33 @@ it("align_content_flex_start_with_flex", function () { }); it("align_content_flex_end", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignContent(Yoga.ALIGN_FLEX_END); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root_child2.setHeight(10); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(50); root_child3.setHeight(10); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(50); root_child4.setHeight(10); root.insertChild(root_child4, 4); @@ -415,29 +415,29 @@ it("align_content_flex_end", function () { }); it("align_content_stretch", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignContent(Yoga.ALIGN_STRETCH); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(150); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(50); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(50); root.insertChild(root_child4, 4); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -511,34 +511,34 @@ it("align_content_stretch", function () { }); it("align_content_spacebetween", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignContent(Yoga.ALIGN_SPACE_BETWEEN); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(130); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root_child2.setHeight(10); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(50); root_child3.setHeight(10); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(50); root_child4.setHeight(10); root.insertChild(root_child4, 4); @@ -613,34 +613,34 @@ it("align_content_spacebetween", function () { }); it("align_content_spacearound", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignContent(Yoga.ALIGN_SPACE_AROUND); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(140); root.setHeight(120); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root_child2.setHeight(10); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(50); root_child3.setHeight(10); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(50); root_child4.setHeight(10); root.insertChild(root_child4, 4); @@ -715,30 +715,30 @@ it("align_content_spacearound", function () { }); it("align_content_stretch_row", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignContent(Yoga.ALIGN_STRETCH); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(150); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(50); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(50); root.insertChild(root_child4, 4); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -812,36 +812,36 @@ it("align_content_stretch_row", function () { }); it("align_content_stretch_row_with_children", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignContent(Yoga.ALIGN_STRETCH); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(150); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setFlexGrow(1); root_child0_child0.setFlexShrink(1); root_child0_child0.setFlexBasis("0%"); root_child0.insertChild(root_child0_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(50); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(50); root.insertChild(root_child4, 4); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -925,36 +925,36 @@ it("align_content_stretch_row_with_children", function () { }); it("align_content_stretch_row_with_flex", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignContent(Yoga.ALIGN_STRETCH); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(150); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root_child1.setFlexShrink(1); root_child1.setFlexBasis("0%"); root_child1.setWidth(50); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setFlexGrow(1); root_child3.setFlexShrink(1); root_child3.setFlexBasis("0%"); root_child3.setWidth(50); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(50); root.insertChild(root_child4, 4); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -1028,35 +1028,35 @@ it("align_content_stretch_row_with_flex", function () { }); it("align_content_stretch_row_with_flex_no_shrink", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignContent(Yoga.ALIGN_STRETCH); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(150); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root_child1.setFlexShrink(1); root_child1.setFlexBasis("0%"); root_child1.setWidth(50); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setFlexGrow(1); root_child3.setFlexBasis("0%"); root_child3.setWidth(50); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(50); root.insertChild(root_child4, 4); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -1130,18 +1130,18 @@ it("align_content_stretch_row_with_flex_no_shrink", function () { }); it("align_content_stretch_row_with_margin", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignContent(Yoga.ALIGN_STRETCH); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(150); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setMargin(Yoga.EDGE_LEFT, 10); root_child1.setMargin(Yoga.EDGE_TOP, 10); root_child1.setMargin(Yoga.EDGE_RIGHT, 10); @@ -1149,11 +1149,11 @@ it("align_content_stretch_row_with_margin", function () { root_child1.setWidth(50); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setMargin(Yoga.EDGE_LEFT, 10); root_child3.setMargin(Yoga.EDGE_TOP, 10); root_child3.setMargin(Yoga.EDGE_RIGHT, 10); @@ -1161,7 +1161,7 @@ it("align_content_stretch_row_with_margin", function () { root_child3.setWidth(50); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(50); root.insertChild(root_child4, 4); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -1235,18 +1235,18 @@ it("align_content_stretch_row_with_margin", function () { }); it("align_content_stretch_row_with_padding", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignContent(Yoga.ALIGN_STRETCH); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(150); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setPadding(Yoga.EDGE_LEFT, 10); root_child1.setPadding(Yoga.EDGE_TOP, 10); root_child1.setPadding(Yoga.EDGE_RIGHT, 10); @@ -1254,11 +1254,11 @@ it("align_content_stretch_row_with_padding", function () { root_child1.setWidth(50); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setPadding(Yoga.EDGE_LEFT, 10); root_child3.setPadding(Yoga.EDGE_TOP, 10); root_child3.setPadding(Yoga.EDGE_RIGHT, 10); @@ -1266,7 +1266,7 @@ it("align_content_stretch_row_with_padding", function () { root_child3.setWidth(50); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(50); root.insertChild(root_child4, 4); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -1340,18 +1340,18 @@ it("align_content_stretch_row_with_padding", function () { }); it("align_content_stretch_row_with_single_row", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignContent(Yoga.ALIGN_STRETCH); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(150); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root.insertChild(root_child1, 1); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -1395,31 +1395,31 @@ it("align_content_stretch_row_with_single_row", function () { }); it("align_content_stretch_row_with_fixed_height", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignContent(Yoga.ALIGN_STRETCH); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(150); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(60); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(50); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(50); root.insertChild(root_child4, 4); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -1493,31 +1493,31 @@ it("align_content_stretch_row_with_fixed_height", function () { }); it("align_content_stretch_row_with_max_height", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignContent(Yoga.ALIGN_STRETCH); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(150); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setMaxHeight(20); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(50); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(50); root.insertChild(root_child4, 4); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -1591,31 +1591,31 @@ it("align_content_stretch_row_with_max_height", function () { }); it("align_content_stretch_row_with_min_height", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignContent(Yoga.ALIGN_STRETCH); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(150); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setMinHeight(80); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(50); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(50); root.insertChild(root_child4, 4); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -1689,38 +1689,38 @@ it("align_content_stretch_row_with_min_height", function () { }); it("align_content_stretch_column", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignContent(Yoga.ALIGN_STRETCH); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(100); root.setHeight(150); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setFlexGrow(1); root_child0_child0.setFlexShrink(1); root_child0_child0.setFlexBasis("0%"); root_child0.insertChild(root_child0_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root_child1.setFlexShrink(1); root_child1.setFlexBasis("0%"); root_child1.setHeight(50); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setHeight(50); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setHeight(50); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setHeight(50); root.insertChild(root_child4, 4); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -1804,10 +1804,10 @@ it("align_content_stretch_column", function () { }); it("align_content_stretch_is_not_overriding_align_items", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignContent(Yoga.ALIGN_STRETCH); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root_child0.setAlignContent(Yoga.ALIGN_STRETCH); root_child0.setAlignItems(Yoga.ALIGN_CENTER); @@ -1815,7 +1815,7 @@ it("align_content_stretch_is_not_overriding_align_items", function () { root_child0.setHeight(100); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH); root_child0_child0.setWidth(10); root_child0_child0.setHeight(10); diff --git a/javascript/tests/Facebook.Yoga/YGAlignItemsTest.js b/javascript/tests/Facebook.Yoga/YGAlignItemsTest.js index 4d769391..8c4bee4c 100644 --- a/javascript/tests/Facebook.Yoga/YGAlignItemsTest.js +++ b/javascript/tests/Facebook.Yoga/YGAlignItemsTest.js @@ -13,11 +13,11 @@ var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY); it("align_items_stretch", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setHeight(10); root.insertChild(root_child0, 0); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -51,12 +51,12 @@ it("align_items_stretch", function () { }); it("align_items_center", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_CENTER); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(10); root_child0.setHeight(10); root.insertChild(root_child0, 0); @@ -91,12 +91,12 @@ it("align_items_center", function () { }); it("align_items_flex_start", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_FLEX_START); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(10); root_child0.setHeight(10); root.insertChild(root_child0, 0); @@ -131,12 +131,12 @@ it("align_items_flex_start", function () { }); it("align_items_flex_end", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_FLEX_END); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(10); root_child0.setHeight(10); root.insertChild(root_child0, 0); @@ -171,18 +171,18 @@ it("align_items_flex_end", function () { }); it("align_baseline", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignItems(Yoga.ALIGN_BASELINE); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(20); root.insertChild(root_child1, 1); @@ -227,23 +227,23 @@ it("align_baseline", function () { }); it("align_baseline_child", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignItems(Yoga.ALIGN_BASELINE); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(20); root.insertChild(root_child1, 1); - var root_child1_child0 = Yoga.Node.create(); + var root_child1_child0 = Yoga.Node.create(config); root_child1_child0.setWidth(50); root_child1_child0.setHeight(10); root_child1.insertChild(root_child1_child0, 0); @@ -298,40 +298,40 @@ it("align_baseline_child", function () { }); it("align_baseline_child_multiline", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignItems(Yoga.ALIGN_BASELINE); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(60); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root_child1.setFlexWrap(Yoga.WRAP_WRAP); root_child1.setWidth(50); root_child1.setHeight(25); root.insertChild(root_child1, 1); - var root_child1_child0 = Yoga.Node.create(); + var root_child1_child0 = Yoga.Node.create(config); root_child1_child0.setWidth(25); root_child1_child0.setHeight(20); root_child1.insertChild(root_child1_child0, 0); - var root_child1_child1 = Yoga.Node.create(); + var root_child1_child1 = Yoga.Node.create(config); root_child1_child1.setWidth(25); root_child1_child1.setHeight(10); root_child1.insertChild(root_child1_child1, 1); - var root_child1_child2 = Yoga.Node.create(); + var root_child1_child2 = Yoga.Node.create(config); root_child1_child2.setWidth(25); root_child1_child2.setHeight(20); root_child1.insertChild(root_child1_child2, 2); - var root_child1_child3 = Yoga.Node.create(); + var root_child1_child3 = Yoga.Node.create(config); root_child1_child3.setWidth(25); root_child1_child3.setHeight(10); root_child1.insertChild(root_child1_child3, 3); @@ -416,41 +416,41 @@ it("align_baseline_child_multiline", function () { }); it("align_baseline_child_multiline_override", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignItems(Yoga.ALIGN_BASELINE); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(60); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root_child1.setFlexWrap(Yoga.WRAP_WRAP); root_child1.setWidth(50); root_child1.setHeight(25); root.insertChild(root_child1, 1); - var root_child1_child0 = Yoga.Node.create(); + var root_child1_child0 = Yoga.Node.create(config); root_child1_child0.setWidth(25); root_child1_child0.setHeight(20); root_child1.insertChild(root_child1_child0, 0); - var root_child1_child1 = Yoga.Node.create(); + var root_child1_child1 = Yoga.Node.create(config); root_child1_child1.setAlignSelf(Yoga.ALIGN_BASELINE); root_child1_child1.setWidth(25); root_child1_child1.setHeight(10); root_child1.insertChild(root_child1_child1, 1); - var root_child1_child2 = Yoga.Node.create(); + var root_child1_child2 = Yoga.Node.create(config); root_child1_child2.setWidth(25); root_child1_child2.setHeight(20); root_child1.insertChild(root_child1_child2, 2); - var root_child1_child3 = Yoga.Node.create(); + var root_child1_child3 = Yoga.Node.create(config); root_child1_child3.setAlignSelf(Yoga.ALIGN_BASELINE); root_child1_child3.setWidth(25); root_child1_child3.setHeight(10); @@ -536,40 +536,40 @@ it("align_baseline_child_multiline_override", function () { }); it("align_baseline_child_multiline_no_override_on_secondline", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignItems(Yoga.ALIGN_BASELINE); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(60); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root_child1.setFlexWrap(Yoga.WRAP_WRAP); root_child1.setWidth(50); root_child1.setHeight(25); root.insertChild(root_child1, 1); - var root_child1_child0 = Yoga.Node.create(); + var root_child1_child0 = Yoga.Node.create(config); root_child1_child0.setWidth(25); root_child1_child0.setHeight(20); root_child1.insertChild(root_child1_child0, 0); - var root_child1_child1 = Yoga.Node.create(); + var root_child1_child1 = Yoga.Node.create(config); root_child1_child1.setWidth(25); root_child1_child1.setHeight(10); root_child1.insertChild(root_child1_child1, 1); - var root_child1_child2 = Yoga.Node.create(); + var root_child1_child2 = Yoga.Node.create(config); root_child1_child2.setWidth(25); root_child1_child2.setHeight(20); root_child1.insertChild(root_child1_child2, 2); - var root_child1_child3 = Yoga.Node.create(); + var root_child1_child3 = Yoga.Node.create(config); root_child1_child3.setAlignSelf(Yoga.ALIGN_BASELINE); root_child1_child3.setWidth(25); root_child1_child3.setHeight(10); @@ -655,24 +655,24 @@ it("align_baseline_child_multiline_no_override_on_secondline", function () { }); it("align_baseline_child_top", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignItems(Yoga.ALIGN_BASELINE); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPosition(Yoga.EDGE_TOP, 10); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(20); root.insertChild(root_child1, 1); - var root_child1_child0 = Yoga.Node.create(); + var root_child1_child0 = Yoga.Node.create(config); root_child1_child0.setWidth(50); root_child1_child0.setHeight(10); root_child1.insertChild(root_child1_child0, 0); @@ -727,24 +727,24 @@ it("align_baseline_child_top", function () { }); it("align_baseline_child_top2", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignItems(Yoga.ALIGN_BASELINE); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setPosition(Yoga.EDGE_TOP, 5); root_child1.setWidth(50); root_child1.setHeight(20); root.insertChild(root_child1, 1); - var root_child1_child0 = Yoga.Node.create(); + var root_child1_child0 = Yoga.Node.create(config); root_child1_child0.setWidth(50); root_child1_child0.setHeight(10); root_child1.insertChild(root_child1_child0, 0); @@ -799,28 +799,28 @@ it("align_baseline_child_top2", function () { }); it("align_baseline_double_nested_child", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignItems(Yoga.ALIGN_BASELINE); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setWidth(50); root_child0_child0.setHeight(20); root_child0.insertChild(root_child0_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(20); root.insertChild(root_child1, 1); - var root_child1_child0 = Yoga.Node.create(); + var root_child1_child0 = Yoga.Node.create(config); root_child1_child0.setWidth(50); root_child1_child0.setHeight(15); root_child1.insertChild(root_child1_child0, 0); @@ -885,17 +885,17 @@ it("align_baseline_double_nested_child", function () { }); it("align_baseline_column", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_BASELINE); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(20); root.insertChild(root_child1, 1); @@ -940,13 +940,13 @@ it("align_baseline_column", function () { }); it("align_baseline_child_margin", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignItems(Yoga.ALIGN_BASELINE); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_LEFT, 5); root_child0.setMargin(Yoga.EDGE_TOP, 5); root_child0.setMargin(Yoga.EDGE_RIGHT, 5); @@ -955,12 +955,12 @@ it("align_baseline_child_margin", function () { root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(20); root.insertChild(root_child1, 1); - var root_child1_child0 = Yoga.Node.create(); + var root_child1_child0 = Yoga.Node.create(config); root_child1_child0.setMargin(Yoga.EDGE_LEFT, 1); root_child1_child0.setMargin(Yoga.EDGE_TOP, 1); root_child1_child0.setMargin(Yoga.EDGE_RIGHT, 1); @@ -1019,7 +1019,7 @@ it("align_baseline_child_margin", function () { }); it("align_baseline_child_padding", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignItems(Yoga.ALIGN_BASELINE); root.setPadding(Yoga.EDGE_LEFT, 5); @@ -1029,12 +1029,12 @@ it("align_baseline_child_padding", function () { root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setPadding(Yoga.EDGE_LEFT, 5); root_child1.setPadding(Yoga.EDGE_TOP, 5); root_child1.setPadding(Yoga.EDGE_RIGHT, 5); @@ -1043,7 +1043,7 @@ it("align_baseline_child_padding", function () { root_child1.setHeight(20); root.insertChild(root_child1, 1); - var root_child1_child0 = Yoga.Node.create(); + var root_child1_child0 = Yoga.Node.create(config); root_child1_child0.setWidth(50); root_child1_child0.setHeight(10); root_child1.insertChild(root_child1_child0, 0); @@ -1098,39 +1098,39 @@ it("align_baseline_child_padding", function () { }); it("align_baseline_multiline", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignItems(Yoga.ALIGN_BASELINE); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(20); root.insertChild(root_child1, 1); - var root_child1_child0 = Yoga.Node.create(); + var root_child1_child0 = Yoga.Node.create(config); root_child1_child0.setWidth(50); root_child1_child0.setHeight(10); root_child1.insertChild(root_child1_child0, 0); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root_child2.setHeight(20); root.insertChild(root_child2, 2); - var root_child2_child0 = Yoga.Node.create(); + var root_child2_child0 = Yoga.Node.create(config); root_child2_child0.setWidth(50); root_child2_child0.setHeight(10); root_child2.insertChild(root_child2_child0, 0); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(50); root_child3.setHeight(50); root.insertChild(root_child3, 3); @@ -1215,38 +1215,38 @@ it("align_baseline_multiline", function () { }); it("align_baseline_multiline_column", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_BASELINE); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(30); root_child1.setHeight(50); root.insertChild(root_child1, 1); - var root_child1_child0 = Yoga.Node.create(); + var root_child1_child0 = Yoga.Node.create(config); root_child1_child0.setWidth(20); root_child1_child0.setHeight(20); root_child1.insertChild(root_child1_child0, 0); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(40); root_child2.setHeight(70); root.insertChild(root_child2, 2); - var root_child2_child0 = Yoga.Node.create(); + var root_child2_child0 = Yoga.Node.create(config); root_child2_child0.setWidth(10); root_child2_child0.setHeight(10); root_child2.insertChild(root_child2_child0, 0); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(50); root_child3.setHeight(20); root.insertChild(root_child3, 3); @@ -1331,38 +1331,38 @@ it("align_baseline_multiline_column", function () { }); it("align_baseline_multiline_column2", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_BASELINE); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(30); root_child1.setHeight(50); root.insertChild(root_child1, 1); - var root_child1_child0 = Yoga.Node.create(); + var root_child1_child0 = Yoga.Node.create(config); root_child1_child0.setWidth(20); root_child1_child0.setHeight(20); root_child1.insertChild(root_child1_child0, 0); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(40); root_child2.setHeight(70); root.insertChild(root_child2, 2); - var root_child2_child0 = Yoga.Node.create(); + var root_child2_child0 = Yoga.Node.create(config); root_child2_child0.setWidth(10); root_child2_child0.setHeight(10); root_child2.insertChild(root_child2_child0, 0); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(50); root_child3.setHeight(20); root.insertChild(root_child3, 3); @@ -1447,39 +1447,39 @@ it("align_baseline_multiline_column2", function () { }); it("align_baseline_multiline_row_and_column", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignItems(Yoga.ALIGN_BASELINE); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(50); root.insertChild(root_child1, 1); - var root_child1_child0 = Yoga.Node.create(); + var root_child1_child0 = Yoga.Node.create(config); root_child1_child0.setWidth(50); root_child1_child0.setHeight(10); root_child1.insertChild(root_child1_child0, 0); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root_child2.setHeight(20); root.insertChild(root_child2, 2); - var root_child2_child0 = Yoga.Node.create(); + var root_child2_child0 = Yoga.Node.create(config); root_child2_child0.setWidth(50); root_child2_child0.setHeight(10); root_child2.insertChild(root_child2_child0, 0); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(50); root_child3.setHeight(20); root.insertChild(root_child3, 3); diff --git a/javascript/tests/Facebook.Yoga/YGAlignSelfTest.js b/javascript/tests/Facebook.Yoga/YGAlignSelfTest.js index e82ab511..37fe2dfb 100644 --- a/javascript/tests/Facebook.Yoga/YGAlignSelfTest.js +++ b/javascript/tests/Facebook.Yoga/YGAlignSelfTest.js @@ -13,11 +13,11 @@ var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY); it("align_self_center", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setAlignSelf(Yoga.ALIGN_CENTER); root_child0.setWidth(10); root_child0.setHeight(10); @@ -53,11 +53,11 @@ it("align_self_center", function () { }); it("align_self_flex_end", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setAlignSelf(Yoga.ALIGN_FLEX_END); root_child0.setWidth(10); root_child0.setHeight(10); @@ -93,11 +93,11 @@ it("align_self_flex_end", function () { }); it("align_self_flex_start", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setAlignSelf(Yoga.ALIGN_FLEX_START); root_child0.setWidth(10); root_child0.setHeight(10); @@ -133,12 +133,12 @@ it("align_self_flex_start", function () { }); it("align_self_flex_end_override_flex_start", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_FLEX_START); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setAlignSelf(Yoga.ALIGN_FLEX_END); root_child0.setWidth(10); root_child0.setHeight(10); @@ -174,24 +174,24 @@ it("align_self_flex_end_override_flex_start", function () { }); it("align_self_baseline", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setAlignSelf(Yoga.ALIGN_BASELINE); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setAlignSelf(Yoga.ALIGN_BASELINE); root_child1.setWidth(50); root_child1.setHeight(20); root.insertChild(root_child1, 1); - var root_child1_child0 = Yoga.Node.create(); + var root_child1_child0 = Yoga.Node.create(config); root_child1_child0.setWidth(50); root_child1_child0.setHeight(10); root_child1.insertChild(root_child1_child0, 0); diff --git a/javascript/tests/Facebook.Yoga/YGBorderTest.js b/javascript/tests/Facebook.Yoga/YGBorderTest.js index be5fb4cb..895c44e8 100644 --- a/javascript/tests/Facebook.Yoga/YGBorderTest.js +++ b/javascript/tests/Facebook.Yoga/YGBorderTest.js @@ -13,7 +13,7 @@ var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY); it("border_no_size", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setBorder(Yoga.EDGE_LEFT, 10); root.setBorder(Yoga.EDGE_TOP, 10); root.setBorder(Yoga.EDGE_RIGHT, 10); @@ -39,13 +39,13 @@ it("border_no_size", function () { }); it("border_container_match_child", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setBorder(Yoga.EDGE_LEFT, 10); root.setBorder(Yoga.EDGE_TOP, 10); root.setBorder(Yoga.EDGE_RIGHT, 10); root.setBorder(Yoga.EDGE_BOTTOM, 10); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(10); root_child0.setHeight(10); root.insertChild(root_child0, 0); @@ -80,7 +80,7 @@ it("border_container_match_child", function () { }); it("border_flex_child", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setBorder(Yoga.EDGE_LEFT, 10); root.setBorder(Yoga.EDGE_TOP, 10); root.setBorder(Yoga.EDGE_RIGHT, 10); @@ -88,7 +88,7 @@ it("border_flex_child", function () { root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setWidth(10); root.insertChild(root_child0, 0); @@ -123,7 +123,7 @@ it("border_flex_child", function () { }); it("border_stretch_child", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setBorder(Yoga.EDGE_LEFT, 10); root.setBorder(Yoga.EDGE_TOP, 10); root.setBorder(Yoga.EDGE_RIGHT, 10); @@ -131,7 +131,7 @@ it("border_stretch_child", function () { root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setHeight(10); root.insertChild(root_child0, 0); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -165,7 +165,7 @@ it("border_stretch_child", function () { }); it("border_center_child", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setJustifyContent(Yoga.JUSTIFY_CENTER); root.setAlignItems(Yoga.ALIGN_CENTER); root.setBorder(Yoga.EDGE_START, 10); @@ -174,7 +174,7 @@ it("border_center_child", function () { root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(10); root_child0.setHeight(10); root.insertChild(root_child0, 0); diff --git a/javascript/tests/Facebook.Yoga/YGDimensionTest.js b/javascript/tests/Facebook.Yoga/YGDimensionTest.js index b8ac8a23..c39f9dfe 100644 --- a/javascript/tests/Facebook.Yoga/YGDimensionTest.js +++ b/javascript/tests/Facebook.Yoga/YGDimensionTest.js @@ -13,9 +13,9 @@ var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY); it("wrap_child", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(100); root_child0.setHeight(100); root.insertChild(root_child0, 0); @@ -50,12 +50,12 @@ it("wrap_child", function () { }); it("wrap_grandchild", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setWidth(100); root_child0_child0.setHeight(100); root_child0.insertChild(root_child0_child0, 0); diff --git a/javascript/tests/Facebook.Yoga/YGDisplayTest.js b/javascript/tests/Facebook.Yoga/YGDisplayTest.js index 9590b8d8..1755371b 100644 --- a/javascript/tests/Facebook.Yoga/YGDisplayTest.js +++ b/javascript/tests/Facebook.Yoga/YGDisplayTest.js @@ -13,16 +13,16 @@ var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY); it("display_none", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root_child1.setDisplay(Yoga.DISPLAY_NONE); root.insertChild(root_child1, 1); @@ -67,16 +67,16 @@ it("display_none", function () { }); it("display_none_fixed_size", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(20); root_child1.setHeight(20); root_child1.setDisplay(Yoga.DISPLAY_NONE); @@ -122,12 +122,12 @@ it("display_none_fixed_size", function () { }); it("display_none_with_margin", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_LEFT, 10); root_child0.setMargin(Yoga.EDGE_TOP, 10); root_child0.setMargin(Yoga.EDGE_RIGHT, 10); @@ -137,7 +137,7 @@ it("display_none_with_margin", function () { root_child0.setDisplay(Yoga.DISPLAY_NONE); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root.insertChild(root_child1, 1); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -181,25 +181,25 @@ it("display_none_with_margin", function () { }); it("display_none_with_child", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexShrink(1); root_child0.setFlexBasis("0%"); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root_child1.setFlexShrink(1); root_child1.setFlexBasis("0%"); root_child1.setDisplay(Yoga.DISPLAY_NONE); root.insertChild(root_child1, 1); - var root_child1_child0 = Yoga.Node.create(); + var root_child1_child0 = Yoga.Node.create(config); root_child1_child0.setFlexGrow(1); root_child1_child0.setFlexShrink(1); root_child1_child0.setFlexBasis("0%"); @@ -208,7 +208,7 @@ it("display_none_with_child", function () { root_child1_child0.setMinHeight(0); root_child1.insertChild(root_child1_child0, 0); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setFlexGrow(1); root_child2.setFlexShrink(1); root_child2.setFlexBasis("0%"); @@ -274,16 +274,16 @@ it("display_none_with_child", function () { }); it("display_none_with_position", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root_child1.setPosition(Yoga.EDGE_TOP, 10); root_child1.setDisplay(Yoga.DISPLAY_NONE); diff --git a/javascript/tests/Facebook.Yoga/YGFlexDirectionTest.js b/javascript/tests/Facebook.Yoga/YGFlexDirectionTest.js index c6be00ad..25ef24fb 100644 --- a/javascript/tests/Facebook.Yoga/YGFlexDirectionTest.js +++ b/javascript/tests/Facebook.Yoga/YGFlexDirectionTest.js @@ -13,18 +13,18 @@ var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY); it("flex_direction_column_no_height", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setHeight(10); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -78,19 +78,19 @@ it("flex_direction_column_no_height", function () { }); it("flex_direction_row_no_width", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(10); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -144,19 +144,19 @@ it("flex_direction_row_no_width", function () { }); it("flex_direction_column", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setHeight(10); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -210,20 +210,20 @@ it("flex_direction_column", function () { }); it("flex_direction_row", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(10); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -277,20 +277,20 @@ it("flex_direction_row", function () { }); it("flex_direction_column_reverse", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN_REVERSE); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setHeight(10); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -344,20 +344,20 @@ it("flex_direction_column_reverse", function () { }); it("flex_direction_row_reverse", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW_REVERSE); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(10); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); diff --git a/javascript/tests/Facebook.Yoga/YGFlexTest.js b/javascript/tests/Facebook.Yoga/YGFlexTest.js index bb0da496..a0fa80dd 100644 --- a/javascript/tests/Facebook.Yoga/YGFlexTest.js +++ b/javascript/tests/Facebook.Yoga/YGFlexTest.js @@ -13,16 +13,16 @@ var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY); it("flex_basis_flex_grow_column", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexBasis(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root.insertChild(root_child1, 1); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -66,17 +66,17 @@ it("flex_basis_flex_grow_column", function () { }); it("flex_basis_flex_grow_row", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexBasis(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root.insertChild(root_child1, 1); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -120,16 +120,16 @@ it("flex_basis_flex_grow_row", function () { }); it("flex_basis_flex_shrink_column", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexShrink(1); root_child0.setFlexBasis(100); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexBasis(50); root.insertChild(root_child1, 1); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -173,17 +173,17 @@ it("flex_basis_flex_shrink_column", function () { }); it("flex_basis_flex_shrink_row", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexShrink(1); root_child0.setFlexBasis(100); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexBasis(50); root.insertChild(root_child1, 1); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -227,21 +227,21 @@ it("flex_basis_flex_shrink_row", function () { }); it("flex_shrink_to_zero", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setHeight(75); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexShrink(1); root_child1.setWidth(50); root_child1.setHeight(50); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root_child2.setHeight(50); root.insertChild(root_child2, 2); @@ -296,22 +296,22 @@ it("flex_shrink_to_zero", function () { }); it("flex_basis_overrides_main_size", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexBasis(50); root_child0.setHeight(20); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setFlexGrow(1); root_child2.setHeight(10); root.insertChild(root_child2, 2); @@ -366,14 +366,14 @@ it("flex_basis_overrides_main_size", function () { }); it("flex_grow_shrink_at_most", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setFlexGrow(1); root_child0_child0.setFlexShrink(1); root_child0.insertChild(root_child0_child0, 0); diff --git a/javascript/tests/Facebook.Yoga/YGFlexWrapTest.js b/javascript/tests/Facebook.Yoga/YGFlexWrapTest.js index dae63bf9..5b3b9bda 100644 --- a/javascript/tests/Facebook.Yoga/YGFlexWrapTest.js +++ b/javascript/tests/Facebook.Yoga/YGFlexWrapTest.js @@ -13,26 +13,26 @@ var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY); it("wrap_column", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexWrap(Yoga.WRAP_WRAP); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(30); root_child0.setHeight(30); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(30); root_child1.setHeight(30); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(30); root_child2.setHeight(30); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(30); root_child3.setHeight(30); root.insertChild(root_child3, 3); @@ -97,27 +97,27 @@ it("wrap_column", function () { }); it("wrap_row", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(30); root_child0.setHeight(30); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(30); root_child1.setHeight(30); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(30); root_child2.setHeight(30); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(30); root_child3.setHeight(30); root.insertChild(root_child3, 3); @@ -182,28 +182,28 @@ it("wrap_row", function () { }); it("wrap_row_align_items_flex_end", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignItems(Yoga.ALIGN_FLEX_END); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(30); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(30); root_child1.setHeight(20); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(30); root_child2.setHeight(30); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(30); root_child3.setHeight(30); root.insertChild(root_child3, 3); @@ -268,28 +268,28 @@ it("wrap_row_align_items_flex_end", function () { }); it("wrap_row_align_items_center", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignItems(Yoga.ALIGN_CENTER); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(30); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(30); root_child1.setHeight(20); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(30); root_child2.setHeight(30); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(30); root_child3.setHeight(30); root.insertChild(root_child3, 3); @@ -354,18 +354,18 @@ it("wrap_row_align_items_center", function () { }); it("flex_wrap_children_with_min_main_overriding_flex_basis", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexBasis(50); root_child0.setMinWidth(55); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexBasis(50); root_child1.setMinWidth(55); root_child1.setHeight(50); @@ -411,24 +411,24 @@ it("flex_wrap_children_with_min_main_overriding_flex_basis", function () { }); it("flex_wrap_wrap_to_child_height", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root_child0.setAlignItems(Yoga.ALIGN_FLEX_START); root_child0.setFlexWrap(Yoga.WRAP_WRAP); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setWidth(100); root_child0.insertChild(root_child0_child0, 0); - var root_child0_child0_child0 = Yoga.Node.create(); + var root_child0_child0_child0 = Yoga.Node.create(config); root_child0_child0_child0.setWidth(100); root_child0_child0_child0.setHeight(100); root_child0_child0.insertChild(root_child0_child0_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(100); root_child1.setHeight(100); root.insertChild(root_child1, 1); @@ -493,17 +493,17 @@ it("flex_wrap_wrap_to_child_height", function () { }); it("flex_wrap_align_stretch_fits_one_row", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setFlexWrap(Yoga.WRAP_WRAP); root.setWidth(150); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root.insertChild(root_child1, 1); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -547,32 +547,32 @@ it("flex_wrap_align_stretch_fits_one_row", function () { }); it("wrap_reverse_row_align_content_flex_start", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setFlexWrap(Yoga.WRAP_WRAP_REVERSE); root.setWidth(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(30); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(30); root_child1.setHeight(20); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(30); root_child2.setHeight(30); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(30); root_child3.setHeight(40); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(30); root_child4.setHeight(50); root.insertChild(root_child4, 4); @@ -647,33 +647,33 @@ it("wrap_reverse_row_align_content_flex_start", function () { }); it("wrap_reverse_row_align_content_center", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignContent(Yoga.ALIGN_CENTER); root.setFlexWrap(Yoga.WRAP_WRAP_REVERSE); root.setWidth(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(30); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(30); root_child1.setHeight(20); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(30); root_child2.setHeight(30); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(30); root_child3.setHeight(40); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(30); root_child4.setHeight(50); root.insertChild(root_child4, 4); @@ -748,32 +748,32 @@ it("wrap_reverse_row_align_content_center", function () { }); it("wrap_reverse_row_single_line_different_size", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setFlexWrap(Yoga.WRAP_WRAP_REVERSE); root.setWidth(300); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(30); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(30); root_child1.setHeight(20); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(30); root_child2.setHeight(30); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(30); root_child3.setHeight(40); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(30); root_child4.setHeight(50); root.insertChild(root_child4, 4); @@ -848,33 +848,33 @@ it("wrap_reverse_row_single_line_different_size", function () { }); it("wrap_reverse_row_align_content_stretch", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignContent(Yoga.ALIGN_STRETCH); root.setFlexWrap(Yoga.WRAP_WRAP_REVERSE); root.setWidth(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(30); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(30); root_child1.setHeight(20); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(30); root_child2.setHeight(30); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(30); root_child3.setHeight(40); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(30); root_child4.setHeight(50); root.insertChild(root_child4, 4); @@ -949,33 +949,33 @@ it("wrap_reverse_row_align_content_stretch", function () { }); it("wrap_reverse_row_align_content_space_around", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignContent(Yoga.ALIGN_SPACE_AROUND); root.setFlexWrap(Yoga.WRAP_WRAP_REVERSE); root.setWidth(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(30); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(30); root_child1.setHeight(20); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(30); root_child2.setHeight(30); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(30); root_child3.setHeight(40); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(30); root_child4.setHeight(50); root.insertChild(root_child4, 4); @@ -1050,33 +1050,33 @@ it("wrap_reverse_row_align_content_space_around", function () { }); it("wrap_reverse_column_fixed_size", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_CENTER); root.setFlexWrap(Yoga.WRAP_WRAP_REVERSE); root.setWidth(200); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(30); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(30); root_child1.setHeight(20); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(30); root_child2.setHeight(30); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setWidth(30); root_child3.setHeight(40); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setWidth(30); root_child4.setHeight(50); root.insertChild(root_child4, 4); @@ -1151,22 +1151,22 @@ it("wrap_reverse_column_fixed_size", function () { }); it("wrapped_row_within_align_items_center", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_CENTER); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root_child0.setFlexWrap(Yoga.WRAP_WRAP); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setWidth(150); root_child0_child0.setHeight(80); root_child0.insertChild(root_child0_child0, 0); - var root_child0_child1 = Yoga.Node.create(); + var root_child0_child1 = Yoga.Node.create(config); root_child0_child1.setWidth(80); root_child0_child1.setHeight(80); root_child0.insertChild(root_child0_child1, 1); @@ -1221,22 +1221,22 @@ it("wrapped_row_within_align_items_center", function () { }); it("wrapped_row_within_align_items_flex_start", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_FLEX_START); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root_child0.setFlexWrap(Yoga.WRAP_WRAP); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setWidth(150); root_child0_child0.setHeight(80); root_child0.insertChild(root_child0_child0, 0); - var root_child0_child1 = Yoga.Node.create(); + var root_child0_child1 = Yoga.Node.create(config); root_child0_child1.setWidth(80); root_child0_child1.setHeight(80); root_child0.insertChild(root_child0_child1, 1); @@ -1291,22 +1291,22 @@ it("wrapped_row_within_align_items_flex_start", function () { }); it("wrapped_row_within_align_items_flex_end", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_FLEX_END); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root_child0.setFlexWrap(Yoga.WRAP_WRAP); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setWidth(150); root_child0_child0.setHeight(80); root_child0.insertChild(root_child0_child0, 0); - var root_child0_child1 = Yoga.Node.create(); + var root_child0_child1 = Yoga.Node.create(config); root_child0_child1.setWidth(80); root_child0_child1.setHeight(80); root_child0.insertChild(root_child0_child1, 1); diff --git a/javascript/tests/Facebook.Yoga/YGJustifyContentTest.js b/javascript/tests/Facebook.Yoga/YGJustifyContentTest.js index 511416fb..d2d71a38 100644 --- a/javascript/tests/Facebook.Yoga/YGJustifyContentTest.js +++ b/javascript/tests/Facebook.Yoga/YGJustifyContentTest.js @@ -13,20 +13,20 @@ var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY); it("justify_content_row_flex_start", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(102); root.setHeight(102); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(10); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -80,21 +80,21 @@ it("justify_content_row_flex_start", function () { }); it("justify_content_row_flex_end", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setJustifyContent(Yoga.JUSTIFY_FLEX_END); root.setWidth(102); root.setHeight(102); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(10); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -148,21 +148,21 @@ it("justify_content_row_flex_end", function () { }); it("justify_content_row_center", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setJustifyContent(Yoga.JUSTIFY_CENTER); root.setWidth(102); root.setHeight(102); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(10); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -216,21 +216,21 @@ it("justify_content_row_center", function () { }); it("justify_content_row_space_between", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setJustifyContent(Yoga.JUSTIFY_SPACE_BETWEEN); root.setWidth(102); root.setHeight(102); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(10); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -284,21 +284,21 @@ it("justify_content_row_space_between", function () { }); it("justify_content_row_space_around", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setJustifyContent(Yoga.JUSTIFY_SPACE_AROUND); root.setWidth(102); root.setHeight(102); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(10); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -352,18 +352,18 @@ it("justify_content_row_space_around", function () { }); it("justify_content_column_flex_start", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(102); root.setHeight(102); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setHeight(10); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -417,20 +417,20 @@ it("justify_content_column_flex_start", function () { }); it("justify_content_column_flex_end", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setJustifyContent(Yoga.JUSTIFY_FLEX_END); root.setWidth(102); root.setHeight(102); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setHeight(10); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -484,20 +484,20 @@ it("justify_content_column_flex_end", function () { }); it("justify_content_column_center", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setJustifyContent(Yoga.JUSTIFY_CENTER); root.setWidth(102); root.setHeight(102); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setHeight(10); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -551,20 +551,20 @@ it("justify_content_column_center", function () { }); it("justify_content_column_space_between", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setJustifyContent(Yoga.JUSTIFY_SPACE_BETWEEN); root.setWidth(102); root.setHeight(102); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setHeight(10); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -618,20 +618,20 @@ it("justify_content_column_space_between", function () { }); it("justify_content_column_space_around", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setJustifyContent(Yoga.JUSTIFY_SPACE_AROUND); root.setWidth(102); root.setHeight(102); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setHeight(10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setHeight(10); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); diff --git a/javascript/tests/Facebook.Yoga/YGMarginTest.js b/javascript/tests/Facebook.Yoga/YGMarginTest.js index 3cc01ad9..b6486915 100644 --- a/javascript/tests/Facebook.Yoga/YGMarginTest.js +++ b/javascript/tests/Facebook.Yoga/YGMarginTest.js @@ -13,12 +13,12 @@ var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY); it("margin_start", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_START, 10); root_child0.setWidth(10); root.insertChild(root_child0, 0); @@ -53,11 +53,11 @@ it("margin_start", function () { }); it("margin_top", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_TOP, 10); root_child0.setHeight(10); root.insertChild(root_child0, 0); @@ -92,13 +92,13 @@ it("margin_top", function () { }); it("margin_end", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setJustifyContent(Yoga.JUSTIFY_FLEX_END); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_END, 10); root_child0.setWidth(10); root.insertChild(root_child0, 0); @@ -133,12 +133,12 @@ it("margin_end", function () { }); it("margin_bottom", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setJustifyContent(Yoga.JUSTIFY_FLEX_END); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_BOTTOM, 10); root_child0.setHeight(10); root.insertChild(root_child0, 0); @@ -173,12 +173,12 @@ it("margin_bottom", function () { }); it("margin_and_flex_row", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setMargin(Yoga.EDGE_START, 10); root_child0.setMargin(Yoga.EDGE_END, 10); @@ -214,11 +214,11 @@ it("margin_and_flex_row", function () { }); it("margin_and_flex_column", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setMargin(Yoga.EDGE_TOP, 10); root_child0.setMargin(Yoga.EDGE_BOTTOM, 10); @@ -254,12 +254,12 @@ it("margin_and_flex_column", function () { }); it("margin_and_stretch_row", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setMargin(Yoga.EDGE_TOP, 10); root_child0.setMargin(Yoga.EDGE_BOTTOM, 10); @@ -295,11 +295,11 @@ it("margin_and_stretch_row", function () { }); it("margin_and_stretch_column", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setMargin(Yoga.EDGE_START, 10); root_child0.setMargin(Yoga.EDGE_END, 10); @@ -335,17 +335,17 @@ it("margin_and_stretch_column", function () { }); it("margin_with_sibling_row", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setMargin(Yoga.EDGE_END, 10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root.insertChild(root_child1, 1); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -389,16 +389,16 @@ it("margin_with_sibling_row", function () { }); it("margin_with_sibling_column", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setMargin(Yoga.EDGE_BOTTOM, 10); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root.insertChild(root_child1, 1); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -442,18 +442,18 @@ it("margin_with_sibling_column", function () { }); it("margin_auto_bottom", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_CENTER); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_BOTTOM, "auto"); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(50); root.insertChild(root_child1, 1); @@ -498,18 +498,18 @@ it("margin_auto_bottom", function () { }); it("margin_auto_top", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_CENTER); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_TOP, "auto"); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(50); root.insertChild(root_child1, 1); @@ -554,19 +554,19 @@ it("margin_auto_top", function () { }); it("margin_auto_bottom_and_top", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_CENTER); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_TOP, "auto"); root_child0.setMargin(Yoga.EDGE_BOTTOM, "auto"); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(50); root.insertChild(root_child1, 1); @@ -611,19 +611,19 @@ it("margin_auto_bottom_and_top", function () { }); it("margin_auto_bottom_and_top_justify_center", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setJustifyContent(Yoga.JUSTIFY_CENTER); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_TOP, "auto"); root_child0.setMargin(Yoga.EDGE_BOTTOM, "auto"); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(50); root.insertChild(root_child1, 1); @@ -668,24 +668,24 @@ it("margin_auto_bottom_and_top_justify_center", function () { }); it("margin_auto_mutiple_children_column", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_CENTER); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_TOP, "auto"); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setMargin(Yoga.EDGE_TOP, "auto"); root_child1.setWidth(50); root_child1.setHeight(50); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root_child2.setHeight(50); root.insertChild(root_child2, 2); @@ -740,25 +740,25 @@ it("margin_auto_mutiple_children_column", function () { }); it("margin_auto_mutiple_children_row", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignItems(Yoga.ALIGN_CENTER); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_RIGHT, "auto"); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setMargin(Yoga.EDGE_RIGHT, "auto"); root_child1.setWidth(50); root_child1.setHeight(50); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root_child2.setHeight(50); root.insertChild(root_child2, 2); @@ -813,20 +813,20 @@ it("margin_auto_mutiple_children_row", function () { }); it("margin_auto_left_and_right_column", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignItems(Yoga.ALIGN_CENTER); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_LEFT, "auto"); root_child0.setMargin(Yoga.EDGE_RIGHT, "auto"); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(50); root.insertChild(root_child1, 1); @@ -871,18 +871,18 @@ it("margin_auto_left_and_right_column", function () { }); it("margin_auto_left_and_right", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_LEFT, "auto"); root_child0.setMargin(Yoga.EDGE_RIGHT, "auto"); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(50); root.insertChild(root_child1, 1); @@ -1041,19 +1041,19 @@ it("margin_auto_start_and_end", function () { }); it("margin_auto_left_and_right_column_and_center", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_CENTER); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_LEFT, "auto"); root_child0.setMargin(Yoga.EDGE_RIGHT, "auto"); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(50); root.insertChild(root_child1, 1); @@ -1098,18 +1098,18 @@ it("margin_auto_left_and_right_column_and_center", function () { }); it("margin_auto_left", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_CENTER); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_LEFT, "auto"); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(50); root.insertChild(root_child1, 1); @@ -1154,18 +1154,18 @@ it("margin_auto_left", function () { }); it("margin_auto_right", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_CENTER); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_RIGHT, "auto"); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(50); root.insertChild(root_child1, 1); @@ -1210,19 +1210,19 @@ it("margin_auto_right", function () { }); it("margin_auto_left_and_right_strech", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_LEFT, "auto"); root_child0.setMargin(Yoga.EDGE_RIGHT, "auto"); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(50); root.insertChild(root_child1, 1); @@ -1267,18 +1267,18 @@ it("margin_auto_left_and_right_strech", function () { }); it("margin_auto_top_and_bottom_strech", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMargin(Yoga.EDGE_TOP, "auto"); root_child0.setMargin(Yoga.EDGE_BOTTOM, "auto"); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(50); root.insertChild(root_child1, 1); diff --git a/javascript/tests/Facebook.Yoga/YGMinMaxDimensionTest.js b/javascript/tests/Facebook.Yoga/YGMinMaxDimensionTest.js index be9466ef..431ffab8 100644 --- a/javascript/tests/Facebook.Yoga/YGMinMaxDimensionTest.js +++ b/javascript/tests/Facebook.Yoga/YGMinMaxDimensionTest.js @@ -13,11 +13,11 @@ var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY); it("max_width", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMaxWidth(50); root_child0.setHeight(10); root.insertChild(root_child0, 0); @@ -52,12 +52,12 @@ it("max_width", function () { }); it("max_height", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(10); root_child0.setMaxHeight(50); root.insertChild(root_child0, 0); @@ -92,16 +92,16 @@ it("max_height", function () { }); it("min_height", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setMinHeight(60); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root.insertChild(root_child1, 1); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -145,17 +145,17 @@ it("min_height", function () { }); it("min_width", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setMinWidth(60); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root.insertChild(root_child1, 1); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -199,13 +199,13 @@ it("min_width", function () { }); it("justify_content_min_max", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setJustifyContent(Yoga.JUSTIFY_CENTER); root.setWidth(100); root.setMinHeight(100); root.setMaxHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(60); root_child0.setHeight(60); root.insertChild(root_child0, 0); @@ -240,13 +240,13 @@ it("justify_content_min_max", function () { }); it("align_items_min_max", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_CENTER); root.setMinWidth(100); root.setMaxWidth(200); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(60); root_child0.setHeight(60); root.insertChild(root_child0, 0); @@ -281,22 +281,22 @@ it("align_items_min_max", function () { }); it("justify_content_overflow_min_max", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setJustifyContent(Yoga.JUSTIFY_CENTER); root.setMinHeight(100); root.setMaxHeight(110); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(50); root_child0.setHeight(50); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root_child1.setHeight(50); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(50); root_child2.setHeight(50); root.insertChild(root_child2, 2); @@ -353,17 +353,17 @@ it("flex_grow_to_min", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_MIN_FLEX_FIX, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setMinHeight(100); root.setMaxHeight(500); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexShrink(1); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setHeight(50); root.insertChild(root_child1, 1); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -411,17 +411,17 @@ it("flex_grow_in_at_most_container", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_MIN_FLEX_FIX, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setAlignItems(Yoga.ALIGN_FLEX_START); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setFlexGrow(1); root_child0_child0.setFlexBasis(0); root_child0.insertChild(root_child0_child0, 0); @@ -468,16 +468,16 @@ it("flex_grow_in_at_most_container", function () { }); it("flex_grow_within_max_width", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(200); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root_child0.setMaxWidth(100); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setFlexGrow(1); root_child0_child0.setHeight(20); root_child0.insertChild(root_child0_child0, 0); @@ -522,16 +522,16 @@ it("flex_grow_within_max_width", function () { }); it("flex_grow_within_constrained_max_width", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(200); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root_child0.setMaxWidth(300); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setFlexGrow(1); root_child0_child0.setHeight(20); root_child0.insertChild(root_child0_child0, 0); @@ -576,16 +576,16 @@ it("flex_grow_within_constrained_max_width", function () { }); it("flex_grow_within_constrained_min_row", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setMinWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setWidth(50); root.insertChild(root_child1, 1); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -629,14 +629,14 @@ it("flex_grow_within_constrained_min_row", function () { }); it("flex_grow_within_constrained_min_column", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setMinHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setHeight(50); root.insertChild(root_child1, 1); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -680,21 +680,21 @@ it("flex_grow_within_constrained_min_column", function () { }); it("flex_grow_within_constrained_max_row", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root_child0.setMaxWidth(100); root_child0.setHeight(100); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setFlexShrink(1); root_child0_child0.setFlexBasis(100); root_child0.insertChild(root_child0_child0, 0); - var root_child0_child1 = Yoga.Node.create(); + var root_child0_child1 = Yoga.Node.create(config); root_child0_child1.setWidth(50); root_child0.insertChild(root_child0_child1, 1); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -748,16 +748,16 @@ it("flex_grow_within_constrained_max_row", function () { }); it("flex_grow_within_constrained_max_column", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setMaxHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexShrink(1); root_child0.setFlexBasis(100); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setHeight(50); root.insertChild(root_child1, 1); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -801,7 +801,7 @@ it("flex_grow_within_constrained_max_column", function () { }); it("min_width_overrides_width", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(50); root.setMinWidth(100); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -825,7 +825,7 @@ it("min_width_overrides_width", function () { }); it("max_width_overrides_width", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(200); root.setMaxWidth(100); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -849,7 +849,7 @@ it("max_width_overrides_width", function () { }); it("min_height_overrides_height", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setHeight(50); root.setMinHeight(100); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -873,7 +873,7 @@ it("min_height_overrides_height", function () { }); it("max_height_overrides_height", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setHeight(200); root.setMaxHeight(100); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -897,12 +897,12 @@ it("max_height_overrides_height", function () { }); it("min_max_percent_no_width_height", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setAlignItems(Yoga.ALIGN_FLEX_START); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setMinWidth("10%"); root_child0.setMaxWidth("10%"); root_child0.setMinHeight("10%"); diff --git a/javascript/tests/Facebook.Yoga/YGPaddingTest.js b/javascript/tests/Facebook.Yoga/YGPaddingTest.js index 093f9c5f..4f5bf2cb 100644 --- a/javascript/tests/Facebook.Yoga/YGPaddingTest.js +++ b/javascript/tests/Facebook.Yoga/YGPaddingTest.js @@ -13,7 +13,7 @@ var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY); it("padding_no_size", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setPadding(Yoga.EDGE_LEFT, 10); root.setPadding(Yoga.EDGE_TOP, 10); root.setPadding(Yoga.EDGE_RIGHT, 10); @@ -39,13 +39,13 @@ it("padding_no_size", function () { }); it("padding_container_match_child", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setPadding(Yoga.EDGE_LEFT, 10); root.setPadding(Yoga.EDGE_TOP, 10); root.setPadding(Yoga.EDGE_RIGHT, 10); root.setPadding(Yoga.EDGE_BOTTOM, 10); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(10); root_child0.setHeight(10); root.insertChild(root_child0, 0); @@ -80,7 +80,7 @@ it("padding_container_match_child", function () { }); it("padding_flex_child", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setPadding(Yoga.EDGE_LEFT, 10); root.setPadding(Yoga.EDGE_TOP, 10); root.setPadding(Yoga.EDGE_RIGHT, 10); @@ -88,7 +88,7 @@ it("padding_flex_child", function () { root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setWidth(10); root.insertChild(root_child0, 0); @@ -123,7 +123,7 @@ it("padding_flex_child", function () { }); it("padding_stretch_child", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setPadding(Yoga.EDGE_LEFT, 10); root.setPadding(Yoga.EDGE_TOP, 10); root.setPadding(Yoga.EDGE_RIGHT, 10); @@ -131,7 +131,7 @@ it("padding_stretch_child", function () { root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setHeight(10); root.insertChild(root_child0, 0); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -165,7 +165,7 @@ it("padding_stretch_child", function () { }); it("padding_center_child", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setJustifyContent(Yoga.JUSTIFY_CENTER); root.setAlignItems(Yoga.ALIGN_CENTER); root.setPadding(Yoga.EDGE_START, 10); @@ -174,7 +174,7 @@ it("padding_center_child", function () { root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(10); root_child0.setHeight(10); root.insertChild(root_child0, 0); @@ -209,13 +209,13 @@ it("padding_center_child", function () { }); it("child_with_padding_align_end", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setJustifyContent(Yoga.JUSTIFY_FLEX_END); root.setAlignItems(Yoga.ALIGN_FLEX_END); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPadding(Yoga.EDGE_LEFT, 20); root_child0.setPadding(Yoga.EDGE_TOP, 20); root_child0.setPadding(Yoga.EDGE_RIGHT, 20); diff --git a/javascript/tests/Facebook.Yoga/YGPercentageTest.js b/javascript/tests/Facebook.Yoga/YGPercentageTest.js index 51efcdcc..22fb9d28 100644 --- a/javascript/tests/Facebook.Yoga/YGPercentageTest.js +++ b/javascript/tests/Facebook.Yoga/YGPercentageTest.js @@ -15,12 +15,12 @@ it("percentage_width_height", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth("30%"); root_child0.setHeight("30%"); root.insertChild(root_child0, 0); @@ -59,12 +59,12 @@ it("percentage_position_left_top", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(400); root.setHeight(400); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPosition(Yoga.EDGE_LEFT, "10%"); root_child0.setPosition(Yoga.EDGE_TOP, "20%"); root_child0.setWidth("45%"); @@ -105,12 +105,12 @@ it("percentage_position_bottom_right", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(500); root.setHeight(500); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPosition(Yoga.EDGE_RIGHT, "20%"); root_child0.setPosition(Yoga.EDGE_BOTTOM, "10%"); root_child0.setWidth("55%"); @@ -151,17 +151,17 @@ it("percentage_flex_basis", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexBasis("50%"); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root_child1.setFlexBasis("25%"); root.insertChild(root_child1, 1); @@ -210,16 +210,16 @@ it("percentage_flex_basis_cross", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexBasis("50%"); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root_child1.setFlexBasis("25%"); root.insertChild(root_child1, 1); @@ -268,16 +268,16 @@ it("percentage_flex_basis_cross_min_height", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setMinHeight("60%"); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(2); root_child1.setMinHeight("10%"); root.insertChild(root_child1, 1); @@ -326,18 +326,18 @@ it("percentage_flex_basis_main_max_height", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexBasis("10%"); root_child0.setMaxHeight("60%"); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(4); root_child1.setFlexBasis("10%"); root_child1.setMaxHeight("20%"); @@ -387,17 +387,17 @@ it("percentage_flex_basis_cross_max_height", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexBasis("10%"); root_child0.setMaxHeight("60%"); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(4); root_child1.setFlexBasis("10%"); root_child1.setMaxHeight("20%"); @@ -447,18 +447,18 @@ it("percentage_flex_basis_main_max_width", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexBasis("15%"); root_child0.setMaxWidth("60%"); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(4); root_child1.setFlexBasis("10%"); root_child1.setMaxWidth("20%"); @@ -508,17 +508,17 @@ it("percentage_flex_basis_cross_max_width", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexBasis("10%"); root_child0.setMaxWidth("60%"); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(4); root_child1.setFlexBasis("15%"); root_child1.setMaxWidth("20%"); @@ -568,18 +568,18 @@ it("percentage_flex_basis_main_min_width", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexBasis("15%"); root_child0.setMinWidth("60%"); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(4); root_child1.setFlexBasis("10%"); root_child1.setMinWidth("20%"); @@ -629,17 +629,17 @@ it("percentage_flex_basis_cross_min_width", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexBasis("10%"); root_child0.setMinWidth("60%"); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(4); root_child1.setFlexBasis("15%"); root_child1.setMinWidth("20%"); @@ -689,11 +689,11 @@ it("percentage_multiple_nested_with_padding_margin_and_percentage_values", funct Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(200); root.setHeight(200); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexBasis("10%"); root_child0.setMargin(Yoga.EDGE_LEFT, 5); @@ -707,7 +707,7 @@ it("percentage_multiple_nested_with_padding_margin_and_percentage_values", funct root_child0.setMinWidth("60%"); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setMargin(Yoga.EDGE_LEFT, 5); root_child0_child0.setMargin(Yoga.EDGE_TOP, 5); root_child0_child0.setMargin(Yoga.EDGE_RIGHT, 5); @@ -719,7 +719,7 @@ it("percentage_multiple_nested_with_padding_margin_and_percentage_values", funct root_child0_child0.setWidth("50%"); root_child0.insertChild(root_child0_child0, 0); - var root_child0_child0_child0 = Yoga.Node.create(); + var root_child0_child0_child0 = Yoga.Node.create(config); root_child0_child0_child0.setMargin(Yoga.EDGE_LEFT, "5%"); root_child0_child0_child0.setMargin(Yoga.EDGE_TOP, "5%"); root_child0_child0_child0.setMargin(Yoga.EDGE_RIGHT, "5%"); @@ -731,7 +731,7 @@ it("percentage_multiple_nested_with_padding_margin_and_percentage_values", funct root_child0_child0_child0.setWidth("45%"); root_child0_child0.insertChild(root_child0_child0_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(4); root_child1.setFlexBasis("15%"); root_child1.setMinWidth("20%"); @@ -801,11 +801,11 @@ it("percentage_margin_should_calculate_based_only_on_width", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(200); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setMargin(Yoga.EDGE_LEFT, "10%"); root_child0.setMargin(Yoga.EDGE_TOP, "10%"); @@ -813,7 +813,7 @@ it("percentage_margin_should_calculate_based_only_on_width", function () { root_child0.setMargin(Yoga.EDGE_BOTTOM, "10%"); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setWidth(10); root_child0_child0.setHeight(10); root_child0.insertChild(root_child0_child0, 0); @@ -862,11 +862,11 @@ it("percentage_padding_should_calculate_based_only_on_width", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(200); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setPadding(Yoga.EDGE_LEFT, "10%"); root_child0.setPadding(Yoga.EDGE_TOP, "10%"); @@ -874,7 +874,7 @@ it("percentage_padding_should_calculate_based_only_on_width", function () { root_child0.setPadding(Yoga.EDGE_BOTTOM, "10%"); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setWidth(10); root_child0_child0.setHeight(10); root_child0.insertChild(root_child0_child0, 0); @@ -923,11 +923,11 @@ it("percentage_absolute_position", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(200); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE); root_child0.setPosition(Yoga.EDGE_LEFT, "30%"); root_child0.setPosition(Yoga.EDGE_TOP, "10%"); @@ -967,9 +967,9 @@ it("percentage_absolute_position", function () { }); it("percentage_width_height_undefined_parent_size", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth("50%"); root_child0.setHeight("50%"); root.insertChild(root_child0, 0); @@ -1004,24 +1004,24 @@ it("percentage_width_height_undefined_parent_size", function () { }); it("percent_within_flex_grow", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(350); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(100); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root.insertChild(root_child1, 1); - var root_child1_child0 = Yoga.Node.create(); + var root_child1_child0 = Yoga.Node.create(config); root_child1_child0.setWidth("100%"); root_child1.insertChild(root_child1_child0, 0); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setWidth(100); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); diff --git a/javascript/tests/Facebook.Yoga/YGRoundingTest.js b/javascript/tests/Facebook.Yoga/YGRoundingTest.js index 76bedcec..46e8b64d 100644 --- a/javascript/tests/Facebook.Yoga/YGRoundingTest.js +++ b/javascript/tests/Facebook.Yoga/YGRoundingTest.js @@ -15,20 +15,20 @@ it("rounding_flex_basis_flex_grow_row_width_of_100", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setFlexGrow(1); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -86,28 +86,28 @@ it("rounding_flex_basis_flex_grow_row_prime_number_width", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(113); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setFlexGrow(1); root.insertChild(root_child2, 2); - var root_child3 = Yoga.Node.create(); + var root_child3 = Yoga.Node.create(config); root_child3.setFlexGrow(1); root.insertChild(root_child3, 3); - var root_child4 = Yoga.Node.create(); + var root_child4 = Yoga.Node.create(config); root_child4.setFlexGrow(1); root.insertChild(root_child4, 4); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -185,21 +185,21 @@ it("rounding_flex_basis_flex_shrink_row", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); root.setWidth(101); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexShrink(1); root_child0.setFlexBasis(100); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexBasis(25); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setFlexBasis(25); root.insertChild(root_child2, 2); root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); @@ -257,22 +257,22 @@ it("rounding_flex_basis_overrides_main_size", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(113); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexBasis(50); root_child0.setHeight(20); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setFlexGrow(1); root_child2.setHeight(10); root.insertChild(root_child2, 2); @@ -331,22 +331,22 @@ it("rounding_total_fractial", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(87.4); root.setHeight(113.4); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(0.7); root_child0.setFlexBasis(50.3); root_child0.setHeight(20.3); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1.6); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setFlexGrow(1.1); root_child2.setHeight(10.7); root.insertChild(root_child2, 2); @@ -405,36 +405,36 @@ it("rounding_total_fractial_nested", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(87.4); root.setHeight(113.4); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(0.7); root_child0.setFlexBasis(50.3); root_child0.setHeight(20.3); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setFlexGrow(1); root_child0_child0.setFlexBasis(0.3); root_child0_child0.setPosition(Yoga.EDGE_BOTTOM, 13.3); root_child0_child0.setHeight(9.9); root_child0.insertChild(root_child0_child0, 0); - var root_child0_child1 = Yoga.Node.create(); + var root_child0_child1 = Yoga.Node.create(config); root_child0_child1.setFlexGrow(4); root_child0_child1.setFlexBasis(0.3); root_child0_child1.setPosition(Yoga.EDGE_TOP, 13.3); root_child0_child1.setHeight(1.1); root_child0.insertChild(root_child0_child1, 1); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1.6); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setFlexGrow(1.1); root_child2.setHeight(10.7); root.insertChild(root_child2, 2); @@ -513,22 +513,22 @@ it("rounding_fractial_input_1", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(113.4); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexBasis(50); root_child0.setHeight(20); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setFlexGrow(1); root_child2.setHeight(10); root.insertChild(root_child2, 2); @@ -587,22 +587,22 @@ it("rounding_fractial_input_2", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(113.6); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexBasis(50); root_child0.setHeight(20); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setFlexGrow(1); root_child2.setHeight(10); root.insertChild(root_child2, 2); @@ -661,23 +661,23 @@ it("rounding_fractial_input_3", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setPosition(Yoga.EDGE_TOP, 0.3); root.setWidth(100); root.setHeight(113.4); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexBasis(50); root_child0.setHeight(20); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setFlexGrow(1); root_child2.setHeight(10); root.insertChild(root_child2, 2); @@ -736,23 +736,23 @@ it("rounding_fractial_input_4", function () { Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true); try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setPosition(Yoga.EDGE_TOP, 0.7); root.setWidth(100); root.setHeight(113.4); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setFlexGrow(1); root_child0.setFlexBasis(50); root_child0.setHeight(20); root.insertChild(root_child0, 0); - var root_child1 = Yoga.Node.create(); + var root_child1 = Yoga.Node.create(config); root_child1.setFlexGrow(1); root_child1.setHeight(10); root.insertChild(root_child1, 1); - var root_child2 = Yoga.Node.create(); + var root_child2 = Yoga.Node.create(config); root_child2.setFlexGrow(1); root_child2.setHeight(10); root.insertChild(root_child2, 2); diff --git a/javascript/tests/Facebook.Yoga/YGSizeOverflowTest.js b/javascript/tests/Facebook.Yoga/YGSizeOverflowTest.js index 61abcad2..603832f8 100644 --- a/javascript/tests/Facebook.Yoga/YGSizeOverflowTest.js +++ b/javascript/tests/Facebook.Yoga/YGSizeOverflowTest.js @@ -13,14 +13,14 @@ var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY); it("nested_overflowing_child", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setWidth(200); root_child0_child0.setHeight(200); root_child0.insertChild(root_child0_child0, 0); @@ -65,16 +65,16 @@ it("nested_overflowing_child", function () { }); it("nested_overflowing_child_in_constraint_parent", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(100); root_child0.setHeight(100); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setWidth(200); root_child0_child0.setHeight(200); root_child0.insertChild(root_child0_child0, 0); @@ -119,15 +119,15 @@ it("nested_overflowing_child_in_constraint_parent", function () { }); it("parent_wrap_child_size_overflowing_parent", function () { try { - var root = Yoga.Node.create(); + var root = Yoga.Node.create(config); root.setWidth(100); root.setHeight(100); - var root_child0 = Yoga.Node.create(); + var root_child0 = Yoga.Node.create(config); root_child0.setWidth(100); root.insertChild(root_child0, 0); - var root_child0_child0 = Yoga.Node.create(); + var root_child0_child0 = Yoga.Node.create(config); root_child0_child0.setWidth(100); root_child0_child0.setHeight(200); root_child0.insertChild(root_child0_child0, 0); diff --git a/tests/YGAbsolutePositionTest.cpp b/tests/YGAbsolutePositionTest.cpp index 964419b9..d012dd02 100644 --- a/tests/YGAbsolutePositionTest.cpp +++ b/tests/YGAbsolutePositionTest.cpp @@ -13,11 +13,13 @@ #include TEST(YogaTest, absolute_layout_width_height_start_top) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); YGNodeStyleSetPosition(root_child0, YGEdgeStart, 10); YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); @@ -49,14 +51,18 @@ TEST(YogaTest, absolute_layout_width_height_start_top) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, absolute_layout_width_height_end_bottom) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); YGNodeStyleSetPosition(root_child0, YGEdgeEnd, 10); YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10); @@ -88,14 +94,18 @@ TEST(YogaTest, absolute_layout_width_height_end_bottom) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, absolute_layout_start_top_end_bottom) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); YGNodeStyleSetPosition(root_child0, YGEdgeStart, 10); YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); @@ -127,14 +137,18 @@ TEST(YogaTest, absolute_layout_start_top_end_bottom) { ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, absolute_layout_width_height_start_top_end_bottom) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); YGNodeStyleSetPosition(root_child0, YGEdgeStart, 10); YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); @@ -168,22 +182,26 @@ TEST(YogaTest, absolute_layout_width_height_start_top_end_bottom) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetOverflow(root, YGOverflowHidden); YGNodeStyleSetWidth(root, 50); YGNodeStyleSetHeight(root, 50); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); YGNodeStyleSetPosition(root_child0, YGEdgeStart, 0); YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0_child0, 100); YGNodeStyleSetHeight(root_child0_child0, 100); YGNodeInsertChild(root_child0, root_child0_child0, 0); @@ -222,10 +240,14 @@ TEST(YogaTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hi ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, absolute_layout_within_border) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetMargin(root, YGEdgeLeft, 10); YGNodeStyleSetMargin(root, YGEdgeTop, 10); YGNodeStyleSetMargin(root, YGEdgeRight, 10); @@ -241,7 +263,7 @@ TEST(YogaTest, absolute_layout_within_border) { YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 0); YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); @@ -249,7 +271,7 @@ TEST(YogaTest, absolute_layout_within_border) { YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionType(root_child1, YGPositionTypeAbsolute); YGNodeStyleSetPosition(root_child1, YGEdgeRight, 0); YGNodeStyleSetPosition(root_child1, YGEdgeBottom, 0); @@ -291,17 +313,21 @@ TEST(YogaTest, absolute_layout_within_border) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, absolute_layout_align_items_and_justify_content_center) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetFlexGrow(root, 1); YGNodeStyleSetWidth(root, 110); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); YGNodeStyleSetWidth(root_child0, 60); YGNodeStyleSetHeight(root_child0, 40); @@ -331,17 +357,21 @@ TEST(YogaTest, absolute_layout_align_items_and_justify_content_center) { ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, absolute_layout_align_items_and_justify_content_flex_end) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); YGNodeStyleSetFlexGrow(root, 1); YGNodeStyleSetWidth(root, 110); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); YGNodeStyleSetWidth(root_child0, 60); YGNodeStyleSetHeight(root_child0, 40); @@ -371,16 +401,20 @@ TEST(YogaTest, absolute_layout_align_items_and_justify_content_flex_end) { ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, absolute_layout_justify_content_center) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetFlexGrow(root, 1); YGNodeStyleSetWidth(root, 110); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); YGNodeStyleSetWidth(root_child0, 60); YGNodeStyleSetHeight(root_child0, 40); @@ -410,16 +444,20 @@ TEST(YogaTest, absolute_layout_justify_content_center) { ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, absolute_layout_align_items_center) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetFlexGrow(root, 1); YGNodeStyleSetWidth(root, 110); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); YGNodeStyleSetWidth(root_child0, 60); YGNodeStyleSetHeight(root_child0, 40); @@ -449,15 +487,19 @@ TEST(YogaTest, absolute_layout_align_items_center) { ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, absolute_layout_align_items_center_on_child_only) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root, 1); YGNodeStyleSetWidth(root, 110); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignSelf(root_child0, YGAlignCenter); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); YGNodeStyleSetWidth(root_child0, 60); @@ -488,17 +530,21 @@ TEST(YogaTest, absolute_layout_align_items_center_on_child_only) { ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_top_position) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetFlexGrow(root, 1); YGNodeStyleSetWidth(root, 110); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); YGNodeStyleSetWidth(root_child0, 60); @@ -529,17 +575,21 @@ TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_top_po ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_bottom_position) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetFlexGrow(root, 1); YGNodeStyleSetWidth(root, 110); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10); YGNodeStyleSetWidth(root_child0, 60); @@ -570,17 +620,21 @@ TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_bottom ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_left_position) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetFlexGrow(root, 1); YGNodeStyleSetWidth(root, 110); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 5); YGNodeStyleSetWidth(root_child0, 60); @@ -611,17 +665,21 @@ TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_left_p ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_right_position) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetFlexGrow(root, 1); YGNodeStyleSetWidth(root, 110); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); YGNodeStyleSetPosition(root_child0, YGEdgeRight, 5); YGNodeStyleSetWidth(root_child0, 60); @@ -652,4 +710,6 @@ TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_right_ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } diff --git a/tests/YGAlignContentTest.cpp b/tests/YGAlignContentTest.cpp index 61de501d..49628802 100644 --- a/tests/YGAlignContentTest.cpp +++ b/tests/YGAlignContentTest.cpp @@ -13,33 +13,35 @@ #include TEST(YogaTest, align_content_flex_start) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 130); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 50); YGNodeStyleSetHeight(root_child3, 10); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 50); YGNodeStyleSetHeight(root_child4, 10); YGNodeInsertChild(root, root_child4, 4); @@ -108,33 +110,37 @@ TEST(YogaTest, align_content_flex_start) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_content_flex_start_without_height_on_children) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 50); YGNodeStyleSetHeight(root_child3, 10); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -202,39 +208,43 @@ TEST(YogaTest, align_content_flex_start_without_height_on_children) { ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_content_flex_start_with_flex) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 120); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexBasisPercent(root_child0, 0); YGNodeStyleSetWidth(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeStyleSetFlexBasisPercent(root_child1, 0); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child3, 1); YGNodeStyleSetFlexShrink(root_child3, 1); YGNodeStyleSetFlexBasisPercent(root_child3, 0); YGNodeStyleSetWidth(root_child3, 50); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -302,36 +312,40 @@ TEST(YogaTest, align_content_flex_start_with_flex) { ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_content_flex_end) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignContent(root, YGAlignFlexEnd); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 50); YGNodeStyleSetHeight(root_child3, 10); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 50); YGNodeStyleSetHeight(root_child4, 10); YGNodeInsertChild(root, root_child4, 4); @@ -400,32 +414,36 @@ TEST(YogaTest, align_content_flex_end) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_content_stretch) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignContent(root, YGAlignStretch); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 150); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 50); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -493,37 +511,41 @@ TEST(YogaTest, align_content_stretch) { ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_content_spacebetween) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignContent(root, YGAlignSpaceBetween); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 130); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 50); YGNodeStyleSetHeight(root_child3, 10); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 50); YGNodeStyleSetHeight(root_child4, 10); YGNodeInsertChild(root, root_child4, 4); @@ -592,37 +614,41 @@ TEST(YogaTest, align_content_spacebetween) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_content_spacearound) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignContent(root, YGAlignSpaceAround); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 140); YGNodeStyleSetHeight(root, 120); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 50); YGNodeStyleSetHeight(root_child3, 10); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 50); YGNodeStyleSetHeight(root_child4, 10); YGNodeInsertChild(root, root_child4, 4); @@ -691,33 +717,37 @@ TEST(YogaTest, align_content_spacearound) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_content_stretch_row) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignContent(root, YGAlignStretch); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 150); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 50); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -785,39 +815,43 @@ TEST(YogaTest, align_content_stretch_row) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_content_stretch_row_with_children) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignContent(root, YGAlignStretch); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 150); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0_child0, 1); YGNodeStyleSetFlexShrink(root_child0_child0, 1); YGNodeStyleSetFlexBasisPercent(root_child0_child0, 0); YGNodeInsertChild(root_child0, root_child0_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 50); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -895,39 +929,43 @@ TEST(YogaTest, align_content_stretch_row_with_children) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_content_stretch_row_with_flex) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignContent(root, YGAlignStretch); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 150); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeStyleSetFlexShrink(root_child1, 1); YGNodeStyleSetFlexBasisPercent(root_child1, 0); YGNodeStyleSetWidth(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child3, 1); YGNodeStyleSetFlexShrink(root_child3, 1); YGNodeStyleSetFlexBasisPercent(root_child3, 0); YGNodeStyleSetWidth(root_child3, 50); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -995,38 +1033,42 @@ TEST(YogaTest, align_content_stretch_row_with_flex) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_content_stretch_row_with_flex_no_shrink) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignContent(root, YGAlignStretch); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 150); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeStyleSetFlexShrink(root_child1, 1); YGNodeStyleSetFlexBasisPercent(root_child1, 0); YGNodeStyleSetWidth(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child3, 1); YGNodeStyleSetFlexBasisPercent(root_child3, 0); YGNodeStyleSetWidth(root_child3, 50); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -1094,21 +1136,25 @@ TEST(YogaTest, align_content_stretch_row_with_flex_no_shrink) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_content_stretch_row_with_margin) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignContent(root, YGAlignStretch); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 150); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetMargin(root_child1, YGEdgeLeft, 10); YGNodeStyleSetMargin(root_child1, YGEdgeTop, 10); YGNodeStyleSetMargin(root_child1, YGEdgeRight, 10); @@ -1116,11 +1162,11 @@ TEST(YogaTest, align_content_stretch_row_with_margin) { YGNodeStyleSetWidth(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetMargin(root_child3, YGEdgeLeft, 10); YGNodeStyleSetMargin(root_child3, YGEdgeTop, 10); YGNodeStyleSetMargin(root_child3, YGEdgeRight, 10); @@ -1128,7 +1174,7 @@ TEST(YogaTest, align_content_stretch_row_with_margin) { YGNodeStyleSetWidth(root_child3, 50); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -1196,21 +1242,25 @@ TEST(YogaTest, align_content_stretch_row_with_margin) { ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_content_stretch_row_with_padding) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignContent(root, YGAlignStretch); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 150); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetPadding(root_child1, YGEdgeLeft, 10); YGNodeStyleSetPadding(root_child1, YGEdgeTop, 10); YGNodeStyleSetPadding(root_child1, YGEdgeRight, 10); @@ -1218,11 +1268,11 @@ TEST(YogaTest, align_content_stretch_row_with_padding) { YGNodeStyleSetWidth(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetPadding(root_child3, YGEdgeLeft, 10); YGNodeStyleSetPadding(root_child3, YGEdgeTop, 10); YGNodeStyleSetPadding(root_child3, YGEdgeRight, 10); @@ -1230,7 +1280,7 @@ TEST(YogaTest, align_content_stretch_row_with_padding) { YGNodeStyleSetWidth(root_child3, 50); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -1298,21 +1348,25 @@ TEST(YogaTest, align_content_stretch_row_with_padding) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_content_stretch_row_with_single_row) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignContent(root, YGAlignStretch); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 150); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -1350,34 +1404,38 @@ TEST(YogaTest, align_content_stretch_row_with_single_row) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_content_stretch_row_with_fixed_height) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignContent(root, YGAlignStretch); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 150); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 60); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 50); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -1445,34 +1503,38 @@ TEST(YogaTest, align_content_stretch_row_with_fixed_height) { ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_content_stretch_row_with_max_height) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignContent(root, YGAlignStretch); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 150); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetMaxHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 50); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -1540,34 +1602,38 @@ TEST(YogaTest, align_content_stretch_row_with_max_height) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_content_stretch_row_with_min_height) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignContent(root, YGAlignStretch); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 150); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetMinHeight(root_child1, 80); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 50); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -1635,41 +1701,45 @@ TEST(YogaTest, align_content_stretch_row_with_min_height) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_content_stretch_column) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignContent(root, YGAlignStretch); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 150); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0_child0, 1); YGNodeStyleSetFlexShrink(root_child0_child0, 1); YGNodeStyleSetFlexBasisPercent(root_child0_child0, 0); YGNodeInsertChild(root_child0, root_child0_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeStyleSetFlexShrink(root_child1, 1); YGNodeStyleSetFlexBasisPercent(root_child1, 0); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child3, 50); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -1747,13 +1817,17 @@ TEST(YogaTest, align_content_stretch_column) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_content_stretch_is_not_overriding_align_items) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignContent(root, YGAlignStretch); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); YGNodeStyleSetAlignContent(root_child0, YGAlignStretch); YGNodeStyleSetAlignItems(root_child0, YGAlignCenter); @@ -1761,7 +1835,7 @@ TEST(YogaTest, align_content_stretch_is_not_overriding_align_items) { YGNodeStyleSetHeight(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignContent(root_child0_child0, YGAlignStretch); YGNodeStyleSetWidth(root_child0_child0, 10); YGNodeStyleSetHeight(root_child0_child0, 10); @@ -1801,4 +1875,6 @@ TEST(YogaTest, align_content_stretch_is_not_overriding_align_items) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } diff --git a/tests/YGAlignItemsTest.cpp b/tests/YGAlignItemsTest.cpp index 37ac06e9..90fefcbc 100644 --- a/tests/YGAlignItemsTest.cpp +++ b/tests/YGAlignItemsTest.cpp @@ -13,11 +13,13 @@ #include TEST(YogaTest, align_items_stretch) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -45,15 +47,19 @@ TEST(YogaTest, align_items_stretch) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_items_center) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); @@ -82,15 +88,19 @@ TEST(YogaTest, align_items_center) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_items_flex_start) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); @@ -119,15 +129,19 @@ TEST(YogaTest, align_items_flex_start) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_items_flex_end) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); @@ -156,21 +170,25 @@ TEST(YogaTest, align_items_flex_end) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_baseline) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignBaseline); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); @@ -209,26 +227,30 @@ TEST(YogaTest, align_baseline) { ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_baseline_child) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignBaseline); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child1_child0 = YGNodeNew(); + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child0, 50); YGNodeStyleSetHeight(root_child1_child0, 10); YGNodeInsertChild(root_child1, root_child1_child0, 0); @@ -277,43 +299,47 @@ TEST(YogaTest, align_baseline_child) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_baseline_child_multiline) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignBaseline); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root_child1, YGFlexDirectionRow); YGNodeStyleSetFlexWrap(root_child1, YGWrapWrap); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 25); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child1_child0 = YGNodeNew(); + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child0, 25); YGNodeStyleSetHeight(root_child1_child0, 20); YGNodeInsertChild(root_child1, root_child1_child0, 0); - const YGNodeRef root_child1_child1 = YGNodeNew(); + const YGNodeRef root_child1_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child1, 25); YGNodeStyleSetHeight(root_child1_child1, 10); YGNodeInsertChild(root_child1, root_child1_child1, 1); - const YGNodeRef root_child1_child2 = YGNodeNew(); + const YGNodeRef root_child1_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child2, 25); YGNodeStyleSetHeight(root_child1_child2, 20); YGNodeInsertChild(root_child1, root_child1_child2, 2); - const YGNodeRef root_child1_child3 = YGNodeNew(); + const YGNodeRef root_child1_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child3, 25); YGNodeStyleSetHeight(root_child1_child3, 10); YGNodeInsertChild(root_child1, root_child1_child3, 3); @@ -392,44 +418,48 @@ TEST(YogaTest, align_baseline_child_multiline) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child3)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_baseline_child_multiline_override) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignBaseline); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root_child1, YGFlexDirectionRow); YGNodeStyleSetFlexWrap(root_child1, YGWrapWrap); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 25); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child1_child0 = YGNodeNew(); + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child0, 25); YGNodeStyleSetHeight(root_child1_child0, 20); YGNodeInsertChild(root_child1, root_child1_child0, 0); - const YGNodeRef root_child1_child1 = YGNodeNew(); + const YGNodeRef root_child1_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignSelf(root_child1_child1, YGAlignBaseline); YGNodeStyleSetWidth(root_child1_child1, 25); YGNodeStyleSetHeight(root_child1_child1, 10); YGNodeInsertChild(root_child1, root_child1_child1, 1); - const YGNodeRef root_child1_child2 = YGNodeNew(); + const YGNodeRef root_child1_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child2, 25); YGNodeStyleSetHeight(root_child1_child2, 20); YGNodeInsertChild(root_child1, root_child1_child2, 2); - const YGNodeRef root_child1_child3 = YGNodeNew(); + const YGNodeRef root_child1_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignSelf(root_child1_child3, YGAlignBaseline); YGNodeStyleSetWidth(root_child1_child3, 25); YGNodeStyleSetHeight(root_child1_child3, 10); @@ -509,43 +539,47 @@ TEST(YogaTest, align_baseline_child_multiline_override) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child3)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_baseline_child_multiline_no_override_on_secondline) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignBaseline); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root_child1, YGFlexDirectionRow); YGNodeStyleSetFlexWrap(root_child1, YGWrapWrap); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 25); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child1_child0 = YGNodeNew(); + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child0, 25); YGNodeStyleSetHeight(root_child1_child0, 20); YGNodeInsertChild(root_child1, root_child1_child0, 0); - const YGNodeRef root_child1_child1 = YGNodeNew(); + const YGNodeRef root_child1_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child1, 25); YGNodeStyleSetHeight(root_child1_child1, 10); YGNodeInsertChild(root_child1, root_child1_child1, 1); - const YGNodeRef root_child1_child2 = YGNodeNew(); + const YGNodeRef root_child1_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child2, 25); YGNodeStyleSetHeight(root_child1_child2, 20); YGNodeInsertChild(root_child1, root_child1_child2, 2); - const YGNodeRef root_child1_child3 = YGNodeNew(); + const YGNodeRef root_child1_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignSelf(root_child1_child3, YGAlignBaseline); YGNodeStyleSetWidth(root_child1_child3, 25); YGNodeStyleSetHeight(root_child1_child3, 10); @@ -625,27 +659,31 @@ TEST(YogaTest, align_baseline_child_multiline_no_override_on_secondline) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child3)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_baseline_child_top) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignBaseline); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child1_child0 = YGNodeNew(); + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child0, 50); YGNodeStyleSetHeight(root_child1_child0, 10); YGNodeInsertChild(root_child1, root_child1_child0, 0); @@ -694,27 +732,31 @@ TEST(YogaTest, align_baseline_child_top) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_baseline_child_top2) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignBaseline); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetPosition(root_child1, YGEdgeTop, 5); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child1_child0 = YGNodeNew(); + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child0, 50); YGNodeStyleSetHeight(root_child1_child0, 10); YGNodeInsertChild(root_child1, root_child1_child0, 0); @@ -763,31 +805,35 @@ TEST(YogaTest, align_baseline_child_top2) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_baseline_double_nested_child) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignBaseline); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0_child0, 50); YGNodeStyleSetHeight(root_child0_child0, 20); YGNodeInsertChild(root_child0, root_child0_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child1_child0 = YGNodeNew(); + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child0, 50); YGNodeStyleSetHeight(root_child1_child0, 15); YGNodeInsertChild(root_child1, root_child1_child0, 0); @@ -846,20 +892,24 @@ TEST(YogaTest, align_baseline_double_nested_child) { ASSERT_FLOAT_EQ(15, YGNodeLayoutGetHeight(root_child1_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_baseline_column) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignBaseline); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); @@ -898,16 +948,20 @@ TEST(YogaTest, align_baseline_column) { ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_baseline_child_margin) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignBaseline); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 5); YGNodeStyleSetMargin(root_child0, YGEdgeTop, 5); YGNodeStyleSetMargin(root_child0, YGEdgeRight, 5); @@ -916,12 +970,12 @@ TEST(YogaTest, align_baseline_child_margin) { YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child1_child0 = YGNodeNew(); + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMargin(root_child1_child0, YGEdgeLeft, 1); YGNodeStyleSetMargin(root_child1_child0, YGEdgeTop, 1); YGNodeStyleSetMargin(root_child1_child0, YGEdgeRight, 1); @@ -974,10 +1028,14 @@ TEST(YogaTest, align_baseline_child_margin) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_baseline_child_padding) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignBaseline); YGNodeStyleSetPadding(root, YGEdgeLeft, 5); @@ -987,12 +1045,12 @@ TEST(YogaTest, align_baseline_child_padding) { YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetPadding(root_child1, YGEdgeLeft, 5); YGNodeStyleSetPadding(root_child1, YGEdgeTop, 5); YGNodeStyleSetPadding(root_child1, YGEdgeRight, 5); @@ -1001,7 +1059,7 @@ TEST(YogaTest, align_baseline_child_padding) { YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child1_child0 = YGNodeNew(); + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child0, 50); YGNodeStyleSetHeight(root_child1_child0, 10); YGNodeInsertChild(root_child1, root_child1_child0, 0); @@ -1050,42 +1108,46 @@ TEST(YogaTest, align_baseline_child_padding) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_baseline_multiline) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignBaseline); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child1_child0 = YGNodeNew(); + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child0, 50); YGNodeStyleSetHeight(root_child1_child0, 10); YGNodeInsertChild(root_child1, root_child1_child0, 0); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeStyleSetHeight(root_child2, 20); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child2_child0 = YGNodeNew(); + const YGNodeRef root_child2_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2_child0, 50); YGNodeStyleSetHeight(root_child2_child0, 10); YGNodeInsertChild(root_child2, root_child2_child0, 0); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 50); YGNodeStyleSetHeight(root_child3, 50); YGNodeInsertChild(root, root_child3, 3); @@ -1164,41 +1226,45 @@ TEST(YogaTest, align_baseline_multiline) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child3)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_baseline_multiline_column) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignBaseline); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 30); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child1_child0 = YGNodeNew(); + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child0, 20); YGNodeStyleSetHeight(root_child1_child0, 20); YGNodeInsertChild(root_child1, root_child1_child0, 0); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 40); YGNodeStyleSetHeight(root_child2, 70); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child2_child0 = YGNodeNew(); + const YGNodeRef root_child2_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2_child0, 10); YGNodeStyleSetHeight(root_child2_child0, 10); YGNodeInsertChild(root_child2, root_child2_child0, 0); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 50); YGNodeStyleSetHeight(root_child3, 20); YGNodeInsertChild(root, root_child3, 3); @@ -1277,41 +1343,45 @@ TEST(YogaTest, align_baseline_multiline_column) { ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child3)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_baseline_multiline_column2) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignBaseline); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 30); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child1_child0 = YGNodeNew(); + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child0, 20); YGNodeStyleSetHeight(root_child1_child0, 20); YGNodeInsertChild(root_child1, root_child1_child0, 0); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 40); YGNodeStyleSetHeight(root_child2, 70); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child2_child0 = YGNodeNew(); + const YGNodeRef root_child2_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2_child0, 10); YGNodeStyleSetHeight(root_child2_child0, 10); YGNodeInsertChild(root_child2, root_child2_child0, 0); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 50); YGNodeStyleSetHeight(root_child3, 20); YGNodeInsertChild(root, root_child3, 3); @@ -1390,42 +1460,46 @@ TEST(YogaTest, align_baseline_multiline_column2) { ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child3)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_baseline_multiline_row_and_column) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignBaseline); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child1_child0 = YGNodeNew(); + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child0, 50); YGNodeStyleSetHeight(root_child1_child0, 10); YGNodeInsertChild(root_child1, root_child1_child0, 0); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeStyleSetHeight(root_child2, 20); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child2_child0 = YGNodeNew(); + const YGNodeRef root_child2_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2_child0, 50); YGNodeStyleSetHeight(root_child2_child0, 10); YGNodeInsertChild(root_child2, root_child2_child0, 0); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 50); YGNodeStyleSetHeight(root_child3, 20); YGNodeInsertChild(root, root_child3, 3); @@ -1504,4 +1578,6 @@ TEST(YogaTest, align_baseline_multiline_row_and_column) { ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child3)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } diff --git a/tests/YGAlignSelfTest.cpp b/tests/YGAlignSelfTest.cpp index 1b8b33ae..cff62603 100644 --- a/tests/YGAlignSelfTest.cpp +++ b/tests/YGAlignSelfTest.cpp @@ -13,11 +13,13 @@ #include TEST(YogaTest, align_self_center) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignSelf(root_child0, YGAlignCenter); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); @@ -47,14 +49,18 @@ TEST(YogaTest, align_self_center) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_self_flex_end) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); @@ -84,14 +90,18 @@ TEST(YogaTest, align_self_flex_end) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_self_flex_start) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexStart); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); @@ -121,15 +131,19 @@ TEST(YogaTest, align_self_flex_start) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_self_flex_end_override_flex_start) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); @@ -159,27 +173,31 @@ TEST(YogaTest, align_self_flex_end_override_flex_start) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_self_baseline) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignSelf(root_child0, YGAlignBaseline); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignSelf(root_child1, YGAlignBaseline); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child1_child0 = YGNodeNew(); + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child0, 50); YGNodeStyleSetHeight(root_child1_child0, 10); YGNodeInsertChild(root_child1, root_child1_child0, 0); @@ -228,4 +246,6 @@ TEST(YogaTest, align_self_baseline) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } diff --git a/tests/YGBorderTest.cpp b/tests/YGBorderTest.cpp index 27b84003..44740305 100644 --- a/tests/YGBorderTest.cpp +++ b/tests/YGBorderTest.cpp @@ -13,7 +13,9 @@ #include TEST(YogaTest, border_no_size) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetBorder(root, YGEdgeLeft, 10); YGNodeStyleSetBorder(root, YGEdgeTop, 10); YGNodeStyleSetBorder(root, YGEdgeRight, 10); @@ -33,16 +35,20 @@ TEST(YogaTest, border_no_size) { ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, border_container_match_child) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetBorder(root, YGEdgeLeft, 10); YGNodeStyleSetBorder(root, YGEdgeTop, 10); YGNodeStyleSetBorder(root, YGEdgeRight, 10); YGNodeStyleSetBorder(root, YGEdgeBottom, 10); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); @@ -71,10 +77,14 @@ TEST(YogaTest, border_container_match_child) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, border_flex_child) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetBorder(root, YGEdgeLeft, 10); YGNodeStyleSetBorder(root, YGEdgeTop, 10); YGNodeStyleSetBorder(root, YGEdgeRight, 10); @@ -82,7 +92,7 @@ TEST(YogaTest, border_flex_child) { YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); @@ -111,10 +121,14 @@ TEST(YogaTest, border_flex_child) { ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, border_stretch_child) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetBorder(root, YGEdgeLeft, 10); YGNodeStyleSetBorder(root, YGEdgeTop, 10); YGNodeStyleSetBorder(root, YGEdgeRight, 10); @@ -122,7 +136,7 @@ TEST(YogaTest, border_stretch_child) { YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -150,10 +164,14 @@ TEST(YogaTest, border_stretch_child) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, border_center_child) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetBorder(root, YGEdgeStart, 10); @@ -162,7 +180,7 @@ TEST(YogaTest, border_center_child) { YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); @@ -191,4 +209,6 @@ TEST(YogaTest, border_center_child) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } diff --git a/tests/YGDimensionTest.cpp b/tests/YGDimensionTest.cpp index 53a47347..9944548d 100644 --- a/tests/YGDimensionTest.cpp +++ b/tests/YGDimensionTest.cpp @@ -13,9 +13,11 @@ #include TEST(YogaTest, wrap_child) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 100); YGNodeStyleSetHeight(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); @@ -44,15 +46,19 @@ TEST(YogaTest, wrap_child) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, wrap_grandchild) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0_child0, 100); YGNodeStyleSetHeight(root_child0_child0, 100); YGNodeInsertChild(root_child0, root_child0_child0, 0); @@ -91,4 +97,6 @@ TEST(YogaTest, wrap_grandchild) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } diff --git a/tests/YGDisplayTest.cpp b/tests/YGDisplayTest.cpp index 651dfa82..cc0e4550 100644 --- a/tests/YGDisplayTest.cpp +++ b/tests/YGDisplayTest.cpp @@ -13,16 +13,18 @@ #include TEST(YogaTest, display_none) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeStyleSetDisplay(root_child1, YGDisplayNone); YGNodeInsertChild(root, root_child1, 1); @@ -61,19 +63,23 @@ TEST(YogaTest, display_none) { ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, display_none_fixed_size) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 20); YGNodeStyleSetHeight(root_child1, 20); YGNodeStyleSetDisplay(root_child1, YGDisplayNone); @@ -113,15 +119,19 @@ TEST(YogaTest, display_none_fixed_size) { ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, display_none_with_margin) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 10); YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); YGNodeStyleSetMargin(root_child0, YGEdgeRight, 10); @@ -131,7 +141,7 @@ TEST(YogaTest, display_none_with_margin) { YGNodeStyleSetDisplay(root_child0, YGDisplayNone); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -169,28 +179,32 @@ TEST(YogaTest, display_none_with_margin) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, display_none_with_child) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexShrink(root_child0, 1); YGNodeStyleSetFlexBasisPercent(root_child0, 0); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeStyleSetFlexShrink(root_child1, 1); YGNodeStyleSetFlexBasisPercent(root_child1, 0); YGNodeStyleSetDisplay(root_child1, YGDisplayNone); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child1_child0 = YGNodeNew(); + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1_child0, 1); YGNodeStyleSetFlexShrink(root_child1_child0, 1); YGNodeStyleSetFlexBasisPercent(root_child1_child0, 0); @@ -199,7 +213,7 @@ TEST(YogaTest, display_none_with_child) { YGNodeStyleSetMinHeight(root_child1_child0, 0); YGNodeInsertChild(root_child1, root_child1_child0, 0); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child2, 1); YGNodeStyleSetFlexShrink(root_child2, 1); YGNodeStyleSetFlexBasisPercent(root_child2, 0); @@ -259,19 +273,23 @@ TEST(YogaTest, display_none_with_child) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, display_none_with_position) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeStyleSetPosition(root_child1, YGEdgeTop, 10); YGNodeStyleSetDisplay(root_child1, YGDisplayNone); @@ -311,4 +329,6 @@ TEST(YogaTest, display_none_with_position) { ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } diff --git a/tests/YGFlexDirectionTest.cpp b/tests/YGFlexDirectionTest.cpp index e467d27c..72ec9676 100644 --- a/tests/YGFlexDirectionTest.cpp +++ b/tests/YGFlexDirectionTest.cpp @@ -13,18 +13,20 @@ #include TEST(YogaTest, flex_direction_column_no_height) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -72,22 +74,26 @@ TEST(YogaTest, flex_direction_column_no_height) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_direction_row_no_width) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -135,22 +141,26 @@ TEST(YogaTest, flex_direction_row_no_width) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_direction_column) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -198,23 +208,27 @@ TEST(YogaTest, flex_direction_column) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_direction_row) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -262,23 +276,27 @@ TEST(YogaTest, flex_direction_row) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_direction_column_reverse) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumnReverse); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -326,23 +344,27 @@ TEST(YogaTest, flex_direction_column_reverse) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_direction_row_reverse) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -390,4 +412,6 @@ TEST(YogaTest, flex_direction_row_reverse) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } diff --git a/tests/YGFlexTest.cpp b/tests/YGFlexTest.cpp index ad8cc615..825de3a2 100644 --- a/tests/YGFlexTest.cpp +++ b/tests/YGFlexTest.cpp @@ -13,16 +13,18 @@ #include TEST(YogaTest, flex_basis_flex_grow_column) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexBasis(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -60,20 +62,24 @@ TEST(YogaTest, flex_basis_flex_grow_column) { ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_basis_flex_grow_row) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexBasis(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -111,19 +117,23 @@ TEST(YogaTest, flex_basis_flex_grow_row) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_basis_flex_shrink_column) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexShrink(root_child0, 1); YGNodeStyleSetFlexBasis(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexBasis(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -161,20 +171,24 @@ TEST(YogaTest, flex_basis_flex_shrink_column) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_basis_flex_shrink_row) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexShrink(root_child0, 1); YGNodeStyleSetFlexBasis(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexBasis(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -212,24 +226,28 @@ TEST(YogaTest, flex_basis_flex_shrink_row) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_shrink_to_zero) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root, 75); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexShrink(root_child1, 1); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeStyleSetHeight(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); @@ -278,25 +296,29 @@ TEST(YogaTest, flex_shrink_to_zero) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_basis_overrides_main_size) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexBasis(root_child0, 50); YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child2, 1); YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); @@ -345,17 +367,21 @@ TEST(YogaTest, flex_basis_overrides_main_size) { ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_grow_shrink_at_most) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0_child0, 1); YGNodeStyleSetFlexShrink(root_child0_child0, 1); YGNodeInsertChild(root_child0, root_child0_child0, 0); @@ -394,4 +420,6 @@ TEST(YogaTest, flex_grow_shrink_at_most) { ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } diff --git a/tests/YGFlexWrapTest.cpp b/tests/YGFlexWrapTest.cpp index 36ed6697..8627b5d5 100644 --- a/tests/YGFlexWrapTest.cpp +++ b/tests/YGFlexWrapTest.cpp @@ -13,26 +13,28 @@ #include TEST(YogaTest, wrap_column) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 30); YGNodeStyleSetHeight(root_child0, 30); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 30); YGNodeStyleSetHeight(root_child1, 30); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 30); YGNodeStyleSetHeight(root_child2, 30); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 30); YGNodeStyleSetHeight(root_child3, 30); YGNodeInsertChild(root, root_child3, 3); @@ -91,30 +93,34 @@ TEST(YogaTest, wrap_column) { ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, wrap_row) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 30); YGNodeStyleSetHeight(root_child0, 30); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 30); YGNodeStyleSetHeight(root_child1, 30); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 30); YGNodeStyleSetHeight(root_child2, 30); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 30); YGNodeStyleSetHeight(root_child3, 30); YGNodeInsertChild(root, root_child3, 3); @@ -173,31 +179,35 @@ TEST(YogaTest, wrap_row) { ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, wrap_row_align_items_flex_end) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 30); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 30); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 30); YGNodeStyleSetHeight(root_child2, 30); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 30); YGNodeStyleSetHeight(root_child3, 30); YGNodeInsertChild(root, root_child3, 3); @@ -256,31 +266,35 @@ TEST(YogaTest, wrap_row_align_items_flex_end) { ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, wrap_row_align_items_center) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 30); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 30); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 30); YGNodeStyleSetHeight(root_child2, 30); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 30); YGNodeStyleSetHeight(root_child3, 30); YGNodeInsertChild(root, root_child3, 3); @@ -339,21 +353,25 @@ TEST(YogaTest, wrap_row_align_items_center) { ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_wrap_children_with_min_main_overriding_flex_basis) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexBasis(root_child0, 50); YGNodeStyleSetMinWidth(root_child0, 55); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexBasis(root_child1, 50); YGNodeStyleSetMinWidth(root_child1, 55); YGNodeStyleSetHeight(root_child1, 50); @@ -393,27 +411,31 @@ TEST(YogaTest, flex_wrap_children_with_min_main_overriding_flex_basis) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_wrap_wrap_to_child_height) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root_child0, YGAlignFlexStart); YGNodeStyleSetFlexWrap(root_child0, YGWrapWrap); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0_child0, 100); YGNodeInsertChild(root_child0, root_child0_child0, 0); - const YGNodeRef root_child0_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0_child0_child0, 100); YGNodeStyleSetHeight(root_child0_child0_child0, 100); YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 100); YGNodeStyleSetHeight(root_child1, 100); YGNodeInsertChild(root, root_child1, 1); @@ -472,20 +494,24 @@ TEST(YogaTest, flex_wrap_wrap_to_child_height) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_wrap_align_stretch_fits_one_row) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetFlexWrap(root, YGWrapWrap); YGNodeStyleSetWidth(root, 150); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -523,35 +549,39 @@ TEST(YogaTest, flex_wrap_align_stretch_fits_one_row) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, wrap_reverse_row_align_content_flex_start) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetFlexWrap(root, YGWrapWrapReverse); YGNodeStyleSetWidth(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 30); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 30); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 30); YGNodeStyleSetHeight(root_child2, 30); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 30); YGNodeStyleSetHeight(root_child3, 40); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 30); YGNodeStyleSetHeight(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); @@ -620,36 +650,40 @@ TEST(YogaTest, wrap_reverse_row_align_content_flex_start) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, wrap_reverse_row_align_content_center) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignContent(root, YGAlignCenter); YGNodeStyleSetFlexWrap(root, YGWrapWrapReverse); YGNodeStyleSetWidth(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 30); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 30); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 30); YGNodeStyleSetHeight(root_child2, 30); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 30); YGNodeStyleSetHeight(root_child3, 40); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 30); YGNodeStyleSetHeight(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); @@ -718,35 +752,39 @@ TEST(YogaTest, wrap_reverse_row_align_content_center) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, wrap_reverse_row_single_line_different_size) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetFlexWrap(root, YGWrapWrapReverse); YGNodeStyleSetWidth(root, 300); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 30); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 30); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 30); YGNodeStyleSetHeight(root_child2, 30); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 30); YGNodeStyleSetHeight(root_child3, 40); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 30); YGNodeStyleSetHeight(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); @@ -815,36 +853,40 @@ TEST(YogaTest, wrap_reverse_row_single_line_different_size) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, wrap_reverse_row_align_content_stretch) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignContent(root, YGAlignStretch); YGNodeStyleSetFlexWrap(root, YGWrapWrapReverse); YGNodeStyleSetWidth(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 30); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 30); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 30); YGNodeStyleSetHeight(root_child2, 30); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 30); YGNodeStyleSetHeight(root_child3, 40); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 30); YGNodeStyleSetHeight(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); @@ -913,36 +955,40 @@ TEST(YogaTest, wrap_reverse_row_align_content_stretch) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, wrap_reverse_row_align_content_space_around) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignContent(root, YGAlignSpaceAround); YGNodeStyleSetFlexWrap(root, YGWrapWrapReverse); YGNodeStyleSetWidth(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 30); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 30); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 30); YGNodeStyleSetHeight(root_child2, 30); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 30); YGNodeStyleSetHeight(root_child3, 40); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 30); YGNodeStyleSetHeight(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); @@ -1011,36 +1057,40 @@ TEST(YogaTest, wrap_reverse_row_align_content_space_around) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, wrap_reverse_column_fixed_size) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetFlexWrap(root, YGWrapWrapReverse); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 30); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 30); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 30); YGNodeStyleSetHeight(root_child2, 30); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child3, 30); YGNodeStyleSetHeight(root_child3, 40); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child4, 30); YGNodeStyleSetHeight(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); @@ -1109,25 +1159,29 @@ TEST(YogaTest, wrap_reverse_column_fixed_size) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, wrapped_row_within_align_items_center) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); YGNodeStyleSetFlexWrap(root_child0, YGWrapWrap); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0_child0, 150); YGNodeStyleSetHeight(root_child0_child0, 80); YGNodeInsertChild(root_child0, root_child0_child0, 0); - const YGNodeRef root_child0_child1 = YGNodeNew(); + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0_child1, 80); YGNodeStyleSetHeight(root_child0_child1, 80); YGNodeInsertChild(root_child0, root_child0_child1, 1); @@ -1176,25 +1230,29 @@ TEST(YogaTest, wrapped_row_within_align_items_center) { ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, wrapped_row_within_align_items_flex_start) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); YGNodeStyleSetFlexWrap(root_child0, YGWrapWrap); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0_child0, 150); YGNodeStyleSetHeight(root_child0_child0, 80); YGNodeInsertChild(root_child0, root_child0_child0, 0); - const YGNodeRef root_child0_child1 = YGNodeNew(); + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0_child1, 80); YGNodeStyleSetHeight(root_child0_child1, 80); YGNodeInsertChild(root_child0, root_child0_child1, 1); @@ -1243,25 +1301,29 @@ TEST(YogaTest, wrapped_row_within_align_items_flex_start) { ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, wrapped_row_within_align_items_flex_end) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); YGNodeStyleSetFlexWrap(root_child0, YGWrapWrap); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0_child0, 150); YGNodeStyleSetHeight(root_child0_child0, 80); YGNodeInsertChild(root_child0, root_child0_child0, 0); - const YGNodeRef root_child0_child1 = YGNodeNew(); + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0_child1, 80); YGNodeStyleSetHeight(root_child0_child1, 80); YGNodeInsertChild(root_child0, root_child0_child1, 1); @@ -1310,4 +1372,6 @@ TEST(YogaTest, wrapped_row_within_align_items_flex_end) { ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } diff --git a/tests/YGJustifyContentTest.cpp b/tests/YGJustifyContentTest.cpp index 78e6f44f..98bf24a5 100644 --- a/tests/YGJustifyContentTest.cpp +++ b/tests/YGJustifyContentTest.cpp @@ -13,20 +13,22 @@ #include TEST(YogaTest, justify_content_row_flex_start) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 102); YGNodeStyleSetHeight(root, 102); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -74,24 +76,28 @@ TEST(YogaTest, justify_content_row_flex_start) { ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, justify_content_row_flex_end) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); YGNodeStyleSetWidth(root, 102); YGNodeStyleSetHeight(root, 102); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -139,24 +145,28 @@ TEST(YogaTest, justify_content_row_flex_end) { ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, justify_content_row_center) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetWidth(root, 102); YGNodeStyleSetHeight(root, 102); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -204,24 +214,28 @@ TEST(YogaTest, justify_content_row_center) { ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, justify_content_row_space_between) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); YGNodeStyleSetWidth(root, 102); YGNodeStyleSetHeight(root, 102); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -269,24 +283,28 @@ TEST(YogaTest, justify_content_row_space_between) { ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, justify_content_row_space_around) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround); YGNodeStyleSetWidth(root, 102); YGNodeStyleSetHeight(root, 102); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -334,21 +352,25 @@ TEST(YogaTest, justify_content_row_space_around) { ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, justify_content_column_flex_start) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 102); YGNodeStyleSetHeight(root, 102); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -396,23 +418,27 @@ TEST(YogaTest, justify_content_column_flex_start) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, justify_content_column_flex_end) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); YGNodeStyleSetWidth(root, 102); YGNodeStyleSetHeight(root, 102); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -460,23 +486,27 @@ TEST(YogaTest, justify_content_column_flex_end) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, justify_content_column_center) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetWidth(root, 102); YGNodeStyleSetHeight(root, 102); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -524,23 +554,27 @@ TEST(YogaTest, justify_content_column_center) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, justify_content_column_space_between) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); YGNodeStyleSetWidth(root, 102); YGNodeStyleSetHeight(root, 102); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -588,23 +622,27 @@ TEST(YogaTest, justify_content_column_space_between) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, justify_content_column_space_around) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround); YGNodeStyleSetWidth(root, 102); YGNodeStyleSetHeight(root, 102); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -652,4 +690,6 @@ TEST(YogaTest, justify_content_column_space_around) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } diff --git a/tests/YGMarginTest.cpp b/tests/YGMarginTest.cpp index ccb1ce70..e6570c37 100644 --- a/tests/YGMarginTest.cpp +++ b/tests/YGMarginTest.cpp @@ -13,12 +13,14 @@ #include TEST(YogaTest, margin_start) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); @@ -47,14 +49,18 @@ TEST(YogaTest, margin_start) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_top) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); @@ -83,16 +89,20 @@ TEST(YogaTest, margin_top) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_end) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMargin(root_child0, YGEdgeEnd, 10); YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); @@ -121,15 +131,19 @@ TEST(YogaTest, margin_end) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_bottom) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); @@ -158,15 +172,19 @@ TEST(YogaTest, margin_bottom) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_and_flex_row) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); YGNodeStyleSetMargin(root_child0, YGEdgeEnd, 10); @@ -196,14 +214,18 @@ TEST(YogaTest, margin_and_flex_row) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_and_flex_column) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10); @@ -233,15 +255,19 @@ TEST(YogaTest, margin_and_flex_column) { ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_and_stretch_row) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10); @@ -271,14 +297,18 @@ TEST(YogaTest, margin_and_stretch_row) { ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_and_stretch_column) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); YGNodeStyleSetMargin(root_child0, YGEdgeEnd, 10); @@ -308,20 +338,24 @@ TEST(YogaTest, margin_and_stretch_column) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_with_sibling_row) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetMargin(root_child0, YGEdgeEnd, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -359,19 +393,23 @@ TEST(YogaTest, margin_with_sibling_row) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_with_sibling_column) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -409,21 +447,25 @@ TEST(YogaTest, margin_with_sibling_column) { ASSERT_FLOAT_EQ(45, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_auto_bottom) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMarginAuto(root_child0, YGEdgeBottom); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); @@ -462,21 +504,25 @@ TEST(YogaTest, margin_auto_bottom) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_auto_top) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMarginAuto(root_child0, YGEdgeTop); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); @@ -515,22 +561,26 @@ TEST(YogaTest, margin_auto_top) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_auto_bottom_and_top) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMarginAuto(root_child0, YGEdgeTop); YGNodeStyleSetMarginAuto(root_child0, YGEdgeBottom); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); @@ -569,22 +619,26 @@ TEST(YogaTest, margin_auto_bottom_and_top) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_auto_bottom_and_top_justify_center) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMarginAuto(root_child0, YGEdgeTop); YGNodeStyleSetMarginAuto(root_child0, YGEdgeBottom); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); @@ -623,27 +677,31 @@ TEST(YogaTest, margin_auto_bottom_and_top_justify_center) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_auto_mutiple_children_column) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMarginAuto(root_child0, YGEdgeTop); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetMarginAuto(root_child1, YGEdgeTop); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeStyleSetHeight(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); @@ -692,28 +750,32 @@ TEST(YogaTest, margin_auto_mutiple_children_column) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_auto_mutiple_children_row) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMarginAuto(root_child0, YGEdgeRight); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetMarginAuto(root_child1, YGEdgeRight); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeStyleSetHeight(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); @@ -762,23 +824,27 @@ TEST(YogaTest, margin_auto_mutiple_children_row) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_auto_left_and_right_column) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft); YGNodeStyleSetMarginAuto(root_child0, YGEdgeRight); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); @@ -817,21 +883,25 @@ TEST(YogaTest, margin_auto_left_and_right_column) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_auto_left_and_right) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft); YGNodeStyleSetMarginAuto(root_child0, YGEdgeRight); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); @@ -870,6 +940,8 @@ TEST(YogaTest, margin_auto_left_and_right) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_auto_start_and_end_column) { @@ -981,19 +1053,21 @@ TEST(YogaTest, margin_auto_start_and_end) { } TEST(YogaTest, margin_auto_left_and_right_column_and_center) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft); YGNodeStyleSetMarginAuto(root_child0, YGEdgeRight); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); @@ -1032,21 +1106,25 @@ TEST(YogaTest, margin_auto_left_and_right_column_and_center) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_auto_left) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); @@ -1085,21 +1163,25 @@ TEST(YogaTest, margin_auto_left) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_auto_right) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMarginAuto(root_child0, YGEdgeRight); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); @@ -1138,22 +1220,26 @@ TEST(YogaTest, margin_auto_right) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_auto_left_and_right_strech) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft); YGNodeStyleSetMarginAuto(root_child0, YGEdgeRight); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); @@ -1192,21 +1278,25 @@ TEST(YogaTest, margin_auto_left_and_right_strech) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, margin_auto_top_and_bottom_strech) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMarginAuto(root_child0, YGEdgeTop); YGNodeStyleSetMarginAuto(root_child0, YGEdgeBottom); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); @@ -1245,4 +1335,6 @@ TEST(YogaTest, margin_auto_top_and_bottom_strech) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } diff --git a/tests/YGMinMaxDimensionTest.cpp b/tests/YGMinMaxDimensionTest.cpp index 0d246789..bd719d85 100644 --- a/tests/YGMinMaxDimensionTest.cpp +++ b/tests/YGMinMaxDimensionTest.cpp @@ -13,11 +13,13 @@ #include TEST(YogaTest, max_width) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMaxWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); @@ -46,15 +48,19 @@ TEST(YogaTest, max_width) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, max_height) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetMaxHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); @@ -83,19 +89,23 @@ TEST(YogaTest, max_height) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, min_height) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetMinHeight(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -133,20 +143,24 @@ TEST(YogaTest, min_height) { ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, min_width) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetMinWidth(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -184,16 +198,20 @@ TEST(YogaTest, min_width) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, justify_content_min_max) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetMinHeight(root, 100); YGNodeStyleSetMaxHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 60); YGNodeStyleSetHeight(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); @@ -222,16 +240,20 @@ TEST(YogaTest, justify_content_min_max) { ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, align_items_min_max) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetMinWidth(root, 100); YGNodeStyleSetMaxWidth(root, 200); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 60); YGNodeStyleSetHeight(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); @@ -260,25 +282,29 @@ TEST(YogaTest, align_items_min_max) { ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, justify_content_overflow_min_max) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetMinHeight(root, 100); YGNodeStyleSetMaxHeight(root, 110); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 50); YGNodeStyleSetHeight(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); @@ -327,22 +353,25 @@ TEST(YogaTest, justify_content_overflow_min_max) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_grow_to_min) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureMinFlexFix, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinFlexFix, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetMinHeight(root, 100); YGNodeStyleSetMaxHeight(root, 500); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexShrink(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -381,23 +410,24 @@ TEST(YogaTest, flex_grow_to_min) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureMinFlexFix, false); + YGConfigFree(config); } TEST(YogaTest, flex_grow_in_at_most_container) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureMinFlexFix, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinFlexFix, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0_child0, 1); YGNodeStyleSetFlexBasis(root_child0_child0, 0); YGNodeInsertChild(root_child0, root_child0_child0, 0); @@ -437,20 +467,22 @@ TEST(YogaTest, flex_grow_in_at_most_container) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureMinFlexFix, false); + YGConfigFree(config); } TEST(YogaTest, flex_grow_within_max_width) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); YGNodeStyleSetMaxWidth(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0_child0, 1); YGNodeStyleSetHeight(root_child0_child0, 20); YGNodeInsertChild(root_child0, root_child0_child0, 0); @@ -489,19 +521,23 @@ TEST(YogaTest, flex_grow_within_max_width) { ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_grow_within_constrained_max_width) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); YGNodeStyleSetMaxWidth(root_child0, 300); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0_child0, 1); YGNodeStyleSetHeight(root_child0_child0, 20); YGNodeInsertChild(root_child0, root_child0_child0, 0); @@ -540,19 +576,23 @@ TEST(YogaTest, flex_grow_within_constrained_max_width) { ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_grow_within_constrained_min_row) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetMinWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -590,17 +630,21 @@ TEST(YogaTest, flex_grow_within_constrained_min_row) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_grow_within_constrained_min_column) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetMinHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -638,24 +682,28 @@ TEST(YogaTest, flex_grow_within_constrained_min_column) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_grow_within_constrained_max_row) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); YGNodeStyleSetMaxWidth(root_child0, 100); YGNodeStyleSetHeight(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexShrink(root_child0_child0, 1); YGNodeStyleSetFlexBasis(root_child0_child0, 100); YGNodeInsertChild(root_child0, root_child0_child0, 0); - const YGNodeRef root_child0_child1 = YGNodeNew(); + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0_child1, 50); YGNodeInsertChild(root_child0, root_child0_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -703,19 +751,23 @@ TEST(YogaTest, flex_grow_within_constrained_max_row) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, flex_grow_within_constrained_max_column) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetMaxHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexShrink(root_child0, 1); YGNodeStyleSetFlexBasis(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -753,10 +805,14 @@ TEST(YogaTest, flex_grow_within_constrained_max_column) { ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, min_width_overrides_width) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 50); YGNodeStyleSetMinWidth(root, 100); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -774,10 +830,14 @@ TEST(YogaTest, min_width_overrides_width) { ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, max_width_overrides_width) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetMaxWidth(root, 100); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -795,10 +855,14 @@ TEST(YogaTest, max_width_overrides_width) { ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, min_height_overrides_height) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root, 50); YGNodeStyleSetMinHeight(root, 100); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -816,10 +880,14 @@ TEST(YogaTest, min_height_overrides_height) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, max_height_overrides_height) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root, 200); YGNodeStyleSetMaxHeight(root, 100); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -837,15 +905,19 @@ TEST(YogaTest, max_height_overrides_height) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, min_max_percent_no_width_height) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMinWidthPercent(root_child0, 10); YGNodeStyleSetMaxWidthPercent(root_child0, 10); YGNodeStyleSetMinHeightPercent(root_child0, 10); @@ -876,4 +948,6 @@ TEST(YogaTest, min_max_percent_no_width_height) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } diff --git a/tests/YGPaddingTest.cpp b/tests/YGPaddingTest.cpp index ae4d3bd8..e8223315 100644 --- a/tests/YGPaddingTest.cpp +++ b/tests/YGPaddingTest.cpp @@ -13,7 +13,9 @@ #include TEST(YogaTest, padding_no_size) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetPadding(root, YGEdgeLeft, 10); YGNodeStyleSetPadding(root, YGEdgeTop, 10); YGNodeStyleSetPadding(root, YGEdgeRight, 10); @@ -33,16 +35,20 @@ TEST(YogaTest, padding_no_size) { ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, padding_container_match_child) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetPadding(root, YGEdgeLeft, 10); YGNodeStyleSetPadding(root, YGEdgeTop, 10); YGNodeStyleSetPadding(root, YGEdgeRight, 10); YGNodeStyleSetPadding(root, YGEdgeBottom, 10); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); @@ -71,10 +77,14 @@ TEST(YogaTest, padding_container_match_child) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, padding_flex_child) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetPadding(root, YGEdgeLeft, 10); YGNodeStyleSetPadding(root, YGEdgeTop, 10); YGNodeStyleSetPadding(root, YGEdgeRight, 10); @@ -82,7 +92,7 @@ TEST(YogaTest, padding_flex_child) { YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); @@ -111,10 +121,14 @@ TEST(YogaTest, padding_flex_child) { ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, padding_stretch_child) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetPadding(root, YGEdgeLeft, 10); YGNodeStyleSetPadding(root, YGEdgeTop, 10); YGNodeStyleSetPadding(root, YGEdgeRight, 10); @@ -122,7 +136,7 @@ TEST(YogaTest, padding_stretch_child) { YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -150,10 +164,14 @@ TEST(YogaTest, padding_stretch_child) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, padding_center_child) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetPadding(root, YGEdgeStart, 10); @@ -162,7 +180,7 @@ TEST(YogaTest, padding_center_child) { YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); @@ -191,16 +209,20 @@ TEST(YogaTest, padding_center_child) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, child_with_padding_align_end) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 20); YGNodeStyleSetPadding(root_child0, YGEdgeTop, 20); YGNodeStyleSetPadding(root_child0, YGEdgeRight, 20); @@ -233,4 +255,6 @@ TEST(YogaTest, child_with_padding_align_end) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } diff --git a/tests/YGPercentageTest.cpp b/tests/YGPercentageTest.cpp index cbfb1e89..d4e5bf04 100644 --- a/tests/YGPercentageTest.cpp +++ b/tests/YGPercentageTest.cpp @@ -13,14 +13,15 @@ #include TEST(YogaTest, percentage_width_height) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidthPercent(root_child0, 30); YGNodeStyleSetHeightPercent(root_child0, 30); YGNodeInsertChild(root, root_child0, 0); @@ -50,18 +51,19 @@ TEST(YogaTest, percentage_width_height) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, percentage_position_left_top) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 400); YGNodeStyleSetHeight(root, 400); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionPercent(root_child0, YGEdgeLeft, 10); YGNodeStyleSetPositionPercent(root_child0, YGEdgeTop, 20); YGNodeStyleSetWidthPercent(root_child0, 45); @@ -93,18 +95,19 @@ TEST(YogaTest, percentage_position_left_top) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, percentage_position_bottom_right) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 500); YGNodeStyleSetHeight(root, 500); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionPercent(root_child0, YGEdgeRight, 20); YGNodeStyleSetPositionPercent(root_child0, YGEdgeBottom, 10); YGNodeStyleSetWidthPercent(root_child0, 55); @@ -136,23 +139,24 @@ TEST(YogaTest, percentage_position_bottom_right) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, percentage_flex_basis) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexBasisPercent(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeStyleSetFlexBasisPercent(root_child1, 25); YGNodeInsertChild(root, root_child1, 1); @@ -192,22 +196,23 @@ TEST(YogaTest, percentage_flex_basis) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, percentage_flex_basis_cross) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexBasisPercent(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeStyleSetFlexBasisPercent(root_child1, 25); YGNodeInsertChild(root, root_child1, 1); @@ -247,22 +252,23 @@ TEST(YogaTest, percentage_flex_basis_cross) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, percentage_flex_basis_cross_min_height) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetMinHeightPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 2); YGNodeStyleSetMinHeightPercent(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); @@ -302,24 +308,25 @@ TEST(YogaTest, percentage_flex_basis_cross_min_height) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, percentage_flex_basis_main_max_height) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexBasisPercent(root_child0, 10); YGNodeStyleSetMaxHeightPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 4); YGNodeStyleSetFlexBasisPercent(root_child1, 10); YGNodeStyleSetMaxHeightPercent(root_child1, 20); @@ -360,23 +367,24 @@ TEST(YogaTest, percentage_flex_basis_main_max_height) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, percentage_flex_basis_cross_max_height) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexBasisPercent(root_child0, 10); YGNodeStyleSetMaxHeightPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 4); YGNodeStyleSetFlexBasisPercent(root_child1, 10); YGNodeStyleSetMaxHeightPercent(root_child1, 20); @@ -417,24 +425,25 @@ TEST(YogaTest, percentage_flex_basis_cross_max_height) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, percentage_flex_basis_main_max_width) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexBasisPercent(root_child0, 15); YGNodeStyleSetMaxWidthPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 4); YGNodeStyleSetFlexBasisPercent(root_child1, 10); YGNodeStyleSetMaxWidthPercent(root_child1, 20); @@ -475,23 +484,24 @@ TEST(YogaTest, percentage_flex_basis_main_max_width) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, percentage_flex_basis_cross_max_width) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexBasisPercent(root_child0, 10); YGNodeStyleSetMaxWidthPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 4); YGNodeStyleSetFlexBasisPercent(root_child1, 15); YGNodeStyleSetMaxWidthPercent(root_child1, 20); @@ -532,24 +542,25 @@ TEST(YogaTest, percentage_flex_basis_cross_max_width) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, percentage_flex_basis_main_min_width) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexBasisPercent(root_child0, 15); YGNodeStyleSetMinWidthPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 4); YGNodeStyleSetFlexBasisPercent(root_child1, 10); YGNodeStyleSetMinWidthPercent(root_child1, 20); @@ -590,23 +601,24 @@ TEST(YogaTest, percentage_flex_basis_main_min_width) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, percentage_flex_basis_cross_min_width) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexBasisPercent(root_child0, 10); YGNodeStyleSetMinWidthPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 4); YGNodeStyleSetFlexBasisPercent(root_child1, 15); YGNodeStyleSetMinWidthPercent(root_child1, 20); @@ -647,17 +659,18 @@ TEST(YogaTest, percentage_flex_basis_cross_min_width) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_values) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexBasisPercent(root_child0, 10); YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 5); @@ -671,7 +684,7 @@ TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_val YGNodeStyleSetMinWidthPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMargin(root_child0_child0, YGEdgeLeft, 5); YGNodeStyleSetMargin(root_child0_child0, YGEdgeTop, 5); YGNodeStyleSetMargin(root_child0_child0, YGEdgeRight, 5); @@ -683,7 +696,7 @@ TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_val YGNodeStyleSetWidthPercent(root_child0_child0, 50); YGNodeInsertChild(root_child0, root_child0_child0, 0); - const YGNodeRef root_child0_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeLeft, 5); YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeTop, 5); YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeRight, 5); @@ -695,7 +708,7 @@ TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_val YGNodeStyleSetWidthPercent(root_child0_child0_child0, 45); YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 4); YGNodeStyleSetFlexBasisPercent(root_child1, 15); YGNodeStyleSetMinWidthPercent(root_child1, 20); @@ -756,17 +769,18 @@ TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_val YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, percentage_margin_should_calculate_based_only_on_width) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetMarginPercent(root_child0, YGEdgeLeft, 10); YGNodeStyleSetMarginPercent(root_child0, YGEdgeTop, 10); @@ -774,7 +788,7 @@ TEST(YogaTest, percentage_margin_should_calculate_based_only_on_width) { YGNodeStyleSetMarginPercent(root_child0, YGEdgeBottom, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0_child0, 10); YGNodeStyleSetHeight(root_child0_child0, 10); YGNodeInsertChild(root_child0, root_child0_child0, 0); @@ -814,17 +828,18 @@ TEST(YogaTest, percentage_margin_should_calculate_based_only_on_width) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, percentage_padding_should_calculate_based_only_on_width) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetPaddingPercent(root_child0, YGEdgeLeft, 10); YGNodeStyleSetPaddingPercent(root_child0, YGEdgeTop, 10); @@ -832,7 +847,7 @@ TEST(YogaTest, percentage_padding_should_calculate_based_only_on_width) { YGNodeStyleSetPaddingPercent(root_child0, YGEdgeBottom, 10); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0_child0, 10); YGNodeStyleSetHeight(root_child0_child0, 10); YGNodeInsertChild(root_child0, root_child0_child0, 0); @@ -872,17 +887,18 @@ TEST(YogaTest, percentage_padding_should_calculate_based_only_on_width) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, percentage_absolute_position) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); YGNodeStyleSetPositionPercent(root_child0, YGEdgeLeft, 30); YGNodeStyleSetPositionPercent(root_child0, YGEdgeTop, 10); @@ -915,13 +931,15 @@ TEST(YogaTest, percentage_absolute_position) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, percentage_width_height_undefined_parent_size) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidthPercent(root_child0, 50); YGNodeStyleSetHeightPercent(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); @@ -950,27 +968,31 @@ TEST(YogaTest, percentage_width_height_undefined_parent_size) { ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, percent_within_flex_grow) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 350); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child1_child0 = YGNodeNew(); + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidthPercent(root_child1_child0, 100); YGNodeInsertChild(root_child1, root_child1_child0, 0); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child2, 100); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -1028,4 +1050,6 @@ TEST(YogaTest, percent_within_flex_grow) { ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } diff --git a/tests/YGRelayoutTest.cpp b/tests/YGRelayoutTest.cpp index f0ea337f..7c13c518 100644 --- a/tests/YGRelayoutTest.cpp +++ b/tests/YGRelayoutTest.cpp @@ -11,13 +11,14 @@ #include TEST(YogaTest, dont_cache_computed_flex_basis_between_layouts) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureWebFlexBasis, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetHeightPercent(root, 100); YGNodeStyleSetWidthPercent(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexBasisPercent(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); @@ -28,7 +29,7 @@ TEST(YogaTest, dont_cache_computed_flex_basis_between_layouts) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, false); + YGConfigFree(config); } TEST(YogaTest, recalculate_resolvedDimonsion_onchange) { diff --git a/tests/YGRoundingMeasureFuncTest.cpp b/tests/YGRoundingMeasureFuncTest.cpp index 0e86cb26..78bc49f6 100644 --- a/tests/YGRoundingMeasureFuncTest.cpp +++ b/tests/YGRoundingMeasureFuncTest.cpp @@ -31,18 +31,19 @@ static YGSize _measureCeil(YGNodeRef node, } TEST(YogaTest, rounding_feature_with_custom_measure_func_floor) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeSetMeasureFunc(root_child0, _measureFloor); YGNodeInsertChild(root, root_child0, 0); YGSetPointScaleFactor(0.0); - + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - + ASSERT_FLOAT_EQ(10.2, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10.2, YGNodeLayoutGetHeight(root_child0)); @@ -52,40 +53,41 @@ TEST(YogaTest, rounding_feature_with_custom_measure_func_floor) { ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - + YGSetPointScaleFactor(2.0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - + YGSetPointScaleFactor(4.0); - + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - + ASSERT_FLOAT_EQ(10.25, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10.25, YGNodeLayoutGetHeight(root_child0)); YGSetPointScaleFactor(1.0 / 3.0); - + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - + ASSERT_FLOAT_EQ(9.0, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(9.0, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); YGSetPointScaleFactor(1.0); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, rounding_feature_with_custom_measure_func_ceil) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeSetMeasureFunc(root_child0, _measureCeil); YGNodeInsertChild(root, root_child0, 0); @@ -99,5 +101,5 @@ TEST(YogaTest, rounding_feature_with_custom_measure_func_ceil) { YGNodeFreeRecursive(root); YGSetPointScaleFactor(1.0); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } diff --git a/tests/YGRoundingTest.cpp b/tests/YGRoundingTest.cpp index 93d9f73a..93a80d50 100644 --- a/tests/YGRoundingTest.cpp +++ b/tests/YGRoundingTest.cpp @@ -13,22 +13,23 @@ #include TEST(YogaTest, rounding_flex_basis_flex_grow_row_width_of_100) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child2, 1); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -77,34 +78,35 @@ TEST(YogaTest, rounding_flex_basis_flex_grow_row_width_of_100) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, rounding_flex_basis_flex_grow_row_prime_number_width) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 113); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child2, 1); YGNodeInsertChild(root, root_child2, 2); - const YGNodeRef root_child3 = YGNodeNew(); + const YGNodeRef root_child3 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child3, 1); YGNodeInsertChild(root, root_child3, 3); - const YGNodeRef root_child4 = YGNodeNew(); + const YGNodeRef root_child4 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child4, 1); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -173,27 +175,28 @@ TEST(YogaTest, rounding_flex_basis_flex_grow_row_prime_number_width) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, rounding_flex_basis_flex_shrink_row) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 101); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexShrink(root_child0, 1); YGNodeStyleSetFlexBasis(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexBasis(root_child1, 25); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexBasis(root_child2, 25); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -242,28 +245,29 @@ TEST(YogaTest, rounding_flex_basis_flex_shrink_row) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, rounding_flex_basis_overrides_main_size) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 113); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexBasis(root_child0, 50); YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child2, 1); YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); @@ -313,28 +317,29 @@ TEST(YogaTest, rounding_flex_basis_overrides_main_size) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, rounding_total_fractial) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 87.4f); YGNodeStyleSetHeight(root, 113.4f); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 0.7f); YGNodeStyleSetFlexBasis(root_child0, 50.3f); YGNodeStyleSetHeight(root_child0, 20.3f); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1.6f); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child2, 1.1f); YGNodeStyleSetHeight(root_child2, 10.7f); YGNodeInsertChild(root, root_child2, 2); @@ -384,42 +389,43 @@ TEST(YogaTest, rounding_total_fractial) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, rounding_total_fractial_nested) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 87.4f); YGNodeStyleSetHeight(root, 113.4f); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 0.7f); YGNodeStyleSetFlexBasis(root_child0, 50.3f); YGNodeStyleSetHeight(root_child0, 20.3f); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0_child0, 1); YGNodeStyleSetFlexBasis(root_child0_child0, 0.3f); YGNodeStyleSetPosition(root_child0_child0, YGEdgeBottom, 13.3f); YGNodeStyleSetHeight(root_child0_child0, 9.9f); YGNodeInsertChild(root_child0, root_child0_child0, 0); - const YGNodeRef root_child0_child1 = YGNodeNew(); + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0_child1, 4); YGNodeStyleSetFlexBasis(root_child0_child1, 0.3f); YGNodeStyleSetPosition(root_child0_child1, YGEdgeTop, 13.3f); YGNodeStyleSetHeight(root_child0_child1, 1.1f); YGNodeInsertChild(root_child0, root_child0_child1, 1); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1.6f); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child2, 1.1f); YGNodeStyleSetHeight(root_child2, 10.7f); YGNodeInsertChild(root, root_child2, 2); @@ -489,28 +495,29 @@ TEST(YogaTest, rounding_total_fractial_nested) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, rounding_fractial_input_1) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 113.4f); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexBasis(root_child0, 50); YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child2, 1); YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); @@ -560,28 +567,29 @@ TEST(YogaTest, rounding_fractial_input_1) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, rounding_fractial_input_2) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 113.6f); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexBasis(root_child0, 50); YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child2, 1); YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); @@ -631,29 +639,30 @@ TEST(YogaTest, rounding_fractial_input_2) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, rounding_fractial_input_3) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetPosition(root, YGEdgeTop, 0.3f); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 113.4f); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexBasis(root_child0, 50); YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child2, 1); YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); @@ -703,29 +712,30 @@ TEST(YogaTest, rounding_fractial_input_3) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } TEST(YogaTest, rounding_fractial_input_4) { - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true); - const YGNodeRef root = YGNodeNew(); + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetPosition(root, YGEdgeTop, 0.7f); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 113.4f); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexBasis(root_child0, 50); YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child1 = YGNodeNew(); + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); - const YGNodeRef root_child2 = YGNodeNew(); + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child2, 1); YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); @@ -775,5 +785,5 @@ TEST(YogaTest, rounding_fractial_input_4) { YGNodeFreeRecursive(root); - YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGConfigFree(config); } diff --git a/tests/YGSizeOverflowTest.cpp b/tests/YGSizeOverflowTest.cpp index d06c7677..0ce5ff53 100644 --- a/tests/YGSizeOverflowTest.cpp +++ b/tests/YGSizeOverflowTest.cpp @@ -13,14 +13,16 @@ #include TEST(YogaTest, nested_overflowing_child) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0_child0, 200); YGNodeStyleSetHeight(root_child0_child0, 200); YGNodeInsertChild(root_child0, root_child0_child0, 0); @@ -59,19 +61,23 @@ TEST(YogaTest, nested_overflowing_child) { ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, nested_overflowing_child_in_constraint_parent) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 100); YGNodeStyleSetHeight(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0_child0, 200); YGNodeStyleSetHeight(root_child0_child0, 200); YGNodeInsertChild(root_child0, root_child0_child0, 0); @@ -110,18 +116,22 @@ TEST(YogaTest, nested_overflowing_child_in_constraint_parent) { ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } TEST(YogaTest, parent_wrap_child_size_overflowing_parent) { - const YGNodeRef root = YGNodeNew(); + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); - const YGNodeRef root_child0 = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); - const YGNodeRef root_child0_child0 = YGNodeNew(); + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0_child0, 100); YGNodeStyleSetHeight(root_child0_child0, 200); YGNodeInsertChild(root_child0, root_child0_child0, 0); @@ -160,4 +170,6 @@ TEST(YogaTest, parent_wrap_child_size_overflowing_parent) { ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0)); YGNodeFreeRecursive(root); + + YGConfigFree(config); } diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 9407835a..3f85dfeb 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -94,6 +94,8 @@ typedef struct YGStyle { float aspectRatio; } YGStyle; +typedef struct YGConfig { bool experimentalFeatures[YGExperimentalFeatureCount + 1]; } YGConfig; + typedef struct YGNode { YGStyle style; YGLayout layout; @@ -107,6 +109,7 @@ typedef struct YGNode { YGMeasureFunc measure; YGBaselineFunc baseline; YGPrintFunc print; + YGConfigRef config; void *context; bool isDirty; @@ -191,6 +194,14 @@ static YGNode gYGNodeDefaults = { }, }; +static YGConfig gYGConfigDefaults = { + .experimentalFeatures = + { + [YGExperimentalFeatureRounding] = false, + [YGExperimentalFeatureWebFlexBasis] = false, + }, +}; + static void YGNodeMarkDirtyInternal(const YGNodeRef node); YGMalloc gYGMalloc = &malloc; @@ -290,15 +301,21 @@ static inline float YGValueResolveMargin(const YGValue *const value, const float int32_t gNodeInstanceCount = 0; -YGNodeRef YGNodeNew(void) { + +WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config) { const YGNodeRef node = gYGMalloc(sizeof(YGNode)); YG_ASSERT(node, "Could not allocate memory for node"); gNodeInstanceCount++; memcpy(node, &gYGNodeDefaults, sizeof(YGNode)); + node->config = config; return node; } +YGNodeRef YGNodeNew(void) { + return YGNodeNewWithConfig(&gYGConfigDefaults); +} + void YGNodeFree(const YGNodeRef node) { if (node->parent) { YGNodeListDelete(node->parent->children, node); @@ -331,13 +348,27 @@ void YGNodeReset(const YGNodeRef node) { YG_ASSERT(node->parent == NULL, "Cannot reset a node still attached to a parent"); YGNodeListFree(node->children); + + const YGConfigRef config = node->config; memcpy(node, &gYGNodeDefaults, sizeof(YGNode)); + node->config = config; } int32_t YGNodeGetInstanceCount(void) { return gNodeInstanceCount; } +YGConfigRef YGConfigNew(void) { + const YGConfigRef config = gYGMalloc(sizeof(YGConfig)); + YG_ASSERT(config, "Could not allocate memory for config"); + memcpy(config, &gYGConfigDefaults, sizeof(YGConfig)); + return config; +} + +void YGConfigFree(const YGConfigRef config) { + gYGFree(config); +} + static void YGNodeMarkDirtyInternal(const YGNodeRef node) { if (!node->isDirty) { node->isDirty = true; @@ -678,7 +709,8 @@ bool YGLayoutNodeInternal(const YGNodeRef node, const float parentWidth, const float parentHeight, const bool performLayout, - const char *reason); + const char *reason, + const YGConfigRef config); inline bool YGFloatIsUndefined(const float value) { return isnan(value); @@ -1335,7 +1367,8 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, const float parentWidth, const float parentHeight, const YGMeasureMode heightMode, - const YGDirection direction) { + const YGDirection direction, + const YGConfigRef config) { const YGFlexDirection mainAxis = YGFlexDirectionResolve(node->style.flexDirection, direction); const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis); const float mainAxisSize = isMainAxisRow ? width : height; @@ -1354,7 +1387,7 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, if (!YGFloatIsUndefined(resolvedFlexBasis) && !YGFloatIsUndefined(mainAxisSize)) { if (YGFloatIsUndefined(child->layout.computedFlexBasis) || - (YGIsExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis) && + (YGConfigIsExperimentalFeatureEnabled(config, YGExperimentalFeatureWebFlexBasis) && child->layout.computedFlexBasisGeneration != gCurrentGenerationCount)) { child->layout.computedFlexBasis = fmaxf(resolvedFlexBasis, YGNodePaddingAndBorderForAxis(child, mainAxis, parentWidth)); @@ -1456,7 +1489,8 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, parentWidth, parentHeight, false, - "measure"); + "measure", + config); child->layout.computedFlexBasis = fmaxf(child->layout.measuredDimensions[dim[mainAxis]], @@ -1471,7 +1505,8 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, const float width, const YGMeasureMode widthMode, const float height, - const YGDirection direction) { + const YGDirection direction, + const YGConfigRef config) { const YGFlexDirection mainAxis = YGFlexDirectionResolve(node->style.flexDirection, direction); const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction); const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis); @@ -1560,7 +1595,8 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, childWidth, childHeight, false, - "abs-measure"); + "abs-measure", + config); childWidth = child->layout.measuredDimensions[YGDimensionWidth] + YGNodeMarginForAxis(child, YGFlexDirectionRow, width); childHeight = child->layout.measuredDimensions[YGDimensionHeight] + @@ -1576,7 +1612,8 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, childWidth, childHeight, true, - "abs-layout"); + "abs-layout", + config); if (YGNodeIsTrailingPosDefined(child, mainAxis) && !YGNodeIsLeadingPosDefined(child, mainAxis)) { child->layout.position[leading[mainAxis]] = node->layout.measuredDimensions[dim[mainAxis]] - @@ -1854,7 +1891,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, const YGMeasureMode heightMeasureMode, const float parentWidth, const float parentHeight, - const bool performLayout) { + const bool performLayout, + const YGConfigRef config) { YG_ASSERT(YGFloatIsUndefined(availableWidth) ? widthMeasureMode == YGMeasureModeUndefined : true, "availableWidth is indefinite so widthMeasureMode must be " "YGMeasureModeUndefined"); @@ -2056,7 +2094,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, availableInnerWidth, availableInnerHeight, heightMeasureMode, - direction); + direction, + config); } } @@ -2173,7 +2212,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, availableInnerMainDim = minInnerMainDim; } else if (!YGFloatIsUndefined(maxInnerMainDim) && sizeConsumedOnCurrentLine > maxInnerMainDim) { availableInnerMainDim = maxInnerMainDim; - } else if (YGIsExperimentalFeatureEnabled(YGExperimentalFeatureMinFlexFix)) { + } else if (YGConfigIsExperimentalFeatureEnabled(config, YGExperimentalFeatureMinFlexFix)) { // TODO: this needs to be moved out of experimental feature, as this is legitimate fix // If the measurement isn't exact, we want to use as little space as possible availableInnerMainDim = sizeConsumedOnCurrentLine; @@ -2422,7 +2461,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, availableInnerWidth, availableInnerHeight, performLayout && !requiresStretchLayout, - "flex"); + "flex", + config); currentRelativeChild = currentRelativeChild->nextChild; } @@ -2660,7 +2700,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, availableInnerWidth, availableInnerHeight, true, - "stretch"); + "stretch", + config); } } else { const float remainingCrossDim = @@ -2827,7 +2868,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, availableInnerWidth, availableInnerHeight, true, - "stretch"); + "stretch", + config); } } break; @@ -2915,7 +2957,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, availableInnerWidth, isMainAxisRow ? measureModeMainDim : measureModeCrossDim, availableInnerHeight, - direction); + direction, + config); } // STEP 11: SETTING TRAILING POSITIONS FOR CHILDREN @@ -3057,7 +3100,8 @@ bool YGLayoutNodeInternal(const YGNodeRef node, const float parentWidth, const float parentHeight, const bool performLayout, - const char *reason) { + const char *reason, + const YGConfigRef config) { YGLayout *layout = &node->layout; gDepth++; @@ -3186,7 +3230,8 @@ bool YGLayoutNodeInternal(const YGNodeRef node, heightMeasureMode, parentWidth, parentHeight, - performLayout); + performLayout, + config); if (gPrintChanges) { printf("%s%d.}%s", YGSpacer(gDepth), gDepth, needToVisitNode ? "*" : ""); @@ -3352,11 +3397,11 @@ void YGNodeCalculateLayout(const YGNodeRef node, parentWidth, parentHeight, true, - "initia" - "l")) { - YGNodeSetPosition(node, node->layout.direction, node->layout.dimensions[YGDimensionWidth], node->layout.dimensions[YGDimensionHeight], parentWidth); + "initial", + node->config)) { + YGNodeSetPosition(node, node->layout.direction, parentWidth, parentHeight, parentWidth); - if (YGIsExperimentalFeatureEnabled(YGExperimentalFeatureRounding)) { + if (YGConfigIsExperimentalFeatureEnabled(node->config, YGExperimentalFeatureRounding)) { YGRoundToPixelGrid(node); } @@ -3377,14 +3422,15 @@ void YGLog(YGLogLevel level, const char *format, ...) { va_end(args); } -static bool experimentalFeatures[YGExperimentalFeatureCount + 1]; - -void YGSetExperimentalFeatureEnabled(YGExperimentalFeature feature, bool enabled) { - experimentalFeatures[feature] = enabled; +void YGConfigSetExperimentalFeatureEnabled(const YGConfigRef config, + const YGExperimentalFeature feature, + const bool enabled) { + config->experimentalFeatures[feature] = enabled; } -inline bool YGIsExperimentalFeatureEnabled(YGExperimentalFeature feature) { - return experimentalFeatures[feature]; +inline bool YGConfigIsExperimentalFeatureEnabled(const YGConfigRef config, + const YGExperimentalFeature feature) { + return config->experimentalFeatures[feature]; } void YGSetMemoryFuncs(YGMalloc ygmalloc, YGCalloc yccalloc, YGRealloc ygrealloc, YGFree ygfree) { diff --git a/yoga/Yoga.h b/yoga/Yoga.h index 64b0cda0..cbcf92ee 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -46,6 +46,7 @@ typedef struct YGValue { static const YGValue YGValueUndefined = {YGUndefined, YGUnitUndefined}; static const YGValue YGValueAuto = {YGUndefined, YGUnitAuto}; +typedef struct YGConfig *YGConfigRef; typedef struct YGNode *YGNodeRef; typedef YGSize (*YGMeasureFunc)(YGNodeRef node, float width, @@ -63,6 +64,7 @@ typedef void (*YGFree)(void *ptr); // YGNode WIN_EXPORT YGNodeRef YGNodeNew(void); +WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config); WIN_EXPORT void YGNodeFree(const YGNodeRef node); WIN_EXPORT void YGNodeFreeRecursive(const YGNodeRef node); WIN_EXPORT void YGNodeReset(const YGNodeRef node); @@ -223,8 +225,15 @@ WIN_EXPORT void YGLog(YGLogLevel level, const char *message, ...); // If you want to avoid rounding - set PointScaleFactor to 0 WIN_EXPORT void YGSetPointScaleFactor(float pixelsInPoint); -WIN_EXPORT void YGSetExperimentalFeatureEnabled(YGExperimentalFeature feature, bool enabled); -WIN_EXPORT bool YGIsExperimentalFeatureEnabled(YGExperimentalFeature feature); +// YGConfig +WIN_EXPORT YGConfigRef YGConfigNew(void); +WIN_EXPORT void YGConfigFree(const YGConfigRef config); + +WIN_EXPORT void YGConfigSetExperimentalFeatureEnabled(const YGConfigRef config, + const YGExperimentalFeature feature, + const bool enabled); +WIN_EXPORT bool YGConfigIsExperimentalFeatureEnabled(const YGConfigRef config, + const YGExperimentalFeature feature); WIN_EXPORT void YGSetMemoryFuncs(YGMalloc ygmalloc, YGCalloc yccalloc, YGRealloc ygrealloc, YGFree ygfree);