public void InvalidateMeasureTest3() { Border b = new Border(); LayoutPoker c = new LayoutPoker(); Size s = new Size(10, 10); b.Child = c; c.MeasureResult = s; b.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); Assert.AreEqual(new Size(10, 10), b.DesiredSize, "b desiredsize"); Assert.AreEqual(new Size(10, 10), c.DesiredSize, "c desiredsize"); c.MeasureResult = new Size(20, 20); c.MeasureArg = new Size(99, 99); b.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); Assert.AreEqual(new Size(10, 10), b.DesiredSize, "b desiredsize1"); Assert.AreEqual(new Size(10, 10), c.DesiredSize, "c desiredsize1"); Assert.AreEqual(new Size(99, 99), c.MeasureArg, "c measurearg"); b.InvalidateMeasure(); b.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); Assert.AreEqual(new Size(10, 10), b.DesiredSize, "b desiredsize1"); Assert.AreEqual(new Size(10, 10), c.DesiredSize, "c desiredsize1"); Assert.AreEqual(new Size(99, 99), c.MeasureArg, "c measurearg"); c.InvalidateMeasure(); b.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); Assert.AreEqual(new Size(20, 20), b.DesiredSize, "b desiredsize1"); Assert.AreEqual(new Size(20, 20), c.DesiredSize, "c desiredsize1"); Assert.AreEqual(new Size(Double.PositiveInfinity, Double.PositiveInfinity), c.MeasureArg, "c measurearg"); }
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"); }
public void InvalidateMeasureTest4() { Border b = new Border(); LayoutPoker c = new LayoutPoker(); Size s = new Size(10, 10); b.Child = c; c.MeasureResult = s; b.Measure(new Size(2, 2)); Assert.AreEqual(new Size(2, 2), b.DesiredSize, "b desiredsize"); Assert.AreEqual(new Size(2, 2), c.DesiredSize, "c desiredsize"); c.MeasureResult = new Size(20, 20); c.MeasureArg = new Size(99, 99); b.Measure(new Size(3, 3)); Assert.AreEqual(new Size(3, 3), b.DesiredSize, "b desiredsize1"); Assert.AreEqual(new Size(3, 3), c.DesiredSize, "c desiredsize1"); Assert.AreEqual(new Size(3, 3), c.MeasureArg, "c measurearg1"); c.MeasureArg = new Size(99, 99); b.Measure(new Size(3, 3)); Assert.AreEqual(new Size(3, 3), b.DesiredSize, "b desiredsize2"); Assert.AreEqual(new Size(3, 3), c.DesiredSize, "c desiredsize2"); Assert.AreEqual(new Size(99, 99), c.MeasureArg, "c measurearg2"); b.InvalidateMeasure(); c.MeasureArg = new Size(99, 99); b.Measure(new Size(3, 3)); Assert.AreEqual(new Size(3, 3), b.DesiredSize, "b desiredsize3"); Assert.AreEqual(new Size(3, 3), c.DesiredSize, "c desiredsize3"); Assert.AreEqual(new Size(99, 99), c.MeasureArg, "c measurearg3"); c.InvalidateMeasure(); b.Measure(new Size(3, 3)); Assert.AreEqual(new Size(3, 3), b.DesiredSize, "b desiredsize4"); Assert.AreEqual(new Size(3, 3), c.DesiredSize, "c desiredsize4"); Assert.AreEqual(new Size(3, 3), c.MeasureArg, "c measurearg4"); }
public void InvalidateMeasureTest4 () { Border b = new Border (); LayoutPoker c = new LayoutPoker (); Size s = new Size (10,10); b.Child = c; c.MeasureResult = s; b.Measure (new Size (2, 2)); Assert.AreEqual (new Size (2,2), b.DesiredSize, "b desiredsize"); Assert.AreEqual (new Size (2,2), c.DesiredSize, "c desiredsize"); c.MeasureResult = new Size (20,20); c.MeasureArg = new Size (99,99); b.Measure (new Size (3, 3)); Assert.AreEqual (new Size (3,3), b.DesiredSize, "b desiredsize1"); Assert.AreEqual (new Size (3,3), c.DesiredSize, "c desiredsize1"); Assert.AreEqual (new Size (3,3), c.MeasureArg, "c measurearg1"); c.MeasureArg = new Size (99,99); b.Measure (new Size (3, 3)); Assert.AreEqual (new Size (3,3), b.DesiredSize, "b desiredsize2"); Assert.AreEqual (new Size (3,3), c.DesiredSize, "c desiredsize2"); Assert.AreEqual (new Size (99,99), c.MeasureArg, "c measurearg2"); b.InvalidateMeasure (); c.MeasureArg = new Size (99,99); b.Measure (new Size (3, 3)); Assert.AreEqual (new Size (3,3), b.DesiredSize, "b desiredsize3"); Assert.AreEqual (new Size (3,3), c.DesiredSize, "c desiredsize3"); Assert.AreEqual (new Size (99,99), c.MeasureArg, "c measurearg3"); c.InvalidateMeasure (); b.Measure (new Size (3,3)); Assert.AreEqual (new Size (3,3), b.DesiredSize, "b desiredsize4"); Assert.AreEqual (new Size (3,3), c.DesiredSize, "c desiredsize4"); Assert.AreEqual (new Size (3,3), c.MeasureArg, "c measurearg4"); }
public void InvalidateMeasureTest3 () { Border b = new Border (); LayoutPoker c = new LayoutPoker (); Size s = new Size (10,10); b.Child = c; c.MeasureResult = s; b.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity)); Assert.AreEqual (new Size (10,10), b.DesiredSize, "b desiredsize"); Assert.AreEqual (new Size (10,10), c.DesiredSize, "c desiredsize"); c.MeasureResult = new Size (20,20); c.MeasureArg = new Size (99,99); b.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity)); Assert.AreEqual (new Size (10,10), b.DesiredSize, "b desiredsize1"); Assert.AreEqual (new Size (10,10), c.DesiredSize, "c desiredsize1"); Assert.AreEqual (new Size (99,99), c.MeasureArg, "c measurearg"); b.InvalidateMeasure (); b.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity)); Assert.AreEqual (new Size (10,10), b.DesiredSize, "b desiredsize1"); Assert.AreEqual (new Size (10,10), c.DesiredSize, "c desiredsize1"); Assert.AreEqual (new Size (99,99), c.MeasureArg, "c measurearg"); c.InvalidateMeasure (); b.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity)); Assert.AreEqual (new Size (20,20), b.DesiredSize, "b desiredsize1"); Assert.AreEqual (new Size (20,20), c.DesiredSize, "c desiredsize1"); Assert.AreEqual (new Size (Double.PositiveInfinity,Double.PositiveInfinity), c.MeasureArg, "c measurearg"); }
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"); }