Пример #1
0
        public void InvalidateArrangeTest()
        {
            Border      b = new Border();
            LayoutPoker c = new LayoutPoker();
            Size        s = new Size(10, 10);

            b.Padding = new Thickness(1, 1, 0, 0);
            b.Child   = c;
            b.Measure(s);

            Assert.AreEqual(new Size(0, 0), c.DesiredSize, "c DesiredSize");
            Assert.AreEqual(new Size(9, 9), c.MeasureArg, "c measure args");
            Assert.AreEqual(new Size(1, 1), b.DesiredSize, "b DesiredSize");
            Assert.AreEqual(0, b.ActualWidth);
            Assert.AreEqual(0, b.ActualHeight);
            Assert.AreEqual(0, c.ActualWidth);
            Assert.AreEqual(0, c.ActualHeight);

            c.ArrangeResult = new Size(20, 20);
            b.Arrange(new Rect(0, 0, 10, 10));

            Assert.AreEqual(new Size(0, 0), c.DesiredSize, "c DesiredSize");
            Assert.AreEqual(new Size(20, 20), c.RenderSize, "c render size");
            Assert.AreEqual(new Size(9, 9), c.ArrangeArg, "c measure args");
            Assert.AreEqual(new Size(1, 1), b.DesiredSize, "b DesiredSize");
            Assert.AreEqual(new Size(10, 10), b.RenderSize, "b render size");
            Assert.AreEqual(new Size(10, 10), new Size(b.ActualWidth, b.ActualHeight), "b actual");
            Assert.AreEqual(new Size(20, 20), new Size(c.ActualWidth, c.ActualHeight), "c actual");

            c.ArrangeResult = new Size(9, 9);
            b.Arrange(new Rect(0, 0, 10, 10));

            // Does not invalidate child
            b.InvalidateArrange();

            Assert.AreEqual(new Size(0, 0), c.DesiredSize, "c DesiredSize");
            Assert.AreEqual(new Size(20, 20), c.RenderSize, "c render size");
            Assert.AreEqual(new Size(9, 9), c.ArrangeArg, "c measure args");
            Assert.AreEqual(new Size(1, 1), b.DesiredSize, "b DesiredSize");
            Assert.AreEqual(new Size(10, 10), b.RenderSize, "b render size");
            Assert.AreEqual(new Size(10, 10), new Size(b.ActualWidth, b.ActualHeight), "b actual1");
            Assert.AreEqual(new Size(20, 20), new Size(c.ActualWidth, c.ActualHeight), "c actual1");

            c.InvalidateArrange();
            b.Arrange(new Rect(0, 0, 10, 10));

            Assert.AreEqual(new Size(0, 0), c.DesiredSize, "c DesiredSize");
            Assert.AreEqual(new Size(9, 9), c.RenderSize, "c render size");
            Assert.AreEqual(new Size(9, 9), c.ArrangeArg, "c measure args");
            Assert.AreEqual(new Size(1, 1), b.DesiredSize, "b DesiredSize");
            Assert.AreEqual(new Size(10, 10), b.RenderSize, "b render size");
            Assert.AreEqual(new Size(10, 10), new Size(b.ActualWidth, b.ActualHeight), "b actual2");
            Assert.AreEqual(new Size(9, 9), new Size(c.ActualWidth, c.ActualHeight), "c actual2");
        }
Пример #2
0
        public void BorderCallsLayoutTest()
        {
            var         parent = new Border();
            LayoutPoker c      = new LayoutPoker();

            parent.Child = c;

            c.Width  = 50;
            c.Height = 50;

            int measure_called = 0;
            int arrange_called = 0;

            c.Measured += (Size real) => {
                c.MeasureResult = real;
                measure_called++;
            };
            c.Arranged += (Size real) => {
                c.ArrangeResult = real;
                arrange_called++;
            };

            parent.Measure(new Size(100, 100));
            Assert.AreEqual(0, arrange_called, "arrange called 0");
            Assert.AreEqual(1, measure_called, "measure called 0");

            Assert.AreEqual(new Size(50, 50), c.DesiredSize, "c desired");
            Assert.AreEqual(new Size(50, 50), parent.DesiredSize, "parent desired");

            parent.Arrange(new Rect(0, 0, 100, 100));

            Assert.AreEqual(1, arrange_called, "arrange called 1");
            Assert.AreEqual(1, measure_called, "measure called 1");

            c.InvalidateMeasure();
            c.InvalidateArrange();
            parent.InvalidateArrange();
            parent.InvalidateMeasure();
            parent.Arrange(new Rect(0, 0, 100, 100));

            Assert.AreEqual(2, arrange_called, "arrange called 2");
            Assert.AreEqual(2, measure_called, "measure called 2");
        }
Пример #3
0
		public void InvalidateArrangeTest ()
		{
			Border b = new Border ();
			LayoutPoker c = new LayoutPoker ();
			Size s = new Size (10,10);
			
			b.Padding = new Thickness (1,1,0,0);
			b.Child = c;
			b.Measure (s);

			Assert.AreEqual (new Size (0,0), c.DesiredSize, "c DesiredSize");
			Assert.AreEqual (new Size (9,9), c.MeasureArg, "c measure args");
			Assert.AreEqual (new Size (1,1), b.DesiredSize, "b DesiredSize");
			Assert.AreEqual (0,b.ActualWidth);
			Assert.AreEqual (0,b.ActualHeight);
			Assert.AreEqual (0,c.ActualWidth);
			Assert.AreEqual (0,c.ActualHeight);
			
			c.ArrangeResult = new Size (20,20);
			b.Arrange (new Rect (0,0,10,10));

			Assert.AreEqual (new Size (0,0), c.DesiredSize, "c DesiredSize");
			Assert.AreEqual (new Size (20,20), c.RenderSize, "c render size");
			Assert.AreEqual (new Size (9,9), c.ArrangeArg, "c measure args");
			Assert.AreEqual (new Size (1,1), b.DesiredSize, "b DesiredSize");
			Assert.AreEqual (new Size (10,10), b.RenderSize, "b render size");
			Assert.AreEqual (new Size (10,10), new Size (b.ActualWidth, b.ActualHeight),"b actual");
			Assert.AreEqual (new Size (20,20), new Size (c.ActualWidth, c.ActualHeight), "c actual");

			c.ArrangeResult = new Size (9,9);
			b.Arrange (new Rect (0,0,10,10));

			// Does not invalidate child
			b.InvalidateArrange ();

			Assert.AreEqual (new Size (0,0), c.DesiredSize, "c DesiredSize");
			Assert.AreEqual (new Size (20,20), c.RenderSize, "c render size");
			Assert.AreEqual (new Size (9,9), c.ArrangeArg, "c measure args");
			Assert.AreEqual (new Size (1,1), b.DesiredSize, "b DesiredSize");
			Assert.AreEqual (new Size (10,10), b.RenderSize, "b render size");
			Assert.AreEqual (new Size (10,10), new Size (b.ActualWidth, b.ActualHeight),"b actual1");
			Assert.AreEqual (new Size (20,20), new Size (c.ActualWidth, c.ActualHeight), "c actual1");

			c.InvalidateArrange ();
			b.Arrange (new Rect (0,0,10,10));

			Assert.AreEqual (new Size (0,0), c.DesiredSize, "c DesiredSize");
			Assert.AreEqual (new Size (9,9), c.RenderSize, "c render size");
			Assert.AreEqual (new Size (9,9), c.ArrangeArg, "c measure args");
			Assert.AreEqual (new Size (1,1), b.DesiredSize, "b DesiredSize");
			Assert.AreEqual (new Size (10,10), b.RenderSize, "b render size");
			Assert.AreEqual (new Size (10,10), new Size (b.ActualWidth, b.ActualHeight),"b actual2");
			Assert.AreEqual (new Size (9,9), new Size (c.ActualWidth, c.ActualHeight), "c actual2");
		}
Пример #4
0
		public void BorderCallsLayoutTest ()
		{
			var parent = new Border ();
			LayoutPoker c = new LayoutPoker ();
			parent.Child = c;

			c.Width = 50;
			c.Height = 50;
			
			int measure_called = 0;
			int arrange_called = 0;
			c.Measured += (Size real) => { 
				c.MeasureResult = real; 
				measure_called++;
			};
			c.Arranged += (Size real) => {
				c.ArrangeResult = real;
				arrange_called++;
			};

			parent.Measure (new Size (100, 100));
			Assert.AreEqual (0, arrange_called, "arrange called 0");
			Assert.AreEqual (1, measure_called, "measure called 0");

			Assert.AreEqual (new Size (50,50), c.DesiredSize, "c desired");
			Assert.AreEqual (new Size (50,50), parent.DesiredSize, "parent desired");

			parent.Arrange (new Rect (0, 0, 100, 100));

			Assert.AreEqual (1, arrange_called, "arrange called 1");
			Assert.AreEqual (1, measure_called, "measure called 1");

			c.InvalidateMeasure ();
			c.InvalidateArrange ();
			parent.InvalidateArrange ();
			parent.InvalidateMeasure ();
			parent.Arrange (new Rect (0, 0, 100, 100));

			Assert.AreEqual (2, arrange_called, "arrange called 2");
			Assert.AreEqual (2, measure_called, "measure called 2");
		}