Mark tests as not working under TARGET_JVM
[mono.git] / mcs / class / System.Drawing / Test / System.Drawing / SystemFontsTest.cs
1 //
2 // Tests for System.Drawing.SystemFontsTest
3 //
4 // Authors:
5 //      Gert Driesen  <drieseng@users.sourceforge.net>
6 //      Sebastien Pouliot  <sebastien@ximian.com>
7 //
8 // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com)
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 // 
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 // 
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //
29
30 #if NET_2_0
31
32 using System;
33 using System.Drawing;
34
35 using NUnit.Framework;
36
37 namespace MonoTests.System.Drawing {
38
39         [TestFixture]
40         public class SystemFontsTest {
41
42                 [Test]
43                 public void DefaultFont ()
44                 {
45                         Font f = SystemFonts.DefaultFont;
46                         Assert.IsFalse (f.Bold, "#1");
47
48                         Assert.AreEqual (true, f.IsSystemFont, "#3");
49                         Assert.IsFalse (f.Italic, "#4");
50                         Assert.AreEqual (8.25, f.Size, "#6");
51                         Assert.AreEqual (8.25, f.SizeInPoints, "#7");
52                         Assert.IsFalse (f.Strikeout, "#8");
53                         Assert.IsFalse (f.Underline, "#9");
54                         Assert.AreEqual (GraphicsUnit.Point, f.Unit, "#10");
55                 }
56
57                 [Test]
58                 [Category ("NotWorking")] // on Unix mapping is done to Bitstream Vera Sans
59                 public void DefaultFont_Names ()
60                 {
61                         Font f = SystemFonts.DefaultFont;
62                         Assert.AreEqual ("Microsoft Sans Serif", f.FontFamily.Name, "#1");
63                         Assert.AreEqual ("Microsoft Sans Serif", f.Name, "#2");
64                 }
65
66                 [Test]
67                 public void SystemFontName ()
68                 {
69                         Assert.AreEqual ("CaptionFont", SystemFonts.CaptionFont.SystemFontName, "CaptionFont");
70                         Assert.AreEqual ("DefaultFont", SystemFonts.DefaultFont.SystemFontName, "DefaultFont");
71                         Assert.AreEqual ("DialogFont", SystemFonts.DialogFont.SystemFontName, "DialogFont");
72                         Assert.AreEqual ("IconTitleFont", SystemFonts.IconTitleFont.SystemFontName, "IconTitleFont");
73                         Assert.AreEqual ("MenuFont", SystemFonts.MenuFont.SystemFontName, "MenuFont");
74                         Assert.AreEqual ("MessageBoxFont", SystemFonts.MessageBoxFont.SystemFontName, "MessageBoxFont");
75                         Assert.AreEqual ("SmallCaptionFont", SystemFonts.SmallCaptionFont.SystemFontName, "SmallCaptionFont");
76                         Assert.AreEqual ("StatusFont", SystemFonts.StatusFont.SystemFontName, "StatusFont");
77                 }
78
79                 [Test]
80                 public void GetFontByName ()
81                 {
82                         Assert.AreEqual ("CaptionFont", SystemFonts.GetFontByName ("CaptionFont").SystemFontName, "CaptionFont");
83                         Assert.AreEqual ("DefaultFont", SystemFonts.GetFontByName ("DefaultFont").SystemFontName, "DefaultFont");
84                         Assert.AreEqual ("DialogFont", SystemFonts.GetFontByName ("DialogFont").SystemFontName, "DialogFont");
85                         Assert.AreEqual ("IconTitleFont", SystemFonts.GetFontByName ("IconTitleFont").SystemFontName, "IconTitleFont");
86                         Assert.AreEqual ("MenuFont", SystemFonts.GetFontByName ("MenuFont").SystemFontName, "MenuFont");
87                         Assert.AreEqual ("MessageBoxFont", SystemFonts.GetFontByName ("MessageBoxFont").SystemFontName, "MessageBoxFont");
88                         Assert.AreEqual ("SmallCaptionFont", SystemFonts.GetFontByName ("SmallCaptionFont").SystemFontName, "SmallCaptionFont");
89                         Assert.AreEqual ("StatusFont", SystemFonts.GetFontByName ("StatusFont").SystemFontName, "StatusFont");
90                 }
91
92                 [Test]
93                 public void GetFontByName_Invalid ()
94                 {
95                         Assert.IsNull (SystemFonts.GetFontByName (null), "null");
96                         Assert.IsNull (SystemFonts.GetFontByName (String.Empty), "Empty");
97                         Assert.IsNull (SystemFonts.GetFontByName ("defaultfont"), "lowercase");
98                         Assert.IsNull (SystemFonts.GetFontByName ("DEFAULTFONT"), "UPPERCASE");
99                 }
100
101                 [Test]
102                 public void Same ()
103                 {
104                         Font f1 = SystemFonts.CaptionFont;
105                         Font f2 = SystemFonts.CaptionFont;
106                         Assert.IsFalse (Object.ReferenceEquals (f1, f2), "property-property");
107                         f2 = SystemFonts.GetFontByName ("CaptionFont");
108                         Assert.IsFalse (Object.ReferenceEquals (f1, f2), "property-GetFontByName");
109                 }
110
111                 [Test]
112                 [ExpectedException (typeof (ArgumentException))]
113                 public void Dispose_Instance ()
114                 {
115                         Font f1 = SystemFonts.CaptionFont;
116                         float height = f1.GetHeight (72f);
117                         f1.Dispose ();
118                         f1.GetHeight (72f);
119                 }
120
121                 [Test]
122                 public void Dispose_Property ()
123                 {
124                         float height = SystemFonts.CaptionFont.GetHeight (72f);
125                         SystemFonts.CaptionFont.Dispose ();
126                         Assert.AreEqual (height, SystemFonts.CaptionFont.GetHeight (72f), "height");
127                 }
128         }
129 }
130
131 #endif