Переглянути джерело

Graphics.cs: Added FillMode tests
Brush.cs: Added TextureBrush tests

svn path=/trunk/mcs/; revision=51796

Vladimir Krasnov 20 роки тому
батько
коміт
73c953ff5d

+ 91 - 0
mcs/class/System.Drawing/Test/DrawingTest/Test/Brush.cs

@@ -9,6 +9,9 @@ namespace Test.Sys.Drawing
 	/// <summary>
 	/// Summary description for Brush.
 	/// </summary>
+	
+	#region BrushFixture
+
 	[TestFixture]
 	public class BrushFixture
 	{
@@ -28,4 +31,92 @@ namespace Test.Sys.Drawing
 			t.Show ();
 		}
 	}
+
+	#endregion
+
+	#region TextureBrushFixture
+	[TestFixture]
+	public class GraphicsFixtureFillModes {
+		protected DrawingTest t;
+		protected int TOLERANCE = 3;
+		Image bmp;
+		Image bmp2;
+
+		[SetUp]
+		public virtual void SetUp() {
+			SetUp("TextureBrushFixture");
+		}
+		public virtual void SetUp(string ownerClass) {
+			t = DrawingTest.Create(512, 512, ownerClass);
+			bmp = Bitmap.FromFile(@"..\..\bitmap50.png");
+			bmp2 = Bitmap.FromFile(@"..\..\bitmap25.png");
+		}
+		[TearDown]
+		public void TearDown() {
+		}
+
+		[Test]
+		public void WrapMode_1() {
+			TextureBrush b = new TextureBrush( bmp );
+			Assert.AreEqual(WrapMode.Tile, b.WrapMode);
+		}
+		[Test]
+		public void TextureBush_1() {
+			TextureBrush b = new TextureBrush( bmp );
+			t.Graphics.FillRectangle( b, 100, 100, 300, 300 );
+			t.Show();
+			Assert.IsTrue(t.PDCompare());
+		}
+		[Test]
+		public void TextureBush_2() {
+			TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipX );
+			t.Graphics.FillRectangle( b, 100, 100, 300, 300 );
+			t.Show();
+			Assert.IsTrue(t.PDCompare());
+		}
+		[Test]
+		public void TextureBush_3() {
+			TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipY );
+			t.Graphics.FillRectangle( b, 100, 100, 300, 300 );
+			t.Show();
+			Assert.IsTrue(t.PDCompare());
+		}
+		[Test]
+		public void TextureBush_4() {
+			TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipXY );
+			t.Graphics.FillRectangle( b, 100, 100, 300, 300 );
+			t.Show();
+			Assert.IsTrue(t.PDCompare());
+		}
+		[Test]
+		public void TextureBush_5() {
+			TextureBrush b = new TextureBrush( bmp2, new Rectangle(100, 100, 50, 50) );
+			t.Graphics.FillRectangle( b, 100, 100, 300, 300 );
+			t.Show();
+			Assert.IsTrue(t.PDCompare());
+		}
+		[Test]
+		public void TextureBush_6() {
+			TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipX, new Rectangle(100, 100, 50, 50) );
+			t.Graphics.FillRectangle( b, 100, 100, 300, 300 );
+			t.Show();
+			Assert.IsTrue(t.PDCompare());
+		}
+		[Test]
+		public void TextureBush_7() {
+			TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipY, new Rectangle(100, 100, 50, 50) );
+			t.Graphics.FillRectangle( b, 100, 100, 300, 300 );
+			t.Show();
+			Assert.IsTrue(t.PDCompare());
+		}
+		[Test]
+		public void TextureBush_8() {
+			TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipXY, new Rectangle(100, 100, 50, 50) );
+			t.Graphics.FillRectangle( b, 100, 100, 300, 300 );
+			t.Show();
+			Assert.IsTrue(t.PDCompare());
+		}
+	}
+	#endregion
+
 }

+ 5 - 0
mcs/class/System.Drawing/Test/DrawingTest/Test/ChangeLog

@@ -1,3 +1,8 @@
+2005-10-17 Vladimir Krasnov <[email protected]>
+	
+	* Graphics.cs: Added FillMode tests
+	* Brush.cs:  Added TextureBrush tests 
+
 2005-09-21 Vladimir Krasnov <[email protected]>
 	
 	* Graphics.cs: Added tests for DrawImage

+ 128 - 1
mcs/class/System.Drawing/Test/DrawingTest/Test/Graphics.cs

@@ -416,6 +416,133 @@ namespace Test.Sys.Drawing.GraphicsFixtures {
 	}
 	#endregion
 
+	#region GraphicsFixtureFillModes
+	[TestFixture]
+	public class GraphicsFixtureFillModes {
+		protected DrawingTest t;
+		protected int TOLERANCE = 3; //in %;
+
+		[SetUp]
+		public virtual void SetUp() {
+			SetUp("GraphicsFixtureFillModes");
+		}
+		public virtual void SetUp(string ownerClass) {
+			t = DrawingTest.Create(512, 512, ownerClass);
+		}
+		[TearDown]
+		public void TearDown() {
+		}
+
+		[Test]
+		public void FillModeAlternate() {
+			GraphicsPath p = new GraphicsPath();
+			Assert.AreEqual(FillMode.Alternate, p.FillMode);
+		}
+		[Test]
+		public void FillModeAlternate_1() {
+			Point [] p = new Point[] {
+										 new Point(50, 100),
+										 new Point(70, 10),
+										 new Point(90, 100),
+										 new Point(140, 10),
+										 new Point(150, 100),
+										 new Point(170, 10),
+										 new Point(50, 100)
+									 };
+
+			GraphicsPath path = new GraphicsPath();
+			path.AddLines( p );
+			path.FillMode = FillMode.Alternate;
+			t.Graphics.FillPath( Brushes.Blue, path );
+			t.Show();
+			Assert.IsTrue(t.PDCompare());
+		}
+		[Test]
+		public void FillModeAlternate_2() {
+
+			Rectangle r1 = new Rectangle(100, 100, 100, 100);
+			Rectangle r2 = new Rectangle(125, 125, 50, 50);
+			GraphicsPath path = new GraphicsPath();
+			path.AddRectangle( r1 );
+			path.AddRectangle( r2 );
+			path.FillMode = FillMode.Alternate;
+			t.Graphics.FillPath( Brushes.Blue, path );
+			t.Show();
+			Assert.IsTrue(t.PDCompare());
+		}
+		[Test]
+		public void FillModeAlternate_3() {
+			Point [] p = new Point[] {
+										 new Point(50, 100),
+										 new Point(150, 50),
+										 new Point(250, 100),
+										 new Point(50, 75),
+										 new Point(250, 50),
+										 new Point(50, 100)
+									 };
+
+			GraphicsPath path = new GraphicsPath();
+			path.AddLines( p );
+			path.FillMode = FillMode.Alternate;
+			t.Graphics.FillPath( Brushes.Blue, path );
+			t.Show();
+			Assert.IsTrue(t.PDCompare());
+		}
+		[Test]
+		public void FillModeWinding_1() {
+			Point [] p = new Point[] {
+										 new Point(50, 100),
+										 new Point(70, 10),
+										 new Point(90, 100),
+										 new Point(140, 10),
+										 new Point(150, 100),
+										 new Point(170, 10),
+										 new Point(50, 100)
+									 };
+
+			GraphicsPath path = new GraphicsPath();
+			path.AddLines( p );
+			path.FillMode = FillMode.Winding;
+			t.Graphics.FillPath( Brushes.Blue, path );
+			t.Show();
+			Assert.IsTrue(t.PDCompare());
+		}
+		[Test]
+		public void FillModeWinding_2() {
+
+			Rectangle r1 = new Rectangle(100, 100, 100, 100);
+			Rectangle r2 = new Rectangle(125, 125, 50, 50);
+			GraphicsPath path = new GraphicsPath();
+			path.AddRectangle( r1 );
+			path.AddRectangle( r2 );
+			path.FillMode = FillMode.Winding;
+			t.Graphics.FillPath( Brushes.Blue, path );
+			t.Show();
+			Assert.IsTrue(t.PDCompare());
+		}
+		[Test]
+		public void FillModeWinding_3() {
+			Point [] p = new Point[] {
+										 new Point(50, 100),
+										 new Point(150, 50),
+										 new Point(250, 100),
+										 new Point(50, 75),
+										 new Point(250, 50),
+										 new Point(50, 100)
+									 };
+
+			GraphicsPath path = new GraphicsPath();
+			path.AddLines( p );
+			path.FillMode = FillMode.Winding;
+			t.Graphics.FillPath( Brushes.Blue, path );
+			t.Show();
+			Assert.IsTrue(t.PDCompare());
+		}
+
+	}
+	#endregion
+
+
 	#region GraphicsFixture
 	/// <summary>
 	/// Summary description for Graphics.
@@ -433,7 +560,7 @@ namespace Test.Sys.Drawing.GraphicsFixtures {
 		public virtual void SetUp(string ownerClass) {
 			t = DrawingTest.Create(512, 512, ownerClass);
 
-			// hashtable of differents tolerance values for specified tests.
+			// hashtable of differents tolerance values for specified tests. (for fft comparer)
 			st["DrawArcTest:6"] = TOLERANCE * 2.5f;
 			st["DrawCurveTestF:4"] = TOLERANCE * 2f;
 			st["DrawPolygonPoint:2"] = TOLERANCE * 2f;