Exemplo n.º 1
0
        public void testInvalidatesFullTreeWhenParentWidthChanges()
        {
            CSSNode root = new CSSNode();
            CSSNode c0   = new CSSNode();
            CSSNode c1   = new CSSNode();
            CSSNode c0c0 = new CSSNode();
            CSSNode c1c0 = new CSSNode();

            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c0.addChildAt(c0c0, 0);
            c1.addChildAt(c1c0, 0);

            root.calculateLayout();
            markLayoutAppliedForTree(root);

            c0.Height = 200;
            root.calculateLayout();

            Assert.IsTrue(root.HasNewLayout);
            Assert.IsTrue(c0.HasNewLayout);
            Assert.IsTrue(c0c0.HasNewLayout);

            Assert.IsTrue(c1.HasNewLayout);
            Assert.IsFalse(c1c0.HasNewLayout);
        }
Exemplo n.º 2
0
        public void testInvalidatesCacheWhenChildAdded()
        {
            CSSNode root = new CSSNode();
            CSSNode c0   = new CSSNode();
            CSSNode c1   = new CSSNode();
            CSSNode c0c0 = new CSSNode();
            CSSNode c0c1 = new CSSNode();
            CSSNode c1c0 = new CSSNode();

            c0c1.Width  = 200;
            c0c1.Height = 200;
            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c0.addChildAt(c0c0, 0);
            c0c0.addChildAt(c1c0, 0);

            root.calculateLayout();
            markLayoutAppliedForTree(root);

            c0.addChildAt(c0c1, 1);

            root.calculateLayout();
            Assert.IsTrue(root.HasNewLayout);
            Assert.IsTrue(c0.HasNewLayout);
            Assert.IsTrue(c0c1.HasNewLayout);

            Assert.IsTrue(c0c0.HasNewLayout);
            Assert.IsTrue(c1.HasNewLayout);

            Assert.IsFalse(c1c0.HasNewLayout);
        }
Exemplo n.º 3
0
        public void testInvalidatesCacheWhenChildAdded()
        {
            CSSNode root = new CSSNode();
            CSSNode c0 = new CSSNode();
            CSSNode c1 = new CSSNode();
            CSSNode c0c0 = new CSSNode();
            CSSNode c0c1 = new CSSNode();
            CSSNode c1c0 = new CSSNode();
            c0c1.Width = 200;
            c0c1.Height = 200;
            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c0.addChildAt(c0c0, 0);
            c0c0.addChildAt(c1c0, 0);

            root.calculateLayout();
            markLayoutAppliedForTree(root);

            c0.addChildAt(c0c1, 1);

            root.calculateLayout();
            Assert.IsTrue(root.HasNewLayout);
            Assert.IsTrue(c0.HasNewLayout);
            Assert.IsTrue(c0c1.HasNewLayout);

            Assert.IsTrue(c0c0.HasNewLayout);
            Assert.IsTrue(c1.HasNewLayout);

            Assert.IsFalse(c1c0.HasNewLayout);
        }
Exemplo n.º 4
0
        public void testCachesFullTree()
        {
            CSSNode root = new CSSNode();
            CSSNode c0 = new CSSNode();
            CSSNode c1 = new CSSNode();
            CSSNode c0c0 = new CSSNode();
            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c0.addChildAt(c0c0, 0);

            root.calculateLayout();
            assertTreeHasNewLayout(true, root);
            markLayoutAppliedForTree(root);

            root.calculateLayout();
            Assert.IsTrue(root.HasNewLayout);
            assertTreeHasNewLayout(false, c0);
            assertTreeHasNewLayout(false, c1);
        }
Exemplo n.º 5
0
        public void testCachesFullTree()
        {
            CSSNode root = new CSSNode();
            CSSNode c0   = new CSSNode();
            CSSNode c1   = new CSSNode();
            CSSNode c0c0 = new CSSNode();

            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c0.addChildAt(c0c0, 0);

            root.calculateLayout();
            assertTreeHasNewLayout(true, root);
            markLayoutAppliedForTree(root);

            root.calculateLayout();
            Assert.IsTrue(root.HasNewLayout);
            assertTreeHasNewLayout(false, c0);
            assertTreeHasNewLayout(false, c1);
        }
Exemplo n.º 6
0
        public void testInvalidateCacheWhenHeightChangesPosition()
        {
            CSSNode root = new CSSNode();
            CSSNode c0 = new CSSNode();
            CSSNode c1 = new CSSNode();
            CSSNode c1c0 = new CSSNode();
            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c1.addChildAt(c1c0, 0);

            root.calculateLayout();
            markLayoutAppliedForTree(root);

            c0.Height = 100;
            root.calculateLayout();

            Assert.IsTrue(root.HasNewLayout);
            Assert.IsTrue(c0.HasNewLayout);
            Assert.IsTrue(c1.HasNewLayout);
            Assert.IsFalse(c1c0.HasNewLayout);
        }
Exemplo n.º 7
0
        public void testDoesNotInvalidateCacheWhenPropertyIsTheSame()
        {
            CSSNode root = new CSSNode();
            CSSNode c0 = new CSSNode();
            CSSNode c1 = new CSSNode();
            CSSNode c0c0 = new CSSNode();
            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c0.addChildAt(c0c0, 0);
            root.Width = 200;

            root.calculateLayout();
            markLayoutAppliedForTree(root);

            root.Width = 200;
            root.calculateLayout();

            Assert.IsTrue(root.HasNewLayout);
            assertTreeHasNewLayout(false, c0);
            assertTreeHasNewLayout(false, c1);
        }
Exemplo n.º 8
0
        public void testInvalidateCacheWhenHeightChangesPosition()
        {
            CSSNode root = new CSSNode();
            CSSNode c0   = new CSSNode();
            CSSNode c1   = new CSSNode();
            CSSNode c1c0 = new CSSNode();

            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c1.addChildAt(c1c0, 0);

            root.calculateLayout();
            markLayoutAppliedForTree(root);

            c0.Height = 100;
            root.calculateLayout();

            Assert.IsTrue(root.HasNewLayout);
            Assert.IsTrue(c0.HasNewLayout);
            Assert.IsTrue(c1.HasNewLayout);
            Assert.IsFalse(c1c0.HasNewLayout);
        }
Exemplo n.º 9
0
        public void testDoesNotInvalidateCacheWhenPropertyIsTheSame()
        {
            CSSNode root = new CSSNode();
            CSSNode c0   = new CSSNode();
            CSSNode c1   = new CSSNode();
            CSSNode c0c0 = new CSSNode();

            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c0.addChildAt(c0c0, 0);
            root.Width = 200;

            root.calculateLayout();
            markLayoutAppliedForTree(root);

            root.Width = 200;
            root.calculateLayout();

            Assert.IsTrue(root.HasNewLayout);
            assertTreeHasNewLayout(false, c0);
            assertTreeHasNewLayout(false, c1);
        }
Exemplo n.º 10
0
        public void testInvalidatesCacheWhenEnumPropertyChanges()
        {
            CSSNode root = new CSSNode();
            CSSNode c0   = new CSSNode();
            CSSNode c1   = new CSSNode();
            CSSNode c0c0 = new CSSNode();

            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c0.addChildAt(c0c0, 0);

            root.calculateLayout();
            markLayoutAppliedForTree(root);

            c1.AlignSelf = CSSAlign.Center;
            root.calculateLayout();

            Assert.IsTrue(root.HasNewLayout);
            Assert.IsTrue(c1.HasNewLayout);

            Assert.IsTrue(c0.HasNewLayout);
            Assert.IsFalse(c0c0.HasNewLayout);
        }
Exemplo n.º 11
0
        public void testInvalidatesCacheWhenFloatPropertyChanges()
        {
            CSSNode root = new CSSNode();
            CSSNode c0   = new CSSNode();
            CSSNode c1   = new CSSNode();
            CSSNode c0c0 = new CSSNode();

            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c0.addChildAt(c0c0, 0);

            root.calculateLayout();
            markLayoutAppliedForTree(root);

            c1.SetMargin(CSSSpacingType.Left, 10);
            root.calculateLayout();

            Assert.IsTrue(root.HasNewLayout);
            Assert.IsTrue(c1.HasNewLayout);

            Assert.IsTrue(c0.HasNewLayout);
            Assert.IsFalse(c0c0.HasNewLayout);
        }
Exemplo n.º 12
0
        public void testInvalidatesOnNewMeasureFunction()
        {
            CSSNode root = new CSSNode();
            CSSNode c0   = new CSSNode();
            CSSNode c1   = new CSSNode();
            CSSNode c0c0 = new CSSNode();

            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c0.addChildAt(c0c0, 0);

            root.calculateLayout();
            markLayoutAppliedForTree(root);

            c1.setMeasureFunction((node, width, height) => new MeasureOutput(100, 20));

            root.calculateLayout();

            Assert.IsTrue(root.HasNewLayout);
            Assert.IsTrue(c1.HasNewLayout);

            Assert.IsTrue(c0.HasNewLayout);
            Assert.IsFalse(c0c0.HasNewLayout);
        }
Exemplo n.º 13
0
        public void testInvalidatesCacheWhenEnumPropertyChanges()
        {
            CSSNode root = new CSSNode();
            CSSNode c0 = new CSSNode();
            CSSNode c1 = new CSSNode();
            CSSNode c0c0 = new CSSNode();
            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c0.addChildAt(c0c0, 0);

            root.calculateLayout();
            markLayoutAppliedForTree(root);

            c1.AlignSelf = CSSAlign.Center;
            root.calculateLayout();

            Assert.IsTrue(root.HasNewLayout);
            Assert.IsTrue(c1.HasNewLayout);

            Assert.IsTrue(c0.HasNewLayout);
            Assert.IsFalse(c0c0.HasNewLayout);
        }
Exemplo n.º 14
0
        public void testInvalidatesOnNewMeasureFunction()
        {
            CSSNode root = new CSSNode();
            CSSNode c0 = new CSSNode();
            CSSNode c1 = new CSSNode();
            CSSNode c0c0 = new CSSNode();
            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c0.addChildAt(c0c0, 0);

            root.calculateLayout();
            markLayoutAppliedForTree(root);

            c1.setMeasureFunction((node, width, height) => new MeasureOutput(100, 20));

            root.calculateLayout();

            Assert.IsTrue(root.HasNewLayout);
            Assert.IsTrue(c1.HasNewLayout);

            Assert.IsTrue(c0.HasNewLayout);
            Assert.IsFalse(c0c0.HasNewLayout);
        }
Exemplo n.º 15
0
        public void testInvalidatesFullTreeWhenParentWidthChanges()
        {
            CSSNode root = new CSSNode();
            CSSNode c0 = new CSSNode();
            CSSNode c1 = new CSSNode();
            CSSNode c0c0 = new CSSNode();
            CSSNode c1c0 = new CSSNode();
            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c0.addChildAt(c0c0, 0);
            c1.addChildAt(c1c0, 0);

            root.calculateLayout();
            markLayoutAppliedForTree(root);

            c0.Height = 200;
            root.calculateLayout();

            Assert.IsTrue(root.HasNewLayout);
            Assert.IsTrue(c0.HasNewLayout);
            Assert.IsTrue(c0c0.HasNewLayout);

            Assert.IsTrue(c1.HasNewLayout);
            Assert.IsFalse(c1c0.HasNewLayout);
        }
Exemplo n.º 16
0
        public void testInvalidatesCacheWhenFloatPropertyChanges()
        {
            CSSNode root = new CSSNode();
            CSSNode c0 = new CSSNode();
            CSSNode c1 = new CSSNode();
            CSSNode c0c0 = new CSSNode();
            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c0.addChildAt(c0c0, 0);

            root.calculateLayout();
            markLayoutAppliedForTree(root);

            c1.SetMargin(CSSSpacingType.Left, 10);
            root.calculateLayout();

            Assert.IsTrue(root.HasNewLayout);
            Assert.IsTrue(c1.HasNewLayout);

            Assert.IsTrue(c0.HasNewLayout);
            Assert.IsFalse(c0c0.HasNewLayout);
        }