[bcl] Remove more NET_2_0 checks from class libs
[mono.git] / mcs / class / Managed.Windows.Forms / Test / System.Windows.Forms / StatusStripTest.cs
1 //\r
2 // StatusStripTests.cs\r
3 //\r
4 // Permission is hereby granted, free of charge, to any person obtaining\r
5 // a copy of this software and associated documentation files (the\r
6 // "Software"), to deal in the Software without restriction, including\r
7 // without limitation the rights to use, copy, modify, merge, publish,\r
8 // distribute, sublicense, and/or sell copies of the Software, and to\r
9 // permit persons to whom the Software is furnished to do so, subject to\r
10 // the following conditions:\r
11 // \r
12 // The above copyright notice and this permission notice shall be\r
13 // included in all copies or substantial portions of the Software.\r
14 // \r
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
22 //\r
23 // Copyright (c) 2006 Novell, Inc.\r
24 //\r
25 // Authors:\r
26 //      Jonathan Pobst (monkey@jpobst.com)\r
27 //\r
28 using System;\r
29 using System.Collections.Generic;\r
30 using System.Text;\r
31 using NUnit.Framework;\r
32 using System.Drawing;\r
33 using System.Windows.Forms;\r
34 using System.ComponentModel;\r
35 \r
36 namespace MonoTests.System.Windows.Forms\r
37 {\r
38         [TestFixture]\r
39         public class StatusStripTests : TestHelper\r
40         {\r
41                 [Test]\r
42                 public void Constructor ()\r
43                 {\r
44                         StatusStrip ts = new StatusStrip ();\r
45 \r
46                         Assert.AreEqual (false, ts.CanOverflow, "A1");\r
47                         Assert.AreEqual (new Rectangle (1, 0, 185, 22), ts.DisplayRectangle, "A2");\r
48                         Assert.AreEqual (DockStyle.Bottom, ts.Dock, "A3");\r
49                         Assert.AreEqual (ToolStripGripStyle.Hidden, ts.GripStyle, "A4");\r
50                         Assert.AreEqual (ToolStripLayoutStyle.Table, ts.LayoutStyle, "A5");\r
51                         Assert.AreEqual (new Padding (1, 0, 14, 0), ts.Padding, "A6");\r
52                         Assert.AreEqual (false, ts.ShowItemToolTips, "A7");\r
53                         Assert.AreEqual (new Rectangle (188, 0, 12, 22), ts.SizeGripBounds, "A8");\r
54                         Assert.AreEqual (true, ts.SizingGrip, "A9");\r
55                         Assert.AreEqual (true, ts.Stretch, "A10");\r
56                         Assert.AreEqual (ToolStripRenderMode.System, ts.RenderMode, "A11");\r
57                         \r
58                         Assert.AreEqual ("System.Windows.Forms.StatusStrip+StatusStripAccessibleObject", ts.AccessibilityObject.GetType ().ToString ());\r
59                 }\r
60 \r
61                 [Test]\r
62                 public void ControlStyle ()\r
63                 {\r
64                         ExposeProtectedProperties epp = new ExposeProtectedProperties ();\r
65                 \r
66                         ControlStyles cs = ControlStyles.ContainerControl;\r
67                         cs |= ControlStyles.UserPaint;\r
68                         cs |= ControlStyles.ResizeRedraw;\r
69                         cs |= ControlStyles.StandardClick;\r
70                         cs |= ControlStyles.SupportsTransparentBackColor;\r
71                         cs |= ControlStyles.StandardDoubleClick;\r
72                         cs |= ControlStyles.AllPaintingInWmPaint;\r
73                         cs |= ControlStyles.OptimizedDoubleBuffer;\r
74                         cs |= ControlStyles.UseTextForAccessibility;\r
75 \r
76                         Assert.AreEqual (cs, epp.GetControlStyles (), "Styles");                \r
77                 }\r
78 \r
79                 [Test]\r
80                 public void ProtectedProperties ()\r
81                 {\r
82                         ExposeProtectedProperties epp = new ExposeProtectedProperties ();\r
83 \r
84                         Assert.AreEqual (DockStyle.Bottom, epp.DefaultDock, "C1");\r
85                         Assert.AreEqual (new Padding (1, 0, 14, 0), epp.DefaultPadding, "C2");\r
86                         Assert.AreEqual (false, epp.DefaultShowItemToolTips, "C3");\r
87                         Assert.AreEqual (new Size (200, 22), epp.DefaultSize, "C4");\r
88                 }\r
89 \r
90                 [Test]\r
91                 public void PropertyCanOverflow ()\r
92                 {\r
93                         StatusStrip ts = new StatusStrip ();\r
94 \r
95                         ts.CanOverflow = true;\r
96                         Assert.AreEqual (true, ts.CanOverflow, "B1");\r
97                 }\r
98 \r
99                 [Test]\r
100                 public void PropertyDock ()\r
101                 {\r
102                         StatusStrip ts = new StatusStrip ();\r
103                         \r
104                         ts.Dock = DockStyle.Top;\r
105                         Assert.AreEqual (DockStyle.Top, ts.Dock, "B1");\r
106                 }\r
107 \r
108                 [Test]\r
109                 [ExpectedException (typeof (InvalidEnumArgumentException))]\r
110                 public void PropertyDockIEAE ()\r
111                 {\r
112                         StatusStrip ts = new StatusStrip ();\r
113                         ts.Dock = (DockStyle)42;\r
114                 }\r
115 \r
116                 [Test]\r
117                 public void PropertyGripStyle ()\r
118                 {\r
119                         StatusStrip ts = new StatusStrip ();\r
120 \r
121                         ts.GripStyle = ToolStripGripStyle.Visible;\r
122                         Assert.AreEqual (ToolStripGripStyle.Visible, ts.GripStyle, "B1");\r
123                 }\r
124 \r
125                 [Test]\r
126                 [ExpectedException (typeof (InvalidEnumArgumentException))]\r
127                 public void PropertyGripStyleIEAE ()\r
128                 {\r
129                         StatusStrip ts = new StatusStrip ();\r
130 \r
131                         ts.GripStyle = (ToolStripGripStyle) 42;\r
132                 }\r
133 \r
134                 [Test]\r
135                 public void PropertyLayoutStyle ()\r
136                 {\r
137                         StatusStrip ts = new StatusStrip ();\r
138 \r
139                         ts.LayoutStyle = ToolStripLayoutStyle.VerticalStackWithOverflow;\r
140                         Assert.AreEqual (ToolStripLayoutStyle.VerticalStackWithOverflow, ts.LayoutStyle, "B1");\r
141                 }\r
142 \r
143                 [Test]\r
144                 [ExpectedException (typeof (InvalidEnumArgumentException))]\r
145                 public void PropertyLayoutStyleIEAE ()\r
146                 {\r
147                         StatusStrip ts = new StatusStrip ();\r
148 \r
149                         ts.LayoutStyle = (ToolStripLayoutStyle) 42;\r
150                 }\r
151 \r
152                 [Test]\r
153                 public void PropertyPadding ()\r
154                 {\r
155                         StatusStrip ts = new StatusStrip ();\r
156 \r
157                         ts.Padding = new Padding (7);\r
158                         Assert.AreEqual (new Padding (7), ts.Padding, "B1");\r
159                 }\r
160 \r
161                 [Test]\r
162                 public void PropertyShowItemToolTips ()\r
163                 {\r
164                         StatusStrip ts = new StatusStrip ();\r
165 \r
166                         ts.ShowItemToolTips = true;\r
167                         Assert.AreEqual (true, ts.ShowItemToolTips, "B1");\r
168                 }\r
169 \r
170                 [Test]\r
171                 public void PropertySizingGrip ()\r
172                 {\r
173                         StatusStrip ts = new StatusStrip ();\r
174 \r
175                         ts.SizingGrip = false;\r
176                         Assert.AreEqual (false, ts.SizingGrip, "B1");\r
177                 }\r
178 \r
179                 [Test]\r
180                 public void PropertyStretch ()\r
181                 {\r
182                         StatusStrip ts = new StatusStrip ();\r
183 \r
184                         ts.Stretch = false;\r
185                         Assert.AreEqual (false, ts.Stretch, "B1");\r
186                 }\r
187                 \r
188                 private class ExposeProtectedProperties : StatusStrip\r
189                 {\r
190                         public new DockStyle DefaultDock { get { return base.DefaultDock; } }\r
191                         public new Padding DefaultPadding { get { return base.DefaultPadding; } }\r
192                         public new bool DefaultShowItemToolTips { get { return base.DefaultShowItemToolTips; } }\r
193                         public new Size DefaultSize { get { return base.DefaultSize; } }\r
194                         \r
195                         public ControlStyles GetControlStyles ()\r
196                         {\r
197                                 ControlStyles retval = (ControlStyles) 0;\r
198                                 \r
199                                 foreach (ControlStyles cs in Enum.GetValues (typeof (ControlStyles)))\r
200                                         if (this.GetStyle (cs) == true)\r
201                                                 retval |= cs;\r
202                                                 \r
203                                 return retval;\r
204                         }\r
205                 }\r
206         }\r
207 }\r