Introduce CSSLayoutSetLogger to pass the print result to C# side

Summary:
- CSSLayoutSetLogger
  - Problem: Unity or other logging system can't use printf output
  - Solution: Add CSSLogger to pass CSSNodePrint result to UnityEngine.Debug.Log or other logging system via CSSLogger function for debugging purpose

Reviewed By: emilsjolander

Differential Revision: D4027044

fbshipit-source-id: 90e2e449260888770f71fa7ea790ca9764d91c44
This commit is contained in:
Kazuki Sakamoto
2016-10-19 11:01:24 -07:00
committed by Facebook Github Bot
parent e4ad7d3c12
commit daed6f5b8a
11 changed files with 347 additions and 229 deletions

View File

@@ -178,6 +178,24 @@ namespace Facebook.CSSLayout
Assert.AreEqual(150, (int)node.LayoutHeight);
}
[Test]
public void TestPrint()
{
CSSNode parent = new CSSNode();
parent.StyleWidth = 100;
parent.StyleHeight = 120;
CSSNode child0 = new CSSNode();
child0.StyleWidth = 30;
child0.StyleHeight = 40;
CSSNode child1 = new CSSNode();
child1.StyleWidth = 35;
child1.StyleHeight = 45;
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");
}
private void ForceGC()
{
GC.Collect(GC.MaxGeneration);