* Makefile: Build the make-map.exe in Mono.Unix.Native; add /nowarn:0618 to
[mono.git] / mcs / class / Managed.Windows.Forms / Test / System.Windows.Forms / LabelTest.cs
1 //
2 // Copyright (c) 2005 Novell, Inc.
3 //
4 // Authors:
5 //      Hisham Mardam Bey (hisham.mardambey@gmail.com)
6 //
7 //
8                                                 
9
10 using System;
11 using NUnit.Framework;
12 using System.Windows.Forms;
13 using System.Drawing;
14 using System.Runtime.Remoting;
15
16 namespace MonoTests.System.Windows.Forms
17 {
18         [TestFixture]
19         [Ignore ("This test has to be completly reviewed")]
20         public class LabelTest2
21         {
22                 
23                 [Test]
24                 public void PubPropTest ()
25                 {
26                         Label l = new Label ();
27                         
28                         // A
29                         Assert.AreEqual (false, l.AutoSize, "A1");
30                         l.AutoSize = true;
31                         Assert.AreEqual (true, l.AutoSize, "A2");
32                         l.AutoSize = false;
33                         Assert.AreEqual (false, l.AutoSize, "A3");
34                         
35                         // B
36                         Assert.AreEqual (null, l.BackgroundImage, "B1");
37                         l.BackgroundImage = Image.FromFile ("a.png");;
38                         Assert.IsNotNull (l.BackgroundImage, "B2");
39                         Bitmap bmp = (Bitmap)l.BackgroundImage;
40                         Assert.IsNotNull (bmp.GetPixel (0, 0), "B3");
41                                                                         
42                         Assert.AreEqual (BorderStyle.None, l.BorderStyle, "B4");
43                         l.BorderStyle = BorderStyle.FixedSingle;
44                         Assert.AreEqual (BorderStyle.FixedSingle, l.BorderStyle, "B5");
45                         l.BorderStyle = BorderStyle.Fixed3D;
46                         Assert.AreEqual (BorderStyle.Fixed3D, l.BorderStyle, "B6");
47                         l.BorderStyle = BorderStyle.None;
48                         Assert.AreEqual (BorderStyle.None, l.BorderStyle, "B7");
49                         
50                         // C
51                         string name = l.CompanyName;
52                         if (!name.Equals("Mono Project, Novell, Inc.") && !name.Equals("Microsoft Corporation")) {
53                                 Assert.Fail("CompanyName property does not match any accepted value - C1");
54                         }
55                         
56                         
57                         // F
58                         Assert.AreEqual (FlatStyle.Standard, l.FlatStyle, "F1");
59                         l.FlatStyle = FlatStyle.Flat;
60                         Assert.AreEqual (FlatStyle.Flat, l.FlatStyle, "F1");
61                         l.FlatStyle = FlatStyle.Popup;
62                         Assert.AreEqual (FlatStyle.Popup, l.FlatStyle, "F2");
63                         l.FlatStyle = FlatStyle.Standard;
64                         Assert.AreEqual (FlatStyle.Standard, l.FlatStyle, "F3");
65                         l.FlatStyle = FlatStyle.System;
66                         Assert.AreEqual (FlatStyle.System, l.FlatStyle, "F4");
67                         
68                         // I
69                         Assert.AreEqual (ContentAlignment.MiddleCenter, l.ImageAlign, "I1");
70                         l.ImageAlign = ContentAlignment.TopLeft;
71                         Assert.AreEqual (ContentAlignment.TopLeft, l.ImageAlign, "I2");
72                         l.ImageAlign = ContentAlignment.TopCenter;
73                         Assert.AreEqual (ContentAlignment.TopCenter, l.ImageAlign, "I3");
74                         l.ImageAlign = ContentAlignment.TopRight;
75                         Assert.AreEqual (ContentAlignment.TopRight, l.ImageAlign, "I4");
76                         l.ImageAlign = ContentAlignment.MiddleLeft;
77                         Assert.AreEqual (ContentAlignment.MiddleLeft, l.ImageAlign, "I5");
78                         l.ImageAlign = ContentAlignment.MiddleCenter;
79                         Assert.AreEqual (ContentAlignment.MiddleCenter, l.ImageAlign, "I6");
80                         l.ImageAlign = ContentAlignment.MiddleRight;
81                         Assert.AreEqual (ContentAlignment.MiddleRight, l.ImageAlign, "I7");
82                         l.ImageAlign = ContentAlignment.BottomLeft;
83                         Assert.AreEqual (ContentAlignment.BottomLeft, l.ImageAlign, "I8");
84                         l.ImageAlign = ContentAlignment.BottomCenter;
85                         Assert.AreEqual (ContentAlignment.BottomCenter, l.ImageAlign, "I9");
86                         l.ImageAlign = ContentAlignment.BottomRight;
87                         Assert.AreEqual (ContentAlignment.BottomRight, l.ImageAlign, "I10");
88                         Assert.AreEqual (-1, l.ImageIndex, "I11");
89                         Assert.AreEqual (null, l.ImageList, "I12");
90                         Assert.AreEqual (null, l.Image, "I13");
91                         l.Image = Image.FromFile ("a.png");
92                         Assert.IsNotNull (l.Image, "I14");
93                         bmp = (Bitmap)l.Image;
94                         Assert.IsNotNull (bmp.GetPixel (0, 0), "I15");
95                         
96                         
97                         ImageList il = new ImageList ();
98                         il.ColorDepth = ColorDepth.Depth32Bit;
99                         il.ImageSize = new Size (15, 15);
100                         il.Images.Add (Image.FromFile ("a.png"));
101                         l.ImageList = il;
102                         l.ImageIndex = 0;
103                         
104                         Assert.AreEqual (0, l.ImageIndex, "I16");
105                         Assert.IsNotNull (l.ImageList, "I17");
106                         
107                         // PreferredHeight
108                         // PregerredWidth
109                         // RenderTransparent
110                         
111                         // T
112                         // Assert.AreEqual (false, l.TabStop, "T1");
113                         Assert.AreEqual (ContentAlignment.TopLeft, l.TextAlign, "T2");
114                         
115                         // U
116                         Assert.AreEqual (true, l.UseMnemonic, "U1");
117                         l.UseMnemonic = false;
118                         Assert.AreEqual (false, l.UseMnemonic, "U2");
119                 }
120                 
121                 [Test]
122                 public void PubMethodTest ()
123                 {
124                         Label l = new Label ();
125                         
126                         l.Text = "My Label";
127                         
128                         Assert.AreEqual ("System.Windows.Forms.LabelText: My Label", l.ToString (), "T1");
129                           
130                 }
131         }
132 }
133