2005-09-13 Sureshkumar T <tsureshkumar@novell.com>
[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         public class LabelTest2
20         {
21                 
22                 [Test]
23                 public void PubPropTest ()
24                 {
25                         Label l = new Label ();
26                         
27                         // A
28                         Assert.AreEqual (false, l.AutoSize, "A1");
29                         l.AutoSize = true;
30                         Assert.AreEqual (true, l.AutoSize, "A2");
31                         l.AutoSize = false;
32                         Assert.AreEqual (false, l.AutoSize, "A3");
33                         
34                         // B
35                         Assert.AreEqual (null, l.BackgroundImage, "B1");
36                         l.BackgroundImage = Image.FromFile ("a.png");;
37                         Assert.IsNotNull (l.BackgroundImage, "B2");
38                         Bitmap bmp = (Bitmap)l.BackgroundImage;
39                         Assert.IsNotNull (bmp.GetPixel (0, 0), "B3");
40                                                                         
41                         Assert.AreEqual (BorderStyle.None, l.BorderStyle, "B4");
42                         l.BorderStyle = BorderStyle.FixedSingle;
43                         Assert.AreEqual (BorderStyle.FixedSingle, l.BorderStyle, "B5");
44                         l.BorderStyle = BorderStyle.Fixed3D;
45                         Assert.AreEqual (BorderStyle.Fixed3D, l.BorderStyle, "B6");
46                         l.BorderStyle = BorderStyle.None;
47                         Assert.AreEqual (BorderStyle.None, l.BorderStyle, "B7");
48                         
49                         // C
50                         string name = l.CompanyName;
51                         if (!name.Equals("Mono Project, Novell, Inc.") && !name.Equals("Microsoft Corporation")) {
52                                 Assert.Fail("CompanyName property does not match any accepted value - C1");
53                         }
54                         
55                         
56                         // F
57                         Assert.AreEqual (FlatStyle.Standard, l.FlatStyle, "F1");
58                         l.FlatStyle = FlatStyle.Flat;
59                         Assert.AreEqual (FlatStyle.Flat, l.FlatStyle, "F1");
60                         l.FlatStyle = FlatStyle.Popup;
61                         Assert.AreEqual (FlatStyle.Popup, l.FlatStyle, "F2");
62                         l.FlatStyle = FlatStyle.Standard;
63                         Assert.AreEqual (FlatStyle.Standard, l.FlatStyle, "F3");
64                         l.FlatStyle = FlatStyle.System;
65                         Assert.AreEqual (FlatStyle.System, l.FlatStyle, "F4");
66                         
67                         // I
68                         Assert.AreEqual (ContentAlignment.MiddleCenter, l.ImageAlign, "I1");
69                         l.ImageAlign = ContentAlignment.TopLeft;
70                         Assert.AreEqual (ContentAlignment.TopLeft, l.ImageAlign, "I2");
71                         l.ImageAlign = ContentAlignment.TopCenter;
72                         Assert.AreEqual (ContentAlignment.TopCenter, l.ImageAlign, "I3");
73                         l.ImageAlign = ContentAlignment.TopRight;
74                         Assert.AreEqual (ContentAlignment.TopRight, l.ImageAlign, "I4");
75                         l.ImageAlign = ContentAlignment.MiddleLeft;
76                         Assert.AreEqual (ContentAlignment.MiddleLeft, l.ImageAlign, "I5");
77                         l.ImageAlign = ContentAlignment.MiddleCenter;
78                         Assert.AreEqual (ContentAlignment.MiddleCenter, l.ImageAlign, "I6");
79                         l.ImageAlign = ContentAlignment.MiddleRight;
80                         Assert.AreEqual (ContentAlignment.MiddleRight, l.ImageAlign, "I7");
81                         l.ImageAlign = ContentAlignment.BottomLeft;
82                         Assert.AreEqual (ContentAlignment.BottomLeft, l.ImageAlign, "I8");
83                         l.ImageAlign = ContentAlignment.BottomCenter;
84                         Assert.AreEqual (ContentAlignment.BottomCenter, l.ImageAlign, "I9");
85                         l.ImageAlign = ContentAlignment.BottomRight;
86                         Assert.AreEqual (ContentAlignment.BottomRight, l.ImageAlign, "I10");
87                         Assert.AreEqual (-1, l.ImageIndex, "I11");
88                         Assert.AreEqual (null, l.ImageList, "I12");
89                         Assert.AreEqual (null, l.Image, "I13");
90                         l.Image = Image.FromFile ("a.png");
91                         Assert.IsNotNull (l.Image, "I14");
92                         bmp = (Bitmap)l.Image;
93                         Assert.IsNotNull (bmp.GetPixel (0, 0), "I15");
94                         
95                         
96                         ImageList il = new ImageList ();
97                         il.ColorDepth = ColorDepth.Depth32Bit;
98                         il.ImageSize = new Size (15, 15);
99                         il.Images.Add (Image.FromFile ("a.png"));
100                         l.ImageList = il;
101                         l.ImageIndex = 0;
102                         
103                         Assert.AreEqual (0, l.ImageIndex, "I16");
104                         Assert.IsNotNull (l.ImageList, "I17");
105                         
106                         // PreferredHeight
107                         // PregerredWidth
108                         // RenderTransparent
109                         
110                         // T
111                         // Assert.AreEqual (false, l.TabStop, "T1");
112                         Assert.AreEqual (ContentAlignment.TopLeft, l.TextAlign, "T2");
113                         
114                         // U
115                         Assert.AreEqual (true, l.UseMnemonic, "U1");
116                         l.UseMnemonic = false;
117                         Assert.AreEqual (false, l.UseMnemonic, "U2");
118                 }
119                 
120                 [Test]
121                 public void PubMethodTest ()
122                 {
123                         Label l = new Label ();
124                         
125                         l.Text = "My Label";
126                         
127                         Assert.AreEqual ("System.Windows.Forms.LabelText: My Label", l.ToString (), "T1");
128                           
129                 }
130         }
131 }
132