Graphics.cs: Added FillMode tests
authorVladimir Krasnov <krasnov@mono-cvs.ximian.com>
Mon, 17 Oct 2005 10:43:53 +0000 (10:43 -0000)
committerVladimir Krasnov <krasnov@mono-cvs.ximian.com>
Mon, 17 Oct 2005 10:43:53 +0000 (10:43 -0000)
Brush.cs:  Added TextureBrush tests

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

mcs/class/System.Drawing/Test/DrawingTest/Test/Brush.cs
mcs/class/System.Drawing/Test/DrawingTest/Test/ChangeLog
mcs/class/System.Drawing/Test/DrawingTest/Test/Graphics.cs

index a7275958c3932c001d73490600b0bd1b43dfb333..03e051dff593610229000685eb13b47b51c42362 100644 (file)
@@ -9,6 +9,9 @@ namespace Test.Sys.Drawing
        /// <summary>\r
        /// Summary description for Brush.\r
        /// </summary>\r
+       \r
+       #region BrushFixture\r
+\r
        [TestFixture]\r
        public class BrushFixture\r
        {\r
@@ -28,4 +31,92 @@ namespace Test.Sys.Drawing
                        t.Show ();\r
                }\r
        }\r
+\r
+       #endregion\r
+\r
+       #region TextureBrushFixture\r
+       [TestFixture]\r
+       public class GraphicsFixtureFillModes {\r
+               protected DrawingTest t;\r
+               protected int TOLERANCE = 3;\r
+               Image bmp;\r
+               Image bmp2;\r
+\r
+               [SetUp]\r
+               public virtual void SetUp() {\r
+                       SetUp("TextureBrushFixture");\r
+               }\r
+               public virtual void SetUp(string ownerClass) {\r
+                       t = DrawingTest.Create(512, 512, ownerClass);\r
+                       bmp = Bitmap.FromFile(@"..\..\bitmap50.png");\r
+                       bmp2 = Bitmap.FromFile(@"..\..\bitmap25.png");\r
+               }\r
+               [TearDown]\r
+               public void TearDown() {\r
+               }\r
+\r
+               [Test]\r
+               public void WrapMode_1() {\r
+                       TextureBrush b = new TextureBrush( bmp );\r
+                       Assert.AreEqual(WrapMode.Tile, b.WrapMode);\r
+               }\r
+               [Test]\r
+               public void TextureBush_1() {\r
+                       TextureBrush b = new TextureBrush( bmp );\r
+                       t.Graphics.FillRectangle( b, 100, 100, 300, 300 );\r
+                       t.Show();\r
+                       Assert.IsTrue(t.PDCompare());\r
+               }\r
+               [Test]\r
+               public void TextureBush_2() {\r
+                       TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipX );\r
+                       t.Graphics.FillRectangle( b, 100, 100, 300, 300 );\r
+                       t.Show();\r
+                       Assert.IsTrue(t.PDCompare());\r
+               }\r
+               [Test]\r
+               public void TextureBush_3() {\r
+                       TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipY );\r
+                       t.Graphics.FillRectangle( b, 100, 100, 300, 300 );\r
+                       t.Show();\r
+                       Assert.IsTrue(t.PDCompare());\r
+               }\r
+               [Test]\r
+               public void TextureBush_4() {\r
+                       TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipXY );\r
+                       t.Graphics.FillRectangle( b, 100, 100, 300, 300 );\r
+                       t.Show();\r
+                       Assert.IsTrue(t.PDCompare());\r
+               }\r
+               [Test]\r
+               public void TextureBush_5() {\r
+                       TextureBrush b = new TextureBrush( bmp2, new Rectangle(100, 100, 50, 50) );\r
+                       t.Graphics.FillRectangle( b, 100, 100, 300, 300 );\r
+                       t.Show();\r
+                       Assert.IsTrue(t.PDCompare());\r
+               }\r
+               [Test]\r
+               public void TextureBush_6() {\r
+                       TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipX, new Rectangle(100, 100, 50, 50) );\r
+                       t.Graphics.FillRectangle( b, 100, 100, 300, 300 );\r
+                       t.Show();\r
+                       Assert.IsTrue(t.PDCompare());\r
+               }\r
+               [Test]\r
+               public void TextureBush_7() {\r
+                       TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipY, new Rectangle(100, 100, 50, 50) );\r
+                       t.Graphics.FillRectangle( b, 100, 100, 300, 300 );\r
+                       t.Show();\r
+                       Assert.IsTrue(t.PDCompare());\r
+               }\r
+               [Test]\r
+               public void TextureBush_8() {\r
+                       TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipXY, new Rectangle(100, 100, 50, 50) );\r
+                       t.Graphics.FillRectangle( b, 100, 100, 300, 300 );\r
+                       t.Show();\r
+                       Assert.IsTrue(t.PDCompare());\r
+               }\r
+       }\r
+       #endregion\r
+\r
 }\r
index b7a9306627e2b238dac24a6849504b892629fcd5..74622a83900b611dc587a2ec6f6f46adbb53fb67 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-17 Vladimir Krasnov <vladimirk@mainsoft.com>\r
+       \r
+       * Graphics.cs: Added FillMode tests\r
+       * Brush.cs:  Added TextureBrush tests \r
+\r
 2005-09-21 Vladimir Krasnov <vladimirk@mainsoft.com>\r
        \r
        * Graphics.cs: Added tests for DrawImage\r
index 638ba2a623ae78dc116d2f297ea6cba22e3af51e..ba8ab19228709609c95793d705670d30d3b8ec20 100644 (file)
@@ -416,6 +416,133 @@ namespace Test.Sys.Drawing.GraphicsFixtures {
        }\r
        #endregion\r
 \r
+       #region GraphicsFixtureFillModes\r
+       [TestFixture]\r
+       public class GraphicsFixtureFillModes {\r
+               protected DrawingTest t;\r
+               protected int TOLERANCE = 3; //in %;\r
+\r
+               [SetUp]\r
+               public virtual void SetUp() {\r
+                       SetUp("GraphicsFixtureFillModes");\r
+               }\r
+               public virtual void SetUp(string ownerClass) {\r
+                       t = DrawingTest.Create(512, 512, ownerClass);\r
+               }\r
+               [TearDown]\r
+               public void TearDown() {\r
+               }\r
+\r
+               [Test]\r
+               public void FillModeAlternate() {\r
+                       GraphicsPath p = new GraphicsPath();\r
+                       Assert.AreEqual(FillMode.Alternate, p.FillMode);\r
+               }\r
+               [Test]\r
+               public void FillModeAlternate_1() {\r
+                       Point [] p = new Point[] {\r
+                                                                                new Point(50, 100),\r
+                                                                                new Point(70, 10),\r
+                                                                                new Point(90, 100),\r
+                                                                                new Point(140, 10),\r
+                                                                                new Point(150, 100),\r
+                                                                                new Point(170, 10),\r
+                                                                                new Point(50, 100)\r
+                                                                        };\r
+\r
+                       GraphicsPath path = new GraphicsPath();\r
+                       path.AddLines( p );\r
+                       path.FillMode = FillMode.Alternate;\r
+                       t.Graphics.FillPath( Brushes.Blue, path );\r
+                       t.Show();\r
+                       Assert.IsTrue(t.PDCompare());\r
+               }\r
+               [Test]\r
+               public void FillModeAlternate_2() {\r
+\r
+                       Rectangle r1 = new Rectangle(100, 100, 100, 100);\r
+                       Rectangle r2 = new Rectangle(125, 125, 50, 50);\r
+                       GraphicsPath path = new GraphicsPath();\r
+                       path.AddRectangle( r1 );\r
+                       path.AddRectangle( r2 );\r
+                       path.FillMode = FillMode.Alternate;\r
+                       t.Graphics.FillPath( Brushes.Blue, path );\r
+                       t.Show();\r
+                       Assert.IsTrue(t.PDCompare());\r
+               }\r
+               [Test]\r
+               public void FillModeAlternate_3() {\r
+                       Point [] p = new Point[] {\r
+                                                                                new Point(50, 100),\r
+                                                                                new Point(150, 50),\r
+                                                                                new Point(250, 100),\r
+                                                                                new Point(50, 75),\r
+                                                                                new Point(250, 50),\r
+                                                                                new Point(50, 100)\r
+                                                                        };\r
+\r
+                       GraphicsPath path = new GraphicsPath();\r
+                       path.AddLines( p );\r
+                       path.FillMode = FillMode.Alternate;\r
+                       t.Graphics.FillPath( Brushes.Blue, path );\r
+                       t.Show();\r
+                       Assert.IsTrue(t.PDCompare());\r
+               }\r
+               [Test]\r
+               public void FillModeWinding_1() {\r
+                       Point [] p = new Point[] {\r
+                                                                                new Point(50, 100),\r
+                                                                                new Point(70, 10),\r
+                                                                                new Point(90, 100),\r
+                                                                                new Point(140, 10),\r
+                                                                                new Point(150, 100),\r
+                                                                                new Point(170, 10),\r
+                                                                                new Point(50, 100)\r
+                                                                        };\r
+\r
+                       GraphicsPath path = new GraphicsPath();\r
+                       path.AddLines( p );\r
+                       path.FillMode = FillMode.Winding;\r
+                       t.Graphics.FillPath( Brushes.Blue, path );\r
+                       t.Show();\r
+                       Assert.IsTrue(t.PDCompare());\r
+               }\r
+               [Test]\r
+               public void FillModeWinding_2() {\r
+\r
+                       Rectangle r1 = new Rectangle(100, 100, 100, 100);\r
+                       Rectangle r2 = new Rectangle(125, 125, 50, 50);\r
+                       GraphicsPath path = new GraphicsPath();\r
+                       path.AddRectangle( r1 );\r
+                       path.AddRectangle( r2 );\r
+                       path.FillMode = FillMode.Winding;\r
+                       t.Graphics.FillPath( Brushes.Blue, path );\r
+                       t.Show();\r
+                       Assert.IsTrue(t.PDCompare());\r
+               }\r
+               [Test]\r
+               public void FillModeWinding_3() {\r
+                       Point [] p = new Point[] {\r
+                                                                                new Point(50, 100),\r
+                                                                                new Point(150, 50),\r
+                                                                                new Point(250, 100),\r
+                                                                                new Point(50, 75),\r
+                                                                                new Point(250, 50),\r
+                                                                                new Point(50, 100)\r
+                                                                        };\r
+\r
+                       GraphicsPath path = new GraphicsPath();\r
+                       path.AddLines( p );\r
+                       path.FillMode = FillMode.Winding;\r
+                       t.Graphics.FillPath( Brushes.Blue, path );\r
+                       t.Show();\r
+                       Assert.IsTrue(t.PDCompare());\r
+               }\r
+\r
+       }\r
+       #endregion\r
+\r
+\r
        #region GraphicsFixture\r
        /// <summary>\r
        /// Summary description for Graphics.\r
@@ -433,7 +560,7 @@ namespace Test.Sys.Drawing.GraphicsFixtures {
                public virtual void SetUp(string ownerClass) {\r
                        t = DrawingTest.Create(512, 512, ownerClass);\r
 \r
-                       // hashtable of differents tolerance values for specified tests.\r
+                       // hashtable of differents tolerance values for specified tests. (for fft comparer)\r
                        st["DrawArcTest:6"] = TOLERANCE * 2.5f;\r
                        st["DrawCurveTestF:4"] = TOLERANCE * 2f;\r
                        st["DrawPolygonPoint:2"] = TOLERANCE * 2f;\r