From b747286c1d32a3d650232755bfce7a6df889ac82 Mon Sep 17 00:00:00 2001 From: Adam Comella Date: Tue, 9 Oct 2018 18:01:52 -0700 Subject: [PATCH] Fix C# unit tests (#818) Summary: This consists of several fixes: - Some of the C++ functions called by the tests were missing `WIN_EXPORT` - It looks like Yoga was changed to round up after `TestMeasureFuncWithFloat` was written. Here's the function call that results in the rounding: https://github.com/facebook/yoga/blob/357ca78f9f7bd86298ef00a1426cac5ca2041d3b/yoga/Yoga.cpp#L4019-L4026 - The format of the result of the `Print` method was changed after `TestPrint` was written. Pull Request resolved: https://github.com/facebook/yoga/pull/818 Differential Revision: D10282902 Pulled By: shergin fbshipit-source-id: a5fd732a7dbff1a704cbafbfc95ae3e0c0a0cdd8 --- .../Facebook.Yoga.Universal.Tests/YogaNodeTest.cs | 15 ++++++++++----- yoga/Yoga.h | 6 +++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/csharp/Windows/Facebook.Yoga.Universal.Tests/YogaNodeTest.cs b/csharp/Windows/Facebook.Yoga.Universal.Tests/YogaNodeTest.cs index 1030fe10..78a206e5 100644 --- a/csharp/Windows/Facebook.Yoga.Universal.Tests/YogaNodeTest.cs +++ b/csharp/Windows/Facebook.Yoga.Universal.Tests/YogaNodeTest.cs @@ -1,4 +1,4 @@ -using System; +using System; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Facebook.Yoga; @@ -206,8 +206,8 @@ namespace Facebook.Yoga.Universal.Tests return MeasureOutput.Make(123.4f, 81.7f); }); node.CalculateLayout(); - Assert.AreEqual(123, node.LayoutWidth); - Assert.AreEqual(81, node.LayoutHeight); + Assert.AreEqual(124, node.LayoutWidth); + Assert.AreEqual(82, node.LayoutHeight); } [TestMethod] @@ -268,7 +268,12 @@ namespace Facebook.Yoga.Universal.Tests parent.Insert(0, child0); parent.Insert(0, child1); parent.CalculateLayout(); - Assert.AreEqual(parent.Print(), "{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100, height: 120, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35, height: 45, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30, height: 40, },\n]},\n"); + Assert.AreEqual(parent.Print(), + "
\n" + + "
\n" + + "
\n" + + "
" + ); } [TestMethod] @@ -414,4 +419,4 @@ namespace Facebook.Yoga.Universal.Tests } #endif } -} \ No newline at end of file +} diff --git a/yoga/Yoga.h b/yoga/Yoga.h index c2612b30..f15b4e46 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -153,11 +153,11 @@ WIN_EXPORT void YGNodeCopyStyle( const YGNodeRef dstNode, const YGNodeRef srcNode); -void* YGNodeGetContext(YGNodeRef node); -void YGNodeSetContext(YGNodeRef node, void* context); +WIN_EXPORT void* YGNodeGetContext(YGNodeRef node); +WIN_EXPORT void YGNodeSetContext(YGNodeRef node, void* context); void YGConfigSetPrintTreeFlag(YGConfigRef config, bool enabled); YGMeasureFunc YGNodeGetMeasureFunc(YGNodeRef node); -void YGNodeSetMeasureFunc(YGNodeRef node, YGMeasureFunc measureFunc); +WIN_EXPORT void YGNodeSetMeasureFunc(YGNodeRef node, YGMeasureFunc measureFunc); YGBaselineFunc YGNodeGetBaselineFunc(YGNodeRef node); void YGNodeSetBaselineFunc(YGNodeRef node, YGBaselineFunc baselineFunc); YGDirtiedFunc YGNodeGetDirtiedFunc(YGNodeRef node);