Author: spouliot
Date: 2006-09-18 15:10:44 -0400 (Mon, 18 Sep 2006)
New Revision: 65593
Modified:
trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
trunk/mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs
Log:
* TestGraphics.cs: Add test cases for MeasureString and
MeasureCharacterRanges methods.
Modified: trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
===================================================================
--- trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
2006-09-18 19:09:29 UTC (rev 65592)
+++ trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
2006-09-18 19:10:44 UTC (rev 65593)
@@ -1,6 +1,7 @@
2006-09-18 Sebastien Pouliot <[EMAIL PROTECTED]>
- * TestGraphics.cs: Add test cases for MeasureString methods.
+ * TestGraphics.cs: Add test cases for MeasureString and
+ MeasureCharacterRanges methods.
2006-09-18 Boris Kirzner <[EMAIL PROTECTED]>
Modified: trunk/mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs
===================================================================
--- trunk/mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs
2006-09-18 19:09:29 UTC (rev 65592)
+++ trunk/mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs
2006-09-18 19:10:44 UTC (rev 65593)
@@ -1386,6 +1386,59 @@
}
}
}
+
+ [Test]
+ public void MeasureCharacterRanges_NullOrEmptyText ()
+ {
+ using (Bitmap bitmap = new Bitmap (20, 20)) {
+ using (Graphics g = Graphics.FromImage
(bitmap)) {
+ Region[] regions =
g.MeasureCharacterRanges (null, font, new RectangleF (), null);
+ AssertEquals ("text null", 0,
regions.Length);
+ regions = g.MeasureCharacterRanges
(String.Empty, font, new RectangleF (), null);
+ AssertEquals ("text empty", 0,
regions.Length);
+ // null font is ok with null or empty
string
+ regions = g.MeasureCharacterRanges
(null, null, new RectangleF (), null);
+ AssertEquals ("text null/null font", 0,
regions.Length);
+ regions = g.MeasureCharacterRanges
(String.Empty, null, new RectangleF (), null);
+ AssertEquals ("text empty/null font",
0, regions.Length);
+ }
+ }
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void MeasureCharacterRanges_FontNull ()
+ {
+ using (Bitmap bitmap = new Bitmap (20, 20)) {
+ using (Graphics g = Graphics.FromImage
(bitmap)) {
+ g.MeasureCharacterRanges ("a", null,
new RectangleF (), null);
+ }
+ }
+ }
+
+ [Test] // adapted from bug #78777
+ public void MeasureCharacterRanges_TwoLines ()
+ {
+ string text = "this\nis a test";
+ CharacterRange[] ranges = new CharacterRange [2];
+ ranges[0] = new CharacterRange (0,5);
+ ranges[1] = new CharacterRange (5,9);
+
+ StringFormat string_format = new StringFormat ();
+ string_format.FormatFlags = StringFormatFlags.NoClip;
+ string_format.SetMeasurableCharacterRanges (ranges);
+
+ using (Bitmap bitmap = new Bitmap (20, 20)) {
+ using (Graphics g = Graphics.FromImage
(bitmap)) {
+ SizeF size = g.MeasureString (text,
font, new Point (0,0), string_format);
+ RectangleF layout_rect = new RectangleF
(0.0f, 0.0f, size.Width, size.Height);
+ Region[] regions =
g.MeasureCharacterRanges (text, font, layout_rect, string_format);
+
+ AssertEquals ("Length", 2,
regions.Length);
+ AssertEquals ("Height",
regions[0].GetBounds (g).Height, regions[1].GetBounds (g).Height);
+ }
+ }
+ }
#if NET_2_0
[Test]
public void TestReleaseHdc ()
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches