Пример #1
0
        public void Only_Calls_LayoutManager_InvalidateArrange_Once()
        {
            var target  = new Mock <ILayoutManager>();
            var control = new Decorator();
            var root    = new LayoutTestRoot
            {
                Child         = control,
                LayoutManager = target.Object,
            };

            root.Measure(Size.Infinity);
            root.Arrange(new Rect(root.DesiredSize));
            target.Invocations.Clear();

            control.InvalidateArrange();
            control.InvalidateArrange();

            target.Verify(x => x.InvalidateArrange(control), Times.Once());
        }
Пример #2
0
        public void Doesnt_Measure_Non_Invalidated_Root()
        {
            var control = new LayoutTestControl();
            var root    = new LayoutTestRoot {
                Child = control
            };

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

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

            Assert.False(root.Measured);
            Assert.False(root.Arranged);
            Assert.True(control.Measured);
            Assert.True(control.Arranged);
        }
Пример #3
0
        public void LayoutManager_Should_Properly_Arrange_Visuals_Even_When_There_Are_Issues_With_Previous_Arranged()
        {
            var nonArrageableTargets = Enumerable.Range(1, 10).Select(_ => new LayoutTestControl()).ToArray();
            var targets = Enumerable.Range(1, 10).Select(_ => new LayoutTestControl()).ToArray();

            StackPanel panel;

            var root = new LayoutTestRoot
            {
                Child = panel = new StackPanel()
            };

            panel.Children.AddRange(nonArrageableTargets);
            panel.Children.AddRange(targets);

            root.LayoutManager.ExecuteInitialLayoutPass();

            foreach (var c in panel.Children.OfType <LayoutTestControl>())
            {
                c.Measured = c.Arranged = false;
                c.InvalidateMeasure();
            }

            foreach (var c in nonArrageableTargets)
            {
                c.DoArrangeOverride = (l, s) =>
                {
                    //emulate a problem in the logic of a control that triggers
                    //invalidate measure during arrange
                    c.InvalidateMeasure();
                    return(new Size(100, 100));
                };
            }

            root.LayoutManager.ExecuteLayoutPass();

            //altough nonArrageableTargets has rubbish logic and can't be measured/arranged properly
            //layoutmanager should process properly other visuals
            Assert.All(targets, c => Assert.True(c.Arranged));
        }
Пример #4
0
        public void Arranges_Root_With_DesiredSize()
        {
            var root = new LayoutTestRoot
            {
                Width  = 100,
                Height = 100,
            };

            var arrangeSize = default(Size);

            root.DoArrangeOverride = (_, s) =>
            {
                arrangeSize = s;
                return(s);
            };

            root.LayoutManager.ExecuteInitialLayoutPass();
            Assert.Equal(new Size(100, 100), arrangeSize);

            root.Width = 120;

            root.LayoutManager.ExecuteLayoutPass();
            Assert.Equal(new Size(120, 100), arrangeSize);
        }