Exemple #1
0
		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");
		}
Exemple #2
0
		public void ArrangeTooLongLocal_LineWrapMeasureReverseTest ()
		{
			Border b = new Border ();
			TextBlock tb = new TextBlock ();
			tb.TextWrapping = TextWrapping.Wrap;
			
			b.Child = tb;
			tb.Width = 44;
			tb.Text = "Hello and don't you forget Who I am";

			Assert.IsTrue (tb.ActualWidth > 32 && tb.ActualWidth < 34, "1. textblock.ActualWidth is " + tb.ActualWidth.ToString ());
			Assert.AreEqual (7, GetLineCount (tb.ActualHeight), "1. line count based on textblock.ActualHeight");
			//Assert.AreEqual (112, tb.ActualHeight, "1. tb.ActualHeight");
			
			//Console.WriteLine ("=========== Calling Border.Measure() ============");
			b.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
			//Console.WriteLine ("========= Done calling Border.Measure() =========");
			
			// FIXME: wrong after this point
			
			Assert.IsTrue (tb.ActualWidth < 10.9 && tb.ActualWidth > 10.8, "2. textblock.ActualWidth is " + tb.ActualWidth.ToString ());
			Assert.AreEqual (28, GetLineCount (tb.ActualHeight), "2. line count based on textblock.ActualHeight");
			//Assert.AreEqual (560, tb.ActualHeight, "2. tb.ActualHeight");

			tb.Text = "Hello and don't you forget Who I am.";

			Assert.IsTrue (tb.ActualWidth < 10.9 && tb.ActualWidth > 10.8, "3. textblock.ActualWidth is " + tb.ActualWidth.ToString ());
			Assert.AreEqual (29, GetLineCount (tb.ActualHeight), "3. line count based on textblock.ActualHeight");
			//Assert.AreEqual (576, tb.ActualHeight, "3. tb.ActualHeight");

			tb.Width = 70;
			b.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));

			Assert.IsTrue (tb.ActualWidth < 10.9 && tb.ActualWidth > 10.8, "4. textblock.ActualWidth is " + tb.ActualWidth.ToString ());
			Assert.AreEqual (29, GetLineCount (tb.ActualHeight), "4. line count based on textblock.ActualHeight");
			//Assert.AreEqual (576, tb.ActualHeight, "4. tb.ActualHeight");

			b.InvalidateMeasure ();
			tb.InvalidateMeasure ();

			b.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
			
			Assert.IsTrue (tb.ActualWidth < 10.9 && tb.ActualWidth > 10.8, "5. textblock.ActualWidth is " + tb.ActualWidth.ToString ());
			Assert.AreEqual (29, GetLineCount (tb.ActualHeight), "5. line count based on textblock.ActualHeight");
			//Assert.AreEqual (576, tb.ActualHeight, "5. tb.ActualHeight");
		}
Exemple #3
0
		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");
		}
Exemple #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");
		}
Exemple #5
0
		public void Measure_StretchFill_Test2 ()
		{
			Border b = new Border ();
		        Canvas c = (Canvas)XamlReader.Load (@"
<Canvas xmlns=""http://schemas.microsoft.com/client/2007"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
  <Path x:Name=""bar"" Width=""50"" Height=""50"" Stretch=""Fill"" Data=""F1 M 10,10 20,20 10,20"" StrokeLineJoin=""Round"" Stroke=""Blue""/>
</Canvas>");

			b.Child = c;
			Path bar = (Path)c.FindName ("bar");

			b.InvalidateMeasure ();
			b.Measure (new Size (300, 300));
			Assert.AreEqual (new Size (0,0), b.DesiredSize, "b desired0");
			Assert.AreEqual (new Size (0,0), bar.DesiredSize, "bar desired0");
			Assert.AreEqual (new Size (0,0), bar.RenderSize, "bar render0");

			Assert.AreEqual (new Size (50,50), new Size (bar.ActualWidth, bar.ActualHeight), "bar actual1");

			b.Arrange (new Rect (10, 10, 300, 300));
			Assert.AreEqual (new Size (0,0), b.DesiredSize, "b desired1");
			Assert.AreEqual (new Size (0,0), bar.DesiredSize, "bar desired1");
			Assert.AreEqual (new Size (0,0), bar.RenderSize, "bar render1");

			Assert.AreEqual (new Size (50,50), new Size (bar.ActualWidth, bar.ActualHeight), "bar actual1");
		}
Exemple #6
0
		public void AlignmentMeasureTest ()
		{
			Border b = new Border ();
			Border bc = new Border ();
			b.Child = bc;

			b.Measure (new Size (100,100));

			Assert.AreEqual (new Size (0, 0), b.DesiredSize, "deisred");

			b.Width = 10;
			b.Height = 10;

			b.InvalidateMeasure ();
			b.Measure (new Size (100,100));
			
			Assert.AreEqual (new Size (10, 10), b.DesiredSize, "b deisred0");
			Assert.AreEqual (new Size (0, 0), bc.DesiredSize, "bc deisred0");

			bc.HorizontalAlignment = HorizontalAlignment.Left;

			b.InvalidateMeasure ();
			b.Measure (new Size (100,100));
			
			Assert.AreEqual (new Size (10, 10), b.DesiredSize, "b deisred1");
			Assert.AreEqual (new Size (0, 0), bc.DesiredSize, "bc deisred1");
		}
Exemple #7
0
		public void ParentlessMeasureTest ()
		{
			Border b = new Border ();

			b.Measure (new Size (100,100));

			Assert.AreEqual (new Size (0, 0), b.DesiredSize, "deisred");

			b.Width = 10;
			b.Height = 10;
			
			b.InvalidateMeasure ();
			b.Measure (new Size (100,100));
			
			Assert.AreEqual (new Size (10, 10), b.DesiredSize, "deisred");
		}