Пример #1
0
        public void Test_android_news_feed()
        {
            YogaConfig config = new YogaConfig();

            YogaNode root = new YogaNode(config);

            root.AlignContent = YogaAlign.Stretch;
            root.Width        = 1080;

            YogaNode root_child0 = new YogaNode(config);

            root.Insert(0, root_child0);

            YogaNode root_child0_child0 = new YogaNode(config);

            root_child0_child0.AlignContent = YogaAlign.Stretch;
            root_child0.Insert(0, root_child0_child0);

            YogaNode root_child0_child0_child0 = new YogaNode(config);

            root_child0_child0_child0.AlignContent = YogaAlign.Stretch;
            root_child0_child0.Insert(0, root_child0_child0_child0);

            YogaNode root_child0_child0_child0_child0 = new YogaNode(config);

            root_child0_child0_child0_child0.FlexDirection = YogaFlexDirection.Row;
            root_child0_child0_child0_child0.AlignContent  = YogaAlign.Stretch;
            root_child0_child0_child0_child0.AlignItems    = YogaAlign.FlexStart;
            root_child0_child0_child0_child0.MarginStart   = 36;
            root_child0_child0_child0_child0.MarginTop     = 24;
            root_child0_child0_child0.Insert(0, root_child0_child0_child0_child0);

            YogaNode root_child0_child0_child0_child0_child0 = new YogaNode(config);

            root_child0_child0_child0_child0_child0.FlexDirection = YogaFlexDirection.Row;
            root_child0_child0_child0_child0_child0.AlignContent  = YogaAlign.Stretch;
            root_child0_child0_child0_child0.Insert(0, root_child0_child0_child0_child0_child0);

            YogaNode root_child0_child0_child0_child0_child0_child0 = new YogaNode(config);

            root_child0_child0_child0_child0_child0_child0.AlignContent = YogaAlign.Stretch;
            root_child0_child0_child0_child0_child0_child0.Width        = 120;
            root_child0_child0_child0_child0_child0_child0.Height       = 120;
            root_child0_child0_child0_child0_child0.Insert(0, root_child0_child0_child0_child0_child0_child0);

            YogaNode root_child0_child0_child0_child0_child1 = new YogaNode(config);

            root_child0_child0_child0_child0_child1.AlignContent  = YogaAlign.Stretch;
            root_child0_child0_child0_child0_child1.FlexShrink    = 1;
            root_child0_child0_child0_child0_child1.MarginRight   = 36;
            root_child0_child0_child0_child0_child1.PaddingLeft   = 36;
            root_child0_child0_child0_child0_child1.PaddingTop    = 21;
            root_child0_child0_child0_child0_child1.PaddingRight  = 36;
            root_child0_child0_child0_child0_child1.PaddingBottom = 18;
            root_child0_child0_child0_child0.Insert(1, root_child0_child0_child0_child0_child1);

            YogaNode root_child0_child0_child0_child0_child1_child0 = new YogaNode(config);

            root_child0_child0_child0_child0_child1_child0.FlexDirection = YogaFlexDirection.Row;
            root_child0_child0_child0_child0_child1_child0.AlignContent  = YogaAlign.Stretch;
            root_child0_child0_child0_child0_child1_child0.FlexShrink    = 1;
            root_child0_child0_child0_child0_child1.Insert(0, root_child0_child0_child0_child0_child1_child0);

            YogaNode root_child0_child0_child0_child0_child1_child1 = new YogaNode(config);

            root_child0_child0_child0_child0_child1_child1.AlignContent = YogaAlign.Stretch;
            root_child0_child0_child0_child0_child1_child1.FlexShrink   = 1;
            root_child0_child0_child0_child0_child1.Insert(1, root_child0_child0_child0_child0_child1_child1);

            YogaNode root_child0_child0_child1 = new YogaNode(config);

            root_child0_child0_child1.AlignContent = YogaAlign.Stretch;
            root_child0_child0.Insert(1, root_child0_child0_child1);

            YogaNode root_child0_child0_child1_child0 = new YogaNode(config);

            root_child0_child0_child1_child0.FlexDirection = YogaFlexDirection.Row;
            root_child0_child0_child1_child0.AlignContent  = YogaAlign.Stretch;
            root_child0_child0_child1_child0.AlignItems    = YogaAlign.FlexStart;
            root_child0_child0_child1_child0.MarginStart   = 174;
            root_child0_child0_child1_child0.MarginTop     = 24;
            root_child0_child0_child1.Insert(0, root_child0_child0_child1_child0);

            YogaNode root_child0_child0_child1_child0_child0 = new YogaNode(config);

            root_child0_child0_child1_child0_child0.FlexDirection = YogaFlexDirection.Row;
            root_child0_child0_child1_child0_child0.AlignContent  = YogaAlign.Stretch;
            root_child0_child0_child1_child0.Insert(0, root_child0_child0_child1_child0_child0);

            YogaNode root_child0_child0_child1_child0_child0_child0 = new YogaNode(config);

            root_child0_child0_child1_child0_child0_child0.AlignContent = YogaAlign.Stretch;
            root_child0_child0_child1_child0_child0_child0.Width        = 72;
            root_child0_child0_child1_child0_child0_child0.Height       = 72;
            root_child0_child0_child1_child0_child0.Insert(0, root_child0_child0_child1_child0_child0_child0);

            YogaNode root_child0_child0_child1_child0_child1 = new YogaNode(config);

            root_child0_child0_child1_child0_child1.AlignContent  = YogaAlign.Stretch;
            root_child0_child0_child1_child0_child1.FlexShrink    = 1;
            root_child0_child0_child1_child0_child1.MarginRight   = 36;
            root_child0_child0_child1_child0_child1.PaddingLeft   = 36;
            root_child0_child0_child1_child0_child1.PaddingTop    = 21;
            root_child0_child0_child1_child0_child1.PaddingRight  = 36;
            root_child0_child0_child1_child0_child1.PaddingBottom = 18;
            root_child0_child0_child1_child0.Insert(1, root_child0_child0_child1_child0_child1);

            YogaNode root_child0_child0_child1_child0_child1_child0 = new YogaNode(config);

            root_child0_child0_child1_child0_child1_child0.FlexDirection = YogaFlexDirection.Row;
            root_child0_child0_child1_child0_child1_child0.AlignContent  = YogaAlign.Stretch;
            root_child0_child0_child1_child0_child1_child0.FlexShrink    = 1;
            root_child0_child0_child1_child0_child1.Insert(0, root_child0_child0_child1_child0_child1_child0);

            YogaNode root_child0_child0_child1_child0_child1_child1 = new YogaNode(config);

            root_child0_child0_child1_child0_child1_child1.AlignContent = YogaAlign.Stretch;
            root_child0_child0_child1_child0_child1_child1.FlexShrink   = 1;
            root_child0_child0_child1_child0_child1.Insert(1, root_child0_child0_child1_child0_child1_child1);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(1080f, root.LayoutWidth);
            Assert.AreEqual(240f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(1080f, root_child0.LayoutWidth);
            Assert.AreEqual(240f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0.LayoutX);
            Assert.AreEqual(0f, root_child0_child0.LayoutY);
            Assert.AreEqual(1080f, root_child0_child0.LayoutWidth);
            Assert.AreEqual(240f, root_child0_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0_child0.LayoutX);
            Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
            Assert.AreEqual(1080f, root_child0_child0_child0.LayoutWidth);
            Assert.AreEqual(144f, root_child0_child0_child0.LayoutHeight);

            Assert.AreEqual(36f, root_child0_child0_child0_child0.LayoutX);
            Assert.AreEqual(24f, root_child0_child0_child0_child0.LayoutY);
            Assert.AreEqual(1044f, root_child0_child0_child0_child0.LayoutWidth);
            Assert.AreEqual(120f, root_child0_child0_child0_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0_child0_child0_child0.LayoutX);
            Assert.AreEqual(0f, root_child0_child0_child0_child0_child0.LayoutY);
            Assert.AreEqual(120f, root_child0_child0_child0_child0_child0.LayoutWidth);
            Assert.AreEqual(120f, root_child0_child0_child0_child0_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0_child0_child0_child0_child0.LayoutX);
            Assert.AreEqual(0f, root_child0_child0_child0_child0_child0_child0.LayoutY);
            Assert.AreEqual(120f, root_child0_child0_child0_child0_child0_child0.LayoutWidth);
            Assert.AreEqual(120f, root_child0_child0_child0_child0_child0_child0.LayoutHeight);

            Assert.AreEqual(120f, root_child0_child0_child0_child0_child1.LayoutX);
            Assert.AreEqual(0f, root_child0_child0_child0_child0_child1.LayoutY);
            Assert.AreEqual(72f, root_child0_child0_child0_child0_child1.LayoutWidth);
            Assert.AreEqual(39f, root_child0_child0_child0_child0_child1.LayoutHeight);

            Assert.AreEqual(36f, root_child0_child0_child0_child0_child1_child0.LayoutX);
            Assert.AreEqual(21f, root_child0_child0_child0_child0_child1_child0.LayoutY);
            Assert.AreEqual(0f, root_child0_child0_child0_child0_child1_child0.LayoutWidth);
            Assert.AreEqual(0f, root_child0_child0_child0_child0_child1_child0.LayoutHeight);

            Assert.AreEqual(36f, root_child0_child0_child0_child0_child1_child1.LayoutX);
            Assert.AreEqual(21f, root_child0_child0_child0_child0_child1_child1.LayoutY);
            Assert.AreEqual(0f, root_child0_child0_child0_child0_child1_child1.LayoutWidth);
            Assert.AreEqual(0f, root_child0_child0_child0_child0_child1_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0_child1.LayoutX);
            Assert.AreEqual(144f, root_child0_child0_child1.LayoutY);
            Assert.AreEqual(1080f, root_child0_child0_child1.LayoutWidth);
            Assert.AreEqual(96f, root_child0_child0_child1.LayoutHeight);

            Assert.AreEqual(174f, root_child0_child0_child1_child0.LayoutX);
            Assert.AreEqual(24f, root_child0_child0_child1_child0.LayoutY);
            Assert.AreEqual(906f, root_child0_child0_child1_child0.LayoutWidth);
            Assert.AreEqual(72f, root_child0_child0_child1_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0_child1_child0_child0.LayoutX);
            Assert.AreEqual(0f, root_child0_child0_child1_child0_child0.LayoutY);
            Assert.AreEqual(72f, root_child0_child0_child1_child0_child0.LayoutWidth);
            Assert.AreEqual(72f, root_child0_child0_child1_child0_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0_child1_child0_child0_child0.LayoutX);
            Assert.AreEqual(0f, root_child0_child0_child1_child0_child0_child0.LayoutY);
            Assert.AreEqual(72f, root_child0_child0_child1_child0_child0_child0.LayoutWidth);
            Assert.AreEqual(72f, root_child0_child0_child1_child0_child0_child0.LayoutHeight);

            Assert.AreEqual(72f, root_child0_child0_child1_child0_child1.LayoutX);
            Assert.AreEqual(0f, root_child0_child0_child1_child0_child1.LayoutY);
            Assert.AreEqual(72f, root_child0_child0_child1_child0_child1.LayoutWidth);
            Assert.AreEqual(39f, root_child0_child0_child1_child0_child1.LayoutHeight);

            Assert.AreEqual(36f, root_child0_child0_child1_child0_child1_child0.LayoutX);
            Assert.AreEqual(21f, root_child0_child0_child1_child0_child1_child0.LayoutY);
            Assert.AreEqual(0f, root_child0_child0_child1_child0_child1_child0.LayoutWidth);
            Assert.AreEqual(0f, root_child0_child0_child1_child0_child1_child0.LayoutHeight);

            Assert.AreEqual(36f, root_child0_child0_child1_child0_child1_child1.LayoutX);
            Assert.AreEqual(21f, root_child0_child0_child1_child0_child1_child1.LayoutY);
            Assert.AreEqual(0f, root_child0_child0_child1_child0_child1_child1.LayoutWidth);
            Assert.AreEqual(0f, root_child0_child0_child1_child0_child1_child1.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(1080f, root.LayoutWidth);
            Assert.AreEqual(240f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(1080f, root_child0.LayoutWidth);
            Assert.AreEqual(240f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0.LayoutX);
            Assert.AreEqual(0f, root_child0_child0.LayoutY);
            Assert.AreEqual(1080f, root_child0_child0.LayoutWidth);
            Assert.AreEqual(240f, root_child0_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0_child0.LayoutX);
            Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
            Assert.AreEqual(1080f, root_child0_child0_child0.LayoutWidth);
            Assert.AreEqual(144f, root_child0_child0_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0_child0_child0.LayoutX);
            Assert.AreEqual(24f, root_child0_child0_child0_child0.LayoutY);
            Assert.AreEqual(1044f, root_child0_child0_child0_child0.LayoutWidth);
            Assert.AreEqual(120f, root_child0_child0_child0_child0.LayoutHeight);

            Assert.AreEqual(924f, root_child0_child0_child0_child0_child0.LayoutX);
            Assert.AreEqual(0f, root_child0_child0_child0_child0_child0.LayoutY);
            Assert.AreEqual(120f, root_child0_child0_child0_child0_child0.LayoutWidth);
            Assert.AreEqual(120f, root_child0_child0_child0_child0_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0_child0_child0_child0_child0.LayoutX);
            Assert.AreEqual(0f, root_child0_child0_child0_child0_child0_child0.LayoutY);
            Assert.AreEqual(120f, root_child0_child0_child0_child0_child0_child0.LayoutWidth);
            Assert.AreEqual(120f, root_child0_child0_child0_child0_child0_child0.LayoutHeight);

            Assert.AreEqual(816f, root_child0_child0_child0_child0_child1.LayoutX);
            Assert.AreEqual(0f, root_child0_child0_child0_child0_child1.LayoutY);
            Assert.AreEqual(72f, root_child0_child0_child0_child0_child1.LayoutWidth);
            Assert.AreEqual(39f, root_child0_child0_child0_child0_child1.LayoutHeight);

            Assert.AreEqual(36f, root_child0_child0_child0_child0_child1_child0.LayoutX);
            Assert.AreEqual(21f, root_child0_child0_child0_child0_child1_child0.LayoutY);
            Assert.AreEqual(0f, root_child0_child0_child0_child0_child1_child0.LayoutWidth);
            Assert.AreEqual(0f, root_child0_child0_child0_child0_child1_child0.LayoutHeight);

            Assert.AreEqual(36f, root_child0_child0_child0_child0_child1_child1.LayoutX);
            Assert.AreEqual(21f, root_child0_child0_child0_child0_child1_child1.LayoutY);
            Assert.AreEqual(0f, root_child0_child0_child0_child0_child1_child1.LayoutWidth);
            Assert.AreEqual(0f, root_child0_child0_child0_child0_child1_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0_child1.LayoutX);
            Assert.AreEqual(144f, root_child0_child0_child1.LayoutY);
            Assert.AreEqual(1080f, root_child0_child0_child1.LayoutWidth);
            Assert.AreEqual(96f, root_child0_child0_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0_child1_child0.LayoutX);
            Assert.AreEqual(24f, root_child0_child0_child1_child0.LayoutY);
            Assert.AreEqual(906f, root_child0_child0_child1_child0.LayoutWidth);
            Assert.AreEqual(72f, root_child0_child0_child1_child0.LayoutHeight);

            Assert.AreEqual(834f, root_child0_child0_child1_child0_child0.LayoutX);
            Assert.AreEqual(0f, root_child0_child0_child1_child0_child0.LayoutY);
            Assert.AreEqual(72f, root_child0_child0_child1_child0_child0.LayoutWidth);
            Assert.AreEqual(72f, root_child0_child0_child1_child0_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0_child1_child0_child0_child0.LayoutX);
            Assert.AreEqual(0f, root_child0_child0_child1_child0_child0_child0.LayoutY);
            Assert.AreEqual(72f, root_child0_child0_child1_child0_child0_child0.LayoutWidth);
            Assert.AreEqual(72f, root_child0_child0_child1_child0_child0_child0.LayoutHeight);

            Assert.AreEqual(726f, root_child0_child0_child1_child0_child1.LayoutX);
            Assert.AreEqual(0f, root_child0_child0_child1_child0_child1.LayoutY);
            Assert.AreEqual(72f, root_child0_child0_child1_child0_child1.LayoutWidth);
            Assert.AreEqual(39f, root_child0_child0_child1_child0_child1.LayoutHeight);

            Assert.AreEqual(36f, root_child0_child0_child1_child0_child1_child0.LayoutX);
            Assert.AreEqual(21f, root_child0_child0_child1_child0_child1_child0.LayoutY);
            Assert.AreEqual(0f, root_child0_child0_child1_child0_child1_child0.LayoutWidth);
            Assert.AreEqual(0f, root_child0_child0_child1_child0_child1_child0.LayoutHeight);

            Assert.AreEqual(36f, root_child0_child0_child1_child0_child1_child1.LayoutX);
            Assert.AreEqual(21f, root_child0_child0_child1_child0_child1_child1.LayoutY);
            Assert.AreEqual(0f, root_child0_child0_child1_child0_child1_child1.LayoutWidth);
            Assert.AreEqual(0f, root_child0_child0_child1_child0_child1_child1.LayoutHeight);
        }
Пример #2
0
        public void Test_flex_shrink_to_zero()
        {
            YogaConfig config = new YogaConfig();

            YogaNode root = new YogaNode(config);

            root.Height = 75;

            YogaNode root_child0 = new YogaNode(config);

            root_child0.Width  = 50;
            root_child0.Height = 50;
            root.Insert(0, root_child0);

            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(config);

            root_child2.Width  = 50;
            root_child2.Height = 50;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(50f, root.LayoutWidth);
            Assert.AreEqual(75f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(50f, root_child0.LayoutWidth);
            Assert.AreEqual(50f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(50f, root_child1.LayoutY);
            Assert.AreEqual(50f, root_child1.LayoutWidth);
            Assert.AreEqual(0f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(50f, root_child2.LayoutY);
            Assert.AreEqual(50f, root_child2.LayoutWidth);
            Assert.AreEqual(50f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(50f, root.LayoutWidth);
            Assert.AreEqual(75f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(50f, root_child0.LayoutWidth);
            Assert.AreEqual(50f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(50f, root_child1.LayoutY);
            Assert.AreEqual(50f, root_child1.LayoutWidth);
            Assert.AreEqual(0f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(50f, root_child2.LayoutY);
            Assert.AreEqual(50f, root_child2.LayoutWidth);
            Assert.AreEqual(50f, root_child2.LayoutHeight);
        }
Пример #3
0
        public void Test_flex_grow_less_than_factor_one()
        {
            YogaConfig config = new YogaConfig();

            YogaNode root = new YogaNode(config);

            root.Width  = 200;
            root.Height = 500;

            YogaNode root_child0 = new YogaNode(config);

            root_child0.FlexGrow  = 0.2f;
            root_child0.FlexBasis = 40;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);

            root_child1.FlexGrow = 0.2f;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);

            root_child2.FlexGrow = 0.4f;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(200f, root.LayoutWidth);
            Assert.AreEqual(500f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(200f, root_child0.LayoutWidth);
            Assert.AreEqual(132f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(132f, root_child1.LayoutY);
            Assert.AreEqual(200f, root_child1.LayoutWidth);
            Assert.AreEqual(92f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(224f, root_child2.LayoutY);
            Assert.AreEqual(200f, root_child2.LayoutWidth);
            Assert.AreEqual(184f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(200f, root.LayoutWidth);
            Assert.AreEqual(500f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(200f, root_child0.LayoutWidth);
            Assert.AreEqual(132f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(132f, root_child1.LayoutY);
            Assert.AreEqual(200f, root_child1.LayoutWidth);
            Assert.AreEqual(92f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(224f, root_child2.LayoutY);
            Assert.AreEqual(200f, root_child2.LayoutWidth);
            Assert.AreEqual(184f, root_child2.LayoutHeight);
        }
Пример #4
0
        public void Test_wrap_column()
        {
            YogaNode root = new YogaNode();

            root.Wrap   = YogaWrap.Wrap;
            root.Height = 100;

            YogaNode root_child0 = new YogaNode();

            root_child0.Width  = 30;
            root_child0.Height = 30;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode();

            root_child1.Width  = 30;
            root_child1.Height = 30;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode();

            root_child2.Width  = 30;
            root_child2.Height = 30;
            root.Insert(2, root_child2);

            YogaNode root_child3 = new YogaNode();

            root_child3.Width  = 30;
            root_child3.Height = 30;
            root.Insert(3, root_child3);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(60f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(30f, root_child0.LayoutWidth);
            Assert.AreEqual(30f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(30f, root_child1.LayoutY);
            Assert.AreEqual(30f, root_child1.LayoutWidth);
            Assert.AreEqual(30f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(60f, root_child2.LayoutY);
            Assert.AreEqual(30f, root_child2.LayoutWidth);
            Assert.AreEqual(30f, root_child2.LayoutHeight);

            Assert.AreEqual(30f, root_child3.LayoutX);
            Assert.AreEqual(0f, root_child3.LayoutY);
            Assert.AreEqual(30f, root_child3.LayoutWidth);
            Assert.AreEqual(30f, root_child3.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(60f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(30f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(30f, root_child0.LayoutWidth);
            Assert.AreEqual(30f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(30f, root_child1.LayoutY);
            Assert.AreEqual(30f, root_child1.LayoutWidth);
            Assert.AreEqual(30f, root_child1.LayoutHeight);

            Assert.AreEqual(30f, root_child2.LayoutX);
            Assert.AreEqual(60f, root_child2.LayoutY);
            Assert.AreEqual(30f, root_child2.LayoutWidth);
            Assert.AreEqual(30f, root_child2.LayoutHeight);

            Assert.AreEqual(0f, root_child3.LayoutX);
            Assert.AreEqual(0f, root_child3.LayoutY);
            Assert.AreEqual(30f, root_child3.LayoutWidth);
            Assert.AreEqual(30f, root_child3.LayoutHeight);
        }
        public void Test_absolute_layout_percentage_bottom_based_on_parent_height()
        {
            YogaConfig config = new YogaConfig();

            YogaNode root = new YogaNode(config);

            root.Width  = 100;
            root.Height = 200;

            YogaNode root_child0 = new YogaNode(config);

            root_child0.PositionType = YogaPositionType.Absolute;
            root_child0.Top          = 50.Percent();
            root_child0.Width        = 10;
            root_child0.Height       = 10;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);

            root_child1.PositionType = YogaPositionType.Absolute;
            root_child1.Bottom       = 50.Percent();
            root_child1.Width        = 10;
            root_child1.Height       = 10;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);

            root_child2.PositionType = YogaPositionType.Absolute;
            root_child2.Top          = 10.Percent();
            root_child2.Bottom       = 10.Percent();
            root_child2.Width        = 10;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(200f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(100f, root_child0.LayoutY);
            Assert.AreEqual(10f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(90f, root_child1.LayoutY);
            Assert.AreEqual(10f, root_child1.LayoutWidth);
            Assert.AreEqual(10f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(20f, root_child2.LayoutY);
            Assert.AreEqual(10f, root_child2.LayoutWidth);
            Assert.AreEqual(160f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(200f, root.LayoutHeight);

            Assert.AreEqual(90f, root_child0.LayoutX);
            Assert.AreEqual(100f, root_child0.LayoutY);
            Assert.AreEqual(10f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(90f, root_child1.LayoutX);
            Assert.AreEqual(90f, root_child1.LayoutY);
            Assert.AreEqual(10f, root_child1.LayoutWidth);
            Assert.AreEqual(10f, root_child1.LayoutHeight);

            Assert.AreEqual(90f, root_child2.LayoutX);
            Assert.AreEqual(20f, root_child2.LayoutY);
            Assert.AreEqual(10f, root_child2.LayoutWidth);
            Assert.AreEqual(160f, root_child2.LayoutHeight);
        }
Пример #6
0
        public void Test_flex_grow_height_maximized()
        {
            YogaConfig config = new YogaConfig();

            YogaNode root = new YogaNode(config);

            root.Width  = 100;
            root.Height = 500;

            YogaNode root_child0 = new YogaNode(config);

            root_child0.FlexGrow  = 1;
            root_child0.MinHeight = 100;
            root_child0.MaxHeight = 500;
            root.Insert(0, root_child0);

            YogaNode root_child0_child0 = new YogaNode(config);

            root_child0_child0.FlexGrow  = 1;
            root_child0_child0.FlexBasis = 200;
            root_child0.Insert(0, root_child0_child0);

            YogaNode root_child0_child1 = new YogaNode(config);

            root_child0_child1.Height = 100;
            root_child0.Insert(1, root_child0_child1);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(500f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(500f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0.LayoutX);
            Assert.AreEqual(0f, root_child0_child0.LayoutY);
            Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
            Assert.AreEqual(400f, root_child0_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child1.LayoutX);
            Assert.AreEqual(400f, root_child0_child1.LayoutY);
            Assert.AreEqual(100f, root_child0_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child0_child1.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(500f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(500f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0.LayoutX);
            Assert.AreEqual(0f, root_child0_child0.LayoutY);
            Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
            Assert.AreEqual(400f, root_child0_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child1.LayoutX);
            Assert.AreEqual(400f, root_child0_child1.LayoutY);
            Assert.AreEqual(100f, root_child0_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child0_child1.LayoutHeight);
        }
Пример #7
0
        public void Test_justify_content_column_space_around()
        {
            YogaNode root = new YogaNode();

            root.JustifyContent = YogaJustify.SpaceAround;
            root.Width          = 102;
            root.Height         = 102;

            YogaNode root_child0 = new YogaNode();

            root_child0.Height = 10;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode();

            root_child1.Height = 10;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode();

            root_child2.Height = 10;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(102f, root.LayoutWidth);
            Assert.AreEqual(102f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(12f, root_child0.LayoutY);
            Assert.AreEqual(102f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(46f, root_child1.LayoutY);
            Assert.AreEqual(102f, root_child1.LayoutWidth);
            Assert.AreEqual(10f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(80f, root_child2.LayoutY);
            Assert.AreEqual(102f, root_child2.LayoutWidth);
            Assert.AreEqual(10f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(102f, root.LayoutWidth);
            Assert.AreEqual(102f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(12f, root_child0.LayoutY);
            Assert.AreEqual(102f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(46f, root_child1.LayoutY);
            Assert.AreEqual(102f, root_child1.LayoutWidth);
            Assert.AreEqual(10f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(80f, root_child2.LayoutY);
            Assert.AreEqual(102f, root_child2.LayoutWidth);
            Assert.AreEqual(10f, root_child2.LayoutHeight);
        }
Пример #8
0
        public void Test_rounding_flex_basis_flex_grow_row_prime_number_width()
        {
            YogaConfig config = new YogaConfig();

            YogaNode root = new YogaNode(config);

            root.FlexDirection = YogaFlexDirection.Row;
            root.Width         = 113;
            root.Height        = 100;

            YogaNode root_child0 = new YogaNode(config);

            root_child0.FlexGrow = 1;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);

            root_child1.FlexGrow = 1;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);

            root_child2.FlexGrow = 1;
            root.Insert(2, root_child2);

            YogaNode root_child3 = new YogaNode(config);

            root_child3.FlexGrow = 1;
            root.Insert(3, root_child3);

            YogaNode root_child4 = new YogaNode(config);

            root_child4.FlexGrow = 1;
            root.Insert(4, root_child4);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(113f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(23f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(23f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(22f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(45f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(23f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            Assert.AreEqual(68f, root_child3.LayoutX);
            Assert.AreEqual(0f, root_child3.LayoutY);
            Assert.AreEqual(22f, root_child3.LayoutWidth);
            Assert.AreEqual(100f, root_child3.LayoutHeight);

            Assert.AreEqual(90f, root_child4.LayoutX);
            Assert.AreEqual(0f, root_child4.LayoutY);
            Assert.AreEqual(23f, root_child4.LayoutWidth);
            Assert.AreEqual(100f, root_child4.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(113f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(90f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(23f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(68f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(22f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(45f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(23f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            Assert.AreEqual(23f, root_child3.LayoutX);
            Assert.AreEqual(0f, root_child3.LayoutY);
            Assert.AreEqual(22f, root_child3.LayoutWidth);
            Assert.AreEqual(100f, root_child3.LayoutHeight);

            Assert.AreEqual(0f, root_child4.LayoutX);
            Assert.AreEqual(0f, root_child4.LayoutY);
            Assert.AreEqual(23f, root_child4.LayoutWidth);
            Assert.AreEqual(100f, root_child4.LayoutHeight);
        }
Пример #9
0
        public void Test_rounding_inner_node_controversy_vertical()
        {
            YogaConfig config = new YogaConfig();

            YogaNode root = new YogaNode(config);

            root.Height = 320;

            YogaNode root_child0 = new YogaNode(config);

            root_child0.FlexGrow = 1;
            root_child0.Width    = 10;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);

            root_child1.FlexGrow = 1;
            root_child1.Width    = 10;
            root.Insert(1, root_child1);

            YogaNode root_child1_child0 = new YogaNode(config);

            root_child1_child0.FlexGrow = 1;
            root_child1_child0.Width    = 10;
            root_child1.Insert(0, root_child1_child0);

            YogaNode root_child2 = new YogaNode(config);

            root_child2.FlexGrow = 1;
            root_child2.Width    = 10;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(10f, root.LayoutWidth);
            Assert.AreEqual(320f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(10f, root_child0.LayoutWidth);
            Assert.AreEqual(107f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(107f, root_child1.LayoutY);
            Assert.AreEqual(10f, root_child1.LayoutWidth);
            Assert.AreEqual(106f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child1_child0.LayoutX);
            Assert.AreEqual(0f, root_child1_child0.LayoutY);
            Assert.AreEqual(10f, root_child1_child0.LayoutWidth);
            Assert.AreEqual(106f, root_child1_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(213f, root_child2.LayoutY);
            Assert.AreEqual(10f, root_child2.LayoutWidth);
            Assert.AreEqual(107f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(10f, root.LayoutWidth);
            Assert.AreEqual(320f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(10f, root_child0.LayoutWidth);
            Assert.AreEqual(107f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(107f, root_child1.LayoutY);
            Assert.AreEqual(10f, root_child1.LayoutWidth);
            Assert.AreEqual(106f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child1_child0.LayoutX);
            Assert.AreEqual(0f, root_child1_child0.LayoutY);
            Assert.AreEqual(10f, root_child1_child0.LayoutWidth);
            Assert.AreEqual(106f, root_child1_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(213f, root_child2.LayoutY);
            Assert.AreEqual(10f, root_child2.LayoutWidth);
            Assert.AreEqual(107f, root_child2.LayoutHeight);
        }
Пример #10
0
        public void Test_rounding_total_fractial_nested()
        {
            YogaConfig config = new YogaConfig();

            YogaNode root = new YogaNode(config);

            root.Width  = 87.4f;
            root.Height = 113.4f;

            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(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(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(config);

            root_child1.FlexGrow = 1.6f;
            root_child1.Height   = 10;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);

            root_child2.FlexGrow = 1.1f;
            root_child2.Height   = 10.7f;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(87f, root.LayoutWidth);
            Assert.AreEqual(113f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(87f, root_child0.LayoutWidth);
            Assert.AreEqual(59f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0.LayoutX);
            Assert.AreEqual(-13f, root_child0_child0.LayoutY);
            Assert.AreEqual(87f, root_child0_child0.LayoutWidth);
            Assert.AreEqual(12f, root_child0_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child1.LayoutX);
            Assert.AreEqual(25f, root_child0_child1.LayoutY);
            Assert.AreEqual(87f, root_child0_child1.LayoutWidth);
            Assert.AreEqual(47f, root_child0_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(59f, root_child1.LayoutY);
            Assert.AreEqual(87f, root_child1.LayoutWidth);
            Assert.AreEqual(30f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(89f, root_child2.LayoutY);
            Assert.AreEqual(87f, root_child2.LayoutWidth);
            Assert.AreEqual(24f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(87f, root.LayoutWidth);
            Assert.AreEqual(113f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(87f, root_child0.LayoutWidth);
            Assert.AreEqual(59f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0.LayoutX);
            Assert.AreEqual(-13f, root_child0_child0.LayoutY);
            Assert.AreEqual(87f, root_child0_child0.LayoutWidth);
            Assert.AreEqual(12f, root_child0_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child1.LayoutX);
            Assert.AreEqual(25f, root_child0_child1.LayoutY);
            Assert.AreEqual(87f, root_child0_child1.LayoutWidth);
            Assert.AreEqual(47f, root_child0_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(59f, root_child1.LayoutY);
            Assert.AreEqual(87f, root_child1.LayoutWidth);
            Assert.AreEqual(30f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(89f, root_child2.LayoutY);
            Assert.AreEqual(87f, root_child2.LayoutWidth);
            Assert.AreEqual(24f, root_child2.LayoutHeight);
        }
Пример #11
0
        public void Test_rounding_fractial_input_4()
        {
            YogaConfig config = new YogaConfig();

            YogaNode root = new YogaNode(config);

            root.Top    = 0.7f;
            root.Width  = 100;
            root.Height = 113.4f;

            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(config);

            root_child1.FlexGrow = 1;
            root_child1.Height   = 10;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);

            root_child2.FlexGrow = 1;
            root_child2.Height   = 10;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(1f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(113f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(64f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(64f, root_child1.LayoutY);
            Assert.AreEqual(100f, root_child1.LayoutWidth);
            Assert.AreEqual(25f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(89f, root_child2.LayoutY);
            Assert.AreEqual(100f, root_child2.LayoutWidth);
            Assert.AreEqual(24f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(1f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(113f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(64f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(64f, root_child1.LayoutY);
            Assert.AreEqual(100f, root_child1.LayoutWidth);
            Assert.AreEqual(25f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(89f, root_child2.LayoutY);
            Assert.AreEqual(100f, root_child2.LayoutWidth);
            Assert.AreEqual(24f, root_child2.LayoutHeight);
        }
Пример #12
0
        public void Test_rounding_flex_basis_flex_shrink_row()
        {
            YogaConfig config = new YogaConfig();

            YogaNode root = new YogaNode(config);

            root.FlexDirection = YogaFlexDirection.Row;
            root.Width         = 101;
            root.Height        = 100;

            YogaNode root_child0 = new YogaNode(config);

            root_child0.FlexShrink = 1;
            root_child0.FlexBasis  = 100;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);

            root_child1.FlexBasis = 25;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);

            root_child2.FlexBasis = 25;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(101f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(51f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(51f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(25f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(76f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(25f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(101f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(50f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(51f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(25f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(25f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(25f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);
        }
Пример #13
0
        public void Test_rounding_flex_basis_flex_grow_row_width_of_100()
        {
            YogaConfig config = new YogaConfig();

            YogaNode root = new YogaNode(config);

            root.FlexDirection = YogaFlexDirection.Row;
            root.Width         = 100;
            root.Height        = 100;

            YogaNode root_child0 = new YogaNode(config);

            root_child0.FlexGrow = 1;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);

            root_child1.FlexGrow = 1;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);

            root_child2.FlexGrow = 1;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.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(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(33f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(33f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(34f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(67f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(33f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.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(67f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(33f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(33f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(34f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(33f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);
        }
Пример #14
0
        public void Test_flex_direction_column_no_height()
        {
            YogaConfig config = new YogaConfig();

            YogaNode root = new YogaNode(config);

            root.Width = 100;

            YogaNode root_child0 = new YogaNode(config);

            root_child0.Height = 10;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);

            root_child1.Height = 10;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);

            root_child2.Height = 10;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(30f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(10f, root_child1.LayoutY);
            Assert.AreEqual(100f, root_child1.LayoutWidth);
            Assert.AreEqual(10f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(20f, root_child2.LayoutY);
            Assert.AreEqual(100f, root_child2.LayoutWidth);
            Assert.AreEqual(10f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(30f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(10f, root_child1.LayoutY);
            Assert.AreEqual(100f, root_child1.LayoutWidth);
            Assert.AreEqual(10f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(20f, root_child2.LayoutY);
            Assert.AreEqual(100f, root_child2.LayoutWidth);
            Assert.AreEqual(10f, root_child2.LayoutHeight);
        }
Пример #15
0
        public void Test_flex_grow_within_constrained_max_row()
        {
            YogaConfig config = new YogaConfig();

            YogaNode root = new YogaNode(config);

            root.Width = 200;

            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(config);

            root_child0_child0.FlexShrink = 1;
            root_child0_child0.FlexBasis  = 100;
            root_child0.Insert(0, root_child0_child0);

            YogaNode root_child0_child1 = new YogaNode(config);

            root_child0_child1.Width = 50;
            root_child0.Insert(1, root_child0_child1);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(200f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0.LayoutX);
            Assert.AreEqual(0f, root_child0_child0.LayoutY);
            Assert.AreEqual(50f, root_child0_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0_child0.LayoutHeight);

            Assert.AreEqual(50f, root_child0_child1.LayoutX);
            Assert.AreEqual(0f, root_child0_child1.LayoutY);
            Assert.AreEqual(50f, root_child0_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child0_child1.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(200f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(100f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(50f, root_child0_child0.LayoutX);
            Assert.AreEqual(0f, root_child0_child0.LayoutY);
            Assert.AreEqual(50f, root_child0_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child1.LayoutX);
            Assert.AreEqual(0f, root_child0_child1.LayoutY);
            Assert.AreEqual(50f, root_child0_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child0_child1.LayoutHeight);
        }
Пример #16
0
        public void Test_justify_content_row_space_between()
        {
            YogaNode root = new YogaNode();

            root.FlexDirection  = YogaFlexDirection.Row;
            root.JustifyContent = YogaJustify.SpaceBetween;
            root.Width          = 102f;
            root.Height         = 102f;

            YogaNode root_child0 = new YogaNode();

            root_child0.Width = 10f;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode();

            root_child1.Width = 10f;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode();

            root_child2.Width = 10f;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(102f, root.LayoutWidth);
            Assert.AreEqual(102f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(10f, root_child0.LayoutWidth);
            Assert.AreEqual(102f, root_child0.LayoutHeight);

            Assert.AreEqual(46f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(10f, root_child1.LayoutWidth);
            Assert.AreEqual(102f, root_child1.LayoutHeight);

            Assert.AreEqual(92f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(10f, root_child2.LayoutWidth);
            Assert.AreEqual(102f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(102f, root.LayoutWidth);
            Assert.AreEqual(102f, root.LayoutHeight);

            Assert.AreEqual(92f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(10f, root_child0.LayoutWidth);
            Assert.AreEqual(102f, root_child0.LayoutHeight);

            Assert.AreEqual(46f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(10f, root_child1.LayoutWidth);
            Assert.AreEqual(102f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(10f, root_child2.LayoutWidth);
            Assert.AreEqual(102f, root_child2.LayoutHeight);
        }
Пример #17
0
        public void Test_justify_content_overflow_min_max()
        {
            YogaConfig config = new YogaConfig();

            YogaNode root = new YogaNode(config);

            root.JustifyContent = YogaJustify.Center;
            root.MinHeight      = 100;
            root.MaxHeight      = 110;

            YogaNode root_child0 = new YogaNode(config);

            root_child0.Width  = 50;
            root_child0.Height = 50;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);

            root_child1.Width  = 50;
            root_child1.Height = 50;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);

            root_child2.Width  = 50;
            root_child2.Height = 50;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(50f, root.LayoutWidth);
            Assert.AreEqual(110f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(-20f, root_child0.LayoutY);
            Assert.AreEqual(50f, root_child0.LayoutWidth);
            Assert.AreEqual(50f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(30f, root_child1.LayoutY);
            Assert.AreEqual(50f, root_child1.LayoutWidth);
            Assert.AreEqual(50f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(80f, root_child2.LayoutY);
            Assert.AreEqual(50f, root_child2.LayoutWidth);
            Assert.AreEqual(50f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(50f, root.LayoutWidth);
            Assert.AreEqual(110f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(-20f, root_child0.LayoutY);
            Assert.AreEqual(50f, root_child0.LayoutWidth);
            Assert.AreEqual(50f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(30f, root_child1.LayoutY);
            Assert.AreEqual(50f, root_child1.LayoutWidth);
            Assert.AreEqual(50f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(80f, root_child2.LayoutY);
            Assert.AreEqual(50f, root_child2.LayoutWidth);
            Assert.AreEqual(50f, root_child2.LayoutHeight);
        }
Пример #18
0
        public void Test_justify_content_column_flex_start()
        {
            YogaNode root = new YogaNode();

            root.Width  = 102f;
            root.Height = 102f;

            YogaNode root_child0 = new YogaNode();

            root_child0.Height = 10f;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode();

            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode();

            root_child2.Height = 10f;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(102f, root.LayoutWidth);
            Assert.AreEqual(102f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(102f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(10f, root_child1.LayoutY);
            Assert.AreEqual(102f, root_child1.LayoutWidth);
            Assert.AreEqual(0f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(10f, root_child2.LayoutY);
            Assert.AreEqual(102f, root_child2.LayoutWidth);
            Assert.AreEqual(10f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(102f, root.LayoutWidth);
            Assert.AreEqual(102f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(102f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(10f, root_child1.LayoutY);
            Assert.AreEqual(102f, root_child1.LayoutWidth);
            Assert.AreEqual(0f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(10f, root_child2.LayoutY);
            Assert.AreEqual(102f, root_child2.LayoutWidth);
            Assert.AreEqual(10f, root_child2.LayoutHeight);
        }
Пример #19
0
        public void Test_margin_auto_mutiple_children_row()
        {
            YogaNode root = new YogaNode();

            root.FlexDirection = YogaFlexDirection.Row;
            root.AlignItems    = YogaAlign.Center;
            root.Width         = 200;
            root.Height        = 200;

            YogaNode root_child0 = new YogaNode();

            root_child0.MarginRight = YogaValue.Auto();
            root_child0.Width       = 50;
            root_child0.Height      = 50;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode();

            root_child1.MarginRight = YogaValue.Auto();
            root_child1.Width       = 50;
            root_child1.Height      = 50;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode();

            root_child2.Width  = 50;
            root_child2.Height = 50;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(200f, root.LayoutWidth);
            Assert.AreEqual(200f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(75f, root_child0.LayoutY);
            Assert.AreEqual(50f, root_child0.LayoutWidth);
            Assert.AreEqual(50f, root_child0.LayoutHeight);

            Assert.AreEqual(75f, root_child1.LayoutX);
            Assert.AreEqual(75f, root_child1.LayoutY);
            Assert.AreEqual(50f, root_child1.LayoutWidth);
            Assert.AreEqual(50f, root_child1.LayoutHeight);

            Assert.AreEqual(150f, root_child2.LayoutX);
            Assert.AreEqual(75f, root_child2.LayoutY);
            Assert.AreEqual(50f, root_child2.LayoutWidth);
            Assert.AreEqual(50f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(200f, root.LayoutWidth);
            Assert.AreEqual(200f, root.LayoutHeight);

            Assert.AreEqual(125f, root_child0.LayoutX);
            Assert.AreEqual(75f, root_child0.LayoutY);
            Assert.AreEqual(50f, root_child0.LayoutWidth);
            Assert.AreEqual(50f, root_child0.LayoutHeight);

            Assert.AreEqual(50f, root_child1.LayoutX);
            Assert.AreEqual(75f, root_child1.LayoutY);
            Assert.AreEqual(50f, root_child1.LayoutWidth);
            Assert.AreEqual(50f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(75f, root_child2.LayoutY);
            Assert.AreEqual(50f, root_child2.LayoutWidth);
            Assert.AreEqual(50f, root_child2.LayoutHeight);
        }
Пример #20
0
        public void Test_flex_direction_column_reverse()
        {
            YogaNode root = new YogaNode();

            root.FlexDirection = YogaFlexDirection.ColumnReverse;
            root.Width         = 100f;
            root.Height        = 100f;

            YogaNode root_child0 = new YogaNode();

            root_child0.Height = 10f;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode();

            root_child1.Height = 10f;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode();

            root_child2.Height = 10f;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.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(0f, root_child0.LayoutX);
            Assert.AreEqual(90f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(80f, root_child1.LayoutY);
            Assert.AreEqual(100f, root_child1.LayoutWidth);
            Assert.AreEqual(10f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(70f, root_child2.LayoutY);
            Assert.AreEqual(100f, root_child2.LayoutWidth);
            Assert.AreEqual(10f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.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(0f, root_child0.LayoutX);
            Assert.AreEqual(90f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(80f, root_child1.LayoutY);
            Assert.AreEqual(100f, root_child1.LayoutWidth);
            Assert.AreEqual(10f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(70f, root_child2.LayoutY);
            Assert.AreEqual(100f, root_child2.LayoutWidth);
            Assert.AreEqual(10f, root_child2.LayoutHeight);
        }
Пример #21
0
        public void Test_justify_content_row_flex_end()
        {
            YogaNode root = new YogaNode();

            root.FlexDirection  = YogaFlexDirection.Row;
            root.JustifyContent = YogaJustify.FlexEnd;
            root.Width          = 102;
            root.Height         = 102;

            YogaNode root_child0 = new YogaNode();

            root_child0.Width = 10;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode();

            root_child1.Width = 10;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode();

            root_child2.Width = 10;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(102f, root.LayoutWidth);
            Assert.AreEqual(102f, root.LayoutHeight);

            Assert.AreEqual(72f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(10f, root_child0.LayoutWidth);
            Assert.AreEqual(102f, root_child0.LayoutHeight);

            Assert.AreEqual(82f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(10f, root_child1.LayoutWidth);
            Assert.AreEqual(102f, root_child1.LayoutHeight);

            Assert.AreEqual(92f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(10f, root_child2.LayoutWidth);
            Assert.AreEqual(102f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(102f, root.LayoutWidth);
            Assert.AreEqual(102f, root.LayoutHeight);

            Assert.AreEqual(20f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(10f, root_child0.LayoutWidth);
            Assert.AreEqual(102f, root_child0.LayoutHeight);

            Assert.AreEqual(10f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(10f, root_child1.LayoutWidth);
            Assert.AreEqual(102f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(10f, root_child2.LayoutWidth);
            Assert.AreEqual(102f, root_child2.LayoutHeight);
        }
Пример #22
0
        public void Test_flex_direction_row_no_width()
        {
            YogaNode root = new YogaNode();

            root.FlexDirection = YogaFlexDirection.Row;
            root.Height        = 100f;

            YogaNode root_child0 = new YogaNode();

            root_child0.Width = 10f;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode();

            root_child1.Width = 10f;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode();

            root_child2.Width = 10f;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(30f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(10f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(10f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(10f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(20f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(10f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(30f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(20f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(10f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(10f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(10f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(10f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);
        }
Пример #23
0
        public void Test_wrap_row_align_items_center()
        {
            YogaNode root = new YogaNode();

            root.FlexDirection = YogaFlexDirection.Row;
            root.AlignItems    = YogaAlign.Center;
            root.Wrap          = YogaWrap.Wrap;
            root.Width         = 100;

            YogaNode root_child0 = new YogaNode();

            root_child0.Width  = 30;
            root_child0.Height = 10;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode();

            root_child1.Width  = 30;
            root_child1.Height = 20;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode();

            root_child2.Width  = 30;
            root_child2.Height = 30;
            root.Insert(2, root_child2);

            YogaNode root_child3 = new YogaNode();

            root_child3.Width  = 30;
            root_child3.Height = 30;
            root.Insert(3, root_child3);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(60f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(10f, root_child0.LayoutY);
            Assert.AreEqual(30f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(5f, root_child1.LayoutY);
            Assert.AreEqual(30f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(60f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(30f, root_child2.LayoutWidth);
            Assert.AreEqual(30f, root_child2.LayoutHeight);

            Assert.AreEqual(0f, root_child3.LayoutX);
            Assert.AreEqual(30f, root_child3.LayoutY);
            Assert.AreEqual(30f, root_child3.LayoutWidth);
            Assert.AreEqual(30f, root_child3.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(60f, root.LayoutHeight);

            Assert.AreEqual(70f, root_child0.LayoutX);
            Assert.AreEqual(10f, root_child0.LayoutY);
            Assert.AreEqual(30f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(40f, root_child1.LayoutX);
            Assert.AreEqual(5f, root_child1.LayoutY);
            Assert.AreEqual(30f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(10f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(30f, root_child2.LayoutWidth);
            Assert.AreEqual(30f, root_child2.LayoutHeight);

            Assert.AreEqual(70f, root_child3.LayoutX);
            Assert.AreEqual(30f, root_child3.LayoutY);
            Assert.AreEqual(30f, root_child3.LayoutWidth);
            Assert.AreEqual(30f, root_child3.LayoutHeight);
        }
Пример #24
0
        public void Test_align_self_baseline()
        {
            YogaConfig config = new YogaConfig();

            YogaNode root = new YogaNode(config);

            root.FlexDirection = YogaFlexDirection.Row;
            root.Width         = 100;
            root.Height        = 100;

            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(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(config);

            root_child1_child0.Width  = 50;
            root_child1_child0.Height = 10;
            root_child1.Insert(0, root_child1_child0);
            root.StyleDirection = YogaDirection.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(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(50f, root_child0.LayoutWidth);
            Assert.AreEqual(50f, root_child0.LayoutHeight);

            Assert.AreEqual(50f, root_child1.LayoutX);
            Assert.AreEqual(40f, root_child1.LayoutY);
            Assert.AreEqual(50f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child1_child0.LayoutX);
            Assert.AreEqual(0f, root_child1_child0.LayoutY);
            Assert.AreEqual(50f, root_child1_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child1_child0.LayoutHeight);

            root.StyleDirection = YogaDirection.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(0f, root_child0.LayoutY);
            Assert.AreEqual(50f, root_child0.LayoutWidth);
            Assert.AreEqual(50f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(40f, root_child1.LayoutY);
            Assert.AreEqual(50f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child1_child0.LayoutX);
            Assert.AreEqual(0f, root_child1_child0.LayoutY);
            Assert.AreEqual(50f, root_child1_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child1_child0.LayoutHeight);
        }
Пример #25
0
        public void Test_absolute_layout_within_border()
        {
            YogaNode root = new YogaNode();

            root.MarginLeft        = 10;
            root.MarginTop         = 10;
            root.MarginRight       = 10;
            root.MarginBottom      = 10;
            root.PaddingLeft       = 10;
            root.PaddingTop        = 10;
            root.PaddingRight      = 10;
            root.PaddingBottom     = 10;
            root.BorderLeftWidth   = 10;
            root.BorderTopWidth    = 10;
            root.BorderRightWidth  = 10;
            root.BorderBottomWidth = 10;
            root.Width             = 100;
            root.Height            = 100;

            YogaNode root_child0 = new YogaNode();

            root_child0.PositionType = YogaPositionType.Absolute;
            root_child0.Left         = 0;
            root_child0.Top          = 0;
            root_child0.Width        = 50;
            root_child0.Height       = 50;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode();

            root_child1.PositionType = YogaPositionType.Absolute;
            root_child1.Right        = 0;
            root_child1.Bottom       = 0;
            root_child1.Width        = 50;
            root_child1.Height       = 50;
            root.Insert(1, root_child1);
            root.StyleDirection = YogaDirection.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 = YogaDirection.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);
        }
Пример #26
0
        public void Test_justify_content_column_center()
        {
            YogaConfig config = new YogaConfig();

            YogaNode root = new YogaNode(config);

            root.JustifyContent = YogaJustify.Center;
            root.Width          = 102;
            root.Height         = 102;

            YogaNode root_child0 = new YogaNode(config);

            root_child0.Height = 10;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);

            root_child1.Height = 10;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);

            root_child2.Height = 10;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(102f, root.LayoutWidth);
            Assert.AreEqual(102f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(36f, root_child0.LayoutY);
            Assert.AreEqual(102f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(46f, root_child1.LayoutY);
            Assert.AreEqual(102f, root_child1.LayoutWidth);
            Assert.AreEqual(10f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(56f, root_child2.LayoutY);
            Assert.AreEqual(102f, root_child2.LayoutWidth);
            Assert.AreEqual(10f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(102f, root.LayoutWidth);
            Assert.AreEqual(102f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(36f, root_child0.LayoutY);
            Assert.AreEqual(102f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(46f, root_child1.LayoutY);
            Assert.AreEqual(102f, root_child1.LayoutWidth);
            Assert.AreEqual(10f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(56f, root_child2.LayoutY);
            Assert.AreEqual(102f, root_child2.LayoutWidth);
            Assert.AreEqual(10f, root_child2.LayoutHeight);
        }
Пример #27
0
        public void Test_flex_basis_overrides_main_size()
        {
            YogaConfig config = new YogaConfig();

            YogaNode root = new YogaNode(config);

            root.Width  = 100;
            root.Height = 100;

            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(config);

            root_child1.FlexGrow = 1;
            root_child1.Height   = 10;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);

            root_child2.FlexGrow = 1;
            root_child2.Height   = 10;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.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(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(60f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(60f, root_child1.LayoutY);
            Assert.AreEqual(100f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(80f, root_child2.LayoutY);
            Assert.AreEqual(100f, root_child2.LayoutWidth);
            Assert.AreEqual(20f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.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(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(60f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(60f, root_child1.LayoutY);
            Assert.AreEqual(100f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(80f, root_child2.LayoutY);
            Assert.AreEqual(100f, root_child2.LayoutWidth);
            Assert.AreEqual(20f, root_child2.LayoutHeight);
        }
Пример #28
0
        public void Test_justify_content_row_space_evenly()
        {
            YogaConfig config = new YogaConfig();

            YogaNode root = new YogaNode(config);

            root.FlexDirection  = YogaFlexDirection.Row;
            root.JustifyContent = YogaJustify.SpaceEvenly;
            root.Width          = 102;
            root.Height         = 102;

            YogaNode root_child0 = new YogaNode(config);

            root_child0.Height = 10;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);

            root_child1.Height = 10;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);

            root_child2.Height = 10;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(102f, root.LayoutWidth);
            Assert.AreEqual(102f, root.LayoutHeight);

            Assert.AreEqual(26f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(0f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(51f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(0f, root_child1.LayoutWidth);
            Assert.AreEqual(10f, root_child1.LayoutHeight);

            Assert.AreEqual(77f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(0f, root_child2.LayoutWidth);
            Assert.AreEqual(10f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(102f, root.LayoutWidth);
            Assert.AreEqual(102f, root.LayoutHeight);

            Assert.AreEqual(77f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(0f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(51f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(0f, root_child1.LayoutWidth);
            Assert.AreEqual(10f, root_child1.LayoutHeight);

            Assert.AreEqual(26f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(0f, root_child2.LayoutWidth);
            Assert.AreEqual(10f, root_child2.LayoutHeight);
        }
Пример #29
0
        public void Test_align_content_stretch()
        {
            YogaNode root = new YogaNode();

            root.AlignContent = YogaAlign.Stretch;
            root.Wrap         = YogaWrap.Wrap;
            root.Width        = 100f;
            root.Height       = 100f;

            YogaNode root_child0 = new YogaNode();

            root_child0.Width = 50f;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode();

            root_child1.Width = 50f;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode();

            root_child2.Width = 50f;
            root.Insert(2, root_child2);

            YogaNode root_child3 = new YogaNode();

            root_child3.Width = 50f;
            root.Insert(3, root_child3);

            YogaNode root_child4 = new YogaNode();

            root_child4.Width = 50f;
            root.Insert(4, root_child4);
            root.StyleDirection = YogaDirection.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(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(50f, root_child0.LayoutWidth);
            Assert.AreEqual(0f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(50f, root_child1.LayoutWidth);
            Assert.AreEqual(0f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(50f, root_child2.LayoutWidth);
            Assert.AreEqual(0f, root_child2.LayoutHeight);

            Assert.AreEqual(0f, root_child3.LayoutX);
            Assert.AreEqual(0f, root_child3.LayoutY);
            Assert.AreEqual(50f, root_child3.LayoutWidth);
            Assert.AreEqual(0f, root_child3.LayoutHeight);

            Assert.AreEqual(0f, root_child4.LayoutX);
            Assert.AreEqual(0f, root_child4.LayoutY);
            Assert.AreEqual(50f, root_child4.LayoutWidth);
            Assert.AreEqual(0f, root_child4.LayoutHeight);

            root.StyleDirection = YogaDirection.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(0f, root_child0.LayoutY);
            Assert.AreEqual(50f, root_child0.LayoutWidth);
            Assert.AreEqual(0f, root_child0.LayoutHeight);

            Assert.AreEqual(50f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(50f, root_child1.LayoutWidth);
            Assert.AreEqual(0f, root_child1.LayoutHeight);

            Assert.AreEqual(50f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(50f, root_child2.LayoutWidth);
            Assert.AreEqual(0f, root_child2.LayoutHeight);

            Assert.AreEqual(50f, root_child3.LayoutX);
            Assert.AreEqual(0f, root_child3.LayoutY);
            Assert.AreEqual(50f, root_child3.LayoutWidth);
            Assert.AreEqual(0f, root_child3.LayoutHeight);

            Assert.AreEqual(50f, root_child4.LayoutX);
            Assert.AreEqual(0f, root_child4.LayoutY);
            Assert.AreEqual(50f, root_child4.LayoutWidth);
            Assert.AreEqual(0f, root_child4.LayoutHeight);
        }
Пример #30
0
        public void Test_display_none_with_child()
        {
            YogaNode root = new YogaNode();

            root.FlexDirection = YogaFlexDirection.Row;
            root.Width         = 100;
            root.Height        = 100;

            YogaNode root_child0 = new YogaNode();

            root_child0.FlexGrow   = 1;
            root_child0.FlexShrink = 1;
            root_child0.FlexBasis  = 0.Percent();
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode();

            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();

            root_child1_child0.FlexGrow   = 1;
            root_child1_child0.FlexShrink = 1;
            root_child1_child0.FlexBasis  = 0.Percent();
            root_child1_child0.Width      = 20;
            root_child1_child0.MinWidth   = 0;
            root_child1_child0.MinHeight  = 0;
            root_child1.Insert(0, root_child1_child0);

            YogaNode root_child2 = new YogaNode();

            root_child2.FlexGrow   = 1;
            root_child2.FlexShrink = 1;
            root_child2.FlexBasis  = 0.Percent();
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.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(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(50f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(0f, root_child1.LayoutWidth);
            Assert.AreEqual(0f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child1_child0.LayoutX);
            Assert.AreEqual(0f, root_child1_child0.LayoutY);
            Assert.AreEqual(0f, root_child1_child0.LayoutWidth);
            Assert.AreEqual(0f, root_child1_child0.LayoutHeight);

            Assert.AreEqual(50f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(50f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.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(0f, root_child0.LayoutY);
            Assert.AreEqual(50f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(0f, root_child1.LayoutWidth);
            Assert.AreEqual(0f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child1_child0.LayoutX);
            Assert.AreEqual(0f, root_child1_child0.LayoutY);
            Assert.AreEqual(0f, root_child1_child0.LayoutWidth);
            Assert.AreEqual(0f, root_child1_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(50f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);
        }