Exemple #1
0
        public void LayoutManager_Should_Prevent_Infinite_Loop_On_Arrange()
        {
            var control = new LayoutTestControl();
            var root    = new LayoutTestRoot {
                Child = control
            };

            root.LayoutManager.ExecuteInitialLayoutPass(root);
            control.Arranged = false;

            int cnt    = 0;
            int maxcnt = 100;

            control.DoArrangeOverride = (l, s) =>
            {
                //emulate a problem in the logic of a control that triggers
                //invalidate measure during arrange
                //it can lead to infinity loop in layoutmanager
                if (++cnt < maxcnt)
                {
                    control.InvalidateArrange();
                }

                return(new Size(100, 100));
            };

            control.InvalidateArrange();

            root.LayoutManager.ExecuteLayoutPass();

            Assert.True(cnt < 100);
        }
Exemple #2
0
        public void Arranges_InvalidateArranged_Control()
        {
            var control = new LayoutTestControl();
            var root    = new LayoutTestRoot {
                Child = control
            };

            root.LayoutManager.ExecuteInitialLayoutPass(root);
            control.Measured = control.Arranged = false;

            control.InvalidateArrange();
            root.LayoutManager.ExecuteLayoutPass();

            Assert.False(control.Measured);
            Assert.True(control.Arranged);
        }