Author: spouliot
Date: 2006-09-18 13:33:23 -0400 (Mon, 18 Sep 2006)
New Revision: 65590

Modified:
   trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
   trunk/mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs
Log:
2006-09-18  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * TestGraphics.cs: Add test cases for MeasureString methods.



Modified: trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
===================================================================
--- trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog        
2006-09-18 17:32:09 UTC (rev 65589)
+++ trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog        
2006-09-18 17:33:23 UTC (rev 65590)
@@ -1,3 +1,7 @@
+2006-09-18  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * TestGraphics.cs: Add test cases for MeasureString methods.
+
 2006-09-18     Boris Kirzner <[EMAIL PROTECTED]>
 
        * ColorTranslator.cs,TestBitmap.cs,TestColor.cs,TestFont.cs,

Modified: trunk/mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs
===================================================================
--- trunk/mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs  
2006-09-18 17:32:09 UTC (rev 65589)
+++ trunk/mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs  
2006-09-18 17:33:23 UTC (rev 65590)
@@ -41,7 +41,21 @@
        public class GraphicsTest : Assertion
        {
                private RectangleF[] rects;
+               private Font font;
 
+               [TestFixtureSetUp]
+               public void FixtureSetUp ()
+               {
+                       font = new Font ("Arial", 12);
+               }
+
+               [TestFixtureTearDown]
+               public void FixtureTearDown ()
+               {
+                       font.Dispose ();
+               }
+               
+
                private bool IsEmptyBitmap (Bitmap bitmap, out int x, out int y)
                {
                        bool result = true;
@@ -1169,12 +1183,12 @@
                        BeginContainer_GraphicsUnit 
((GraphicsUnit)Int32.MinValue);
                }
 
-               [Test]
-#if NET_2_0
-               [ExpectedException (typeof (ArgumentNullException))]
-#else
-               [ExpectedException (typeof (NullReferenceException))]
-#endif
+               [Test]
+#if NET_2_0
+               [ExpectedException (typeof (ArgumentNullException))]
+#else
+               [ExpectedException (typeof (NullReferenceException))]
+#endif
                public void EndContainer_Null ()
                {
                        Bitmap bitmap = new Bitmap (20, 20);
@@ -1230,76 +1244,150 @@
                        Bitmap bitmap = new Bitmap (20, 20);
                        Graphics g = Graphics.FromImage (bitmap);
                        g.Restore (null);
-               }
-
-               [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
-               public void FillRectangles_BrushNull_Rectangle ()
-               {
-                       using (Bitmap bitmap = new Bitmap (20, 20)) {
-                               using (Graphics g = Graphics.FromImage 
(bitmap)) {
-                                       g.FillRectangles (null, new 
Rectangle[1]);
-                               }
-                       }
-               }
-
-               [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
-               public void FillRectangles_Rectangle_Null ()
-               {
-                       using (Bitmap bitmap = new Bitmap (20, 20)) {
-                               using (Graphics g = Graphics.FromImage 
(bitmap)) {
-                                       g.FillRectangles (Brushes.Red, 
(Rectangle[]) null);
-                               }
-                       }
-               }
-
-               [Test] // see bug #78408
-               [ExpectedException (typeof (ArgumentException))]
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void FillRectangles_BrushNull_Rectangle ()
+               {
+                       using (Bitmap bitmap = new Bitmap (20, 20)) {
+                               using (Graphics g = Graphics.FromImage 
(bitmap)) {
+                                       g.FillRectangles (null, new 
Rectangle[1]);
+                               }
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void FillRectangles_Rectangle_Null ()
+               {
+                       using (Bitmap bitmap = new Bitmap (20, 20)) {
+                               using (Graphics g = Graphics.FromImage 
(bitmap)) {
+                                       g.FillRectangles (Brushes.Red, 
(Rectangle[]) null);
+                               }
+                       }
+               }
+
+               [Test] // see bug #78408
+               [ExpectedException (typeof (ArgumentException))]
                public void FillRectanglesZeroRectangle ()
                {
-                       using (Bitmap bitmap = new Bitmap (20, 20)) {
-                               using (Graphics g = Graphics.FromImage 
(bitmap)) {
-                                       g.FillRectangles (Brushes.Red, new 
Rectangle[0]);
+                       using (Bitmap bitmap = new Bitmap (20, 20)) {
+                               using (Graphics g = Graphics.FromImage 
(bitmap)) {
+                                       g.FillRectangles (Brushes.Red, new 
Rectangle[0]);
                                }
                        }
-               }
-
-               [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
-               public void FillRectangles_BrushNull_RectangleF ()
-               {
-                       using (Bitmap bitmap = new Bitmap (20, 20)) {
-                               using (Graphics g = Graphics.FromImage 
(bitmap)) {
-                                       g.FillRectangles (null, new 
RectangleF[1]);
-                               }
-                       }
-               }
-
-               [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
-               public void FillRectangles_RectangleF_Null ()
-               {
-                       using (Bitmap bitmap = new Bitmap (20, 20)) {
-                               using (Graphics g = Graphics.FromImage 
(bitmap)) {
-                                       g.FillRectangles (Brushes.Red, 
(RectangleF[])null);
-                               }
-                       }
-               }
-
-               [Test] // see bug #78408
-               [ExpectedException (typeof (ArgumentException))]
-               public void FillRectanglesZeroRectangleF ()
-               {
-                       using (Bitmap bitmap = new Bitmap (20, 20)) {
-                               using (Graphics g = Graphics.FromImage 
(bitmap)) {
-                                       g.FillRectangles (Brushes.Red, new 
RectangleF[0]);
-                               }
-                       }
                }
 
-#if NET_2_0
                [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void FillRectangles_BrushNull_RectangleF ()
+               {
+                       using (Bitmap bitmap = new Bitmap (20, 20)) {
+                               using (Graphics g = Graphics.FromImage 
(bitmap)) {
+                                       g.FillRectangles (null, new 
RectangleF[1]);
+                               }
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void FillRectangles_RectangleF_Null ()
+               {
+                       using (Bitmap bitmap = new Bitmap (20, 20)) {
+                               using (Graphics g = Graphics.FromImage 
(bitmap)) {
+                                       g.FillRectangles (Brushes.Red, 
(RectangleF[])null);
+                               }
+                       }
+               }
+
+               [Test] // see bug #78408
+               [ExpectedException (typeof (ArgumentException))]
+               public void FillRectanglesZeroRectangleF ()
+               {
+                       using (Bitmap bitmap = new Bitmap (20, 20)) {
+                               using (Graphics g = Graphics.FromImage 
(bitmap)) {
+                                       g.FillRectangles (Brushes.Red, new 
RectangleF[0]);
+                               }
+                       }
+               }
+
+               [Test]
+               public void MeasureString_StringFont ()
+               {
+                       using (Bitmap bitmap = new Bitmap (20, 20)) {
+                               using (Graphics g = Graphics.FromImage 
(bitmap)) {
+                                       SizeF size = g.MeasureString (null, 
font);
+                                       Assert ("MeasureString(null,font)", 
size.IsEmpty);
+                                       size = g.MeasureString (String.Empty, 
font);
+                                       Assert ("MeasureString(empty,font)", 
size.IsEmpty);
+                                       // null font
+                                       size = g.MeasureString (null, null);
+                                       Assert ("MeasureString(null,null)", 
size.IsEmpty);
+                                       size = g.MeasureString (String.Empty, 
null);
+                                       Assert ("MeasureString(empty,null)", 
size.IsEmpty);
+                               }
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void MeasureString_StringFont_Null ()
+               {
+                       using (Bitmap bitmap = new Bitmap (20, 20)) {
+                               using (Graphics g = Graphics.FromImage 
(bitmap)) {
+                                       g.MeasureString ("a", null);
+                               }
+                       }
+               }
+
+               [Test]
+               public void MeasureString_StringFontSizeF ()
+               {
+                       using (Bitmap bitmap = new Bitmap (20, 20)) {
+                               using (Graphics g = Graphics.FromImage 
(bitmap)) {
+                                       SizeF size = g.MeasureString ("a", 
font, SizeF.Empty);
+                                       Assert ("MeasureString(a,font,empty)", 
!size.IsEmpty);
+
+                                       size = g.MeasureString (String.Empty, 
font, SizeF.Empty);
+                                       Assert 
("MeasureString(empty,font,empty)", size.IsEmpty);
+                               }
+                       }
+               }
+
+               [Test]
+               public void MeasureString_StringFontInt ()
+               {
+                       using (Bitmap bitmap = new Bitmap (20, 20)) {
+                               using (Graphics g = Graphics.FromImage 
(bitmap)) {
+                                       SizeF size = g.MeasureString ("a", 
font, 0);
+                                       Assert ("MeasureString(a,font,0)", 
!size.IsEmpty);
+                                       size = g.MeasureString ("a", font, 
Int32.MinValue);
+                                       Assert ("MeasureString(a,font,min)", 
!size.IsEmpty);
+                                       size = g.MeasureString ("a", font, 
Int32.MaxValue);
+                                       Assert ("MeasureString(a,font,max)", 
!size.IsEmpty);
+                               }
+                       }
+               }
+
+               [Test]
+               public void MeasureString_Bug76664 ()
+               {
+                       using (Bitmap bitmap = new Bitmap (20, 20)) {
+                               using (Graphics g = Graphics.FromImage 
(bitmap)) {
+                                       string s = "aaa aa aaaa a aaa";
+                                       SizeF size = g.MeasureString (s, font);
+
+                                       int chars, lines;
+                                       size = g.MeasureString (s, font, new 
SizeF (80, size.Height), null, out chars, out lines);
+                                       // LAMESPEC: documentation seems to 
suggest chars is total length
+                                       Assert ("characters fitted", chars < 
s.Length);
+                                       AssertEquals ("lines fitted", 1, lines);
+                               }
+                       }
+               }
+#if NET_2_0
+               [Test]
                public void TestReleaseHdc ()
                {
                        Bitmap b = new Bitmap (100, 100);

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to