public void Test_border_center_child() { CSSNode root = new CSSNode(); root.JustifyContent = CSSJustify.Center; root.AlignItems = CSSAlign.Center; root.SetBorder(CSSEdge.Start, 10f); root.SetBorder(CSSEdge.End, 20f); root.SetBorder(CSSEdge.Bottom, 20f); root.Width = 100f; root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); Assert.AreEqual(0f, root.LayoutY); Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); Assert.AreEqual(40f, root_child0.LayoutX); Assert.AreEqual(35f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); Assert.AreEqual(0f, root.LayoutY); Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); Assert.AreEqual(50f, root_child0.LayoutX); Assert.AreEqual(35f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); }
public void Test_border_flex_child() { CSSNode root = new CSSNode(); root.SetBorder(CSSEdge.Left, 10f); root.SetBorder(CSSEdge.Top, 10f); root.SetBorder(CSSEdge.Right, 10f); root.SetBorder(CSSEdge.Bottom, 10f); root.Width = 100f; root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; root_child0.Width = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); Assert.AreEqual(0f, root.LayoutY); Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(80f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); Assert.AreEqual(0f, root.LayoutY); Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); Assert.AreEqual(80f, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(80f, root_child0.LayoutHeight); }
public void Test_border_center_child() { CSSNode root = new CSSNode(); root.JustifyContent = CSSJustify.Center; root.AlignItems = CSSAlign.Center; root.SetBorder(CSSEdge.Start, 10); root.SetBorder(CSSEdge.End, 20); root.SetBorder(CSSEdge.Bottom, 20); root.StyleWidth = 100; root.StyleHeight = 100; CSSNode root_child0 = new CSSNode(); root_child0.StyleWidth = 10; root_child0.StyleHeight = 10; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LeftToRight; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(40, root_child0.LayoutX); Assert.AreEqual(35, root_child0.LayoutY); Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RightToLeft; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(50, root_child0.LayoutX); Assert.AreEqual(35, root_child0.LayoutY); Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); }
public void Test_border_no_size() { CSSNode root = new CSSNode(); root.SetBorder(CSSEdge.Left, 10f); root.SetBorder(CSSEdge.Top, 10f); root.SetBorder(CSSEdge.Right, 10f); root.SetBorder(CSSEdge.Bottom, 10f); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); Assert.AreEqual(0f, root.LayoutY); Assert.AreEqual(20f, root.LayoutWidth); Assert.AreEqual(20f, root.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); Assert.AreEqual(0f, root.LayoutY); Assert.AreEqual(20f, root.LayoutWidth); Assert.AreEqual(20f, root.LayoutHeight); }
public void Test_absolute_layout_within_border() { CSSNode root = new CSSNode(); root.SetMargin(CSSEdge.Left, 10f); root.SetMargin(CSSEdge.Top, 10f); root.SetMargin(CSSEdge.Right, 10f); root.SetMargin(CSSEdge.Bottom, 10f); root.SetPadding(CSSEdge.Left, 10f); root.SetPadding(CSSEdge.Top, 10f); root.SetPadding(CSSEdge.Right, 10f); root.SetPadding(CSSEdge.Bottom, 10f); root.SetBorder(CSSEdge.Left, 10f); root.SetBorder(CSSEdge.Top, 10f); root.SetBorder(CSSEdge.Right, 10f); root.SetBorder(CSSEdge.Bottom, 10f); root.Width = 100f; root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.PositionType = CSSPositionType.Absolute; root_child0.SetPosition(CSSEdge.Left, 0f); root_child0.SetPosition(CSSEdge.Top, 0f); root_child0.Width = 50f; root_child0.Height = 50f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); root_child1.PositionType = CSSPositionType.Absolute; root_child1.SetPosition(CSSEdge.Right, 0f); root_child1.SetPosition(CSSEdge.Bottom, 0f); root_child1.Width = 50f; root_child1.Height = 50f; root.Insert(1, root_child1); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(10f, root.LayoutX); Assert.AreEqual(10f, root.LayoutY); Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutY); Assert.AreEqual(50f, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutHeight); Assert.AreEqual(40f, root_child1.LayoutX); Assert.AreEqual(40f, root_child1.LayoutY); Assert.AreEqual(50f, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(10f, root.LayoutX); Assert.AreEqual(10f, root.LayoutY); Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutY); Assert.AreEqual(50f, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutHeight); Assert.AreEqual(40f, root_child1.LayoutX); Assert.AreEqual(40f, root_child1.LayoutY); Assert.AreEqual(50f, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutHeight); }
public void Test_border_container_match_child() { CSSNode root = new CSSNode(); root.SetBorder(CSSEdge.Left, 10); root.SetBorder(CSSEdge.Top, 10); root.SetBorder(CSSEdge.Right, 10); root.SetBorder(CSSEdge.Bottom, 10); CSSNode root_child0 = new CSSNode(); root_child0.StyleWidth = 10; root_child0.StyleHeight = 10; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LeftToRight; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(30, root.LayoutWidth); Assert.AreEqual(30, root.LayoutHeight); Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RightToLeft; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(30, root.LayoutWidth); Assert.AreEqual(30, root.LayoutHeight); Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); }
public void Test_border_no_size() { CSSNode root = new CSSNode(); root.SetBorder(CSSEdge.Left, 10); root.SetBorder(CSSEdge.Top, 10); root.SetBorder(CSSEdge.Right, 10); root.SetBorder(CSSEdge.Bottom, 10); root.StyleDirection = CSSDirection.LeftToRight; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(20, root.LayoutWidth); Assert.AreEqual(20, root.LayoutHeight); root.StyleDirection = CSSDirection.RightToLeft; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(20, root.LayoutWidth); Assert.AreEqual(20, root.LayoutHeight); }