2 // StatusStripTests.cs
\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
12 // The above copyright notice and this permission notice shall be
\r
13 // included in all copies or substantial portions of the Software.
\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
23 // Copyright (c) 2006 Novell, Inc.
\r
26 // Jonathan Pobst (monkey@jpobst.com)
\r
29 using System.Collections.Generic;
\r
31 using NUnit.Framework;
\r
32 using System.Drawing;
\r
33 using System.Windows.Forms;
\r
34 using System.ComponentModel;
\r
36 namespace MonoTests.System.Windows.Forms
\r
39 public class StatusStripTests : TestHelper
\r
42 public void Constructor ()
\r
44 StatusStrip ts = new StatusStrip ();
\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
58 Assert.AreEqual ("System.Windows.Forms.StatusStrip+StatusStripAccessibleObject", ts.AccessibilityObject.GetType ().ToString ());
\r
62 public void ControlStyle ()
\r
64 ExposeProtectedProperties epp = new ExposeProtectedProperties ();
\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
76 Assert.AreEqual (cs, epp.GetControlStyles (), "Styles");
\r
80 public void ProtectedProperties ()
\r
82 ExposeProtectedProperties epp = new ExposeProtectedProperties ();
\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
91 public void PropertyCanOverflow ()
\r
93 StatusStrip ts = new StatusStrip ();
\r
95 ts.CanOverflow = true;
\r
96 Assert.AreEqual (true, ts.CanOverflow, "B1");
\r
100 public void PropertyDock ()
\r
102 StatusStrip ts = new StatusStrip ();
\r
104 ts.Dock = DockStyle.Top;
\r
105 Assert.AreEqual (DockStyle.Top, ts.Dock, "B1");
\r
109 [ExpectedException (typeof (InvalidEnumArgumentException))]
\r
110 public void PropertyDockIEAE ()
\r
112 StatusStrip ts = new StatusStrip ();
\r
113 ts.Dock = (DockStyle)42;
\r
117 public void PropertyGripStyle ()
\r
119 StatusStrip ts = new StatusStrip ();
\r
121 ts.GripStyle = ToolStripGripStyle.Visible;
\r
122 Assert.AreEqual (ToolStripGripStyle.Visible, ts.GripStyle, "B1");
\r
126 [ExpectedException (typeof (InvalidEnumArgumentException))]
\r
127 public void PropertyGripStyleIEAE ()
\r
129 StatusStrip ts = new StatusStrip ();
\r
131 ts.GripStyle = (ToolStripGripStyle) 42;
\r
135 public void PropertyLayoutStyle ()
\r
137 StatusStrip ts = new StatusStrip ();
\r
139 ts.LayoutStyle = ToolStripLayoutStyle.VerticalStackWithOverflow;
\r
140 Assert.AreEqual (ToolStripLayoutStyle.VerticalStackWithOverflow, ts.LayoutStyle, "B1");
\r
144 [ExpectedException (typeof (InvalidEnumArgumentException))]
\r
145 public void PropertyLayoutStyleIEAE ()
\r
147 StatusStrip ts = new StatusStrip ();
\r
149 ts.LayoutStyle = (ToolStripLayoutStyle) 42;
\r
153 public void PropertyPadding ()
\r
155 StatusStrip ts = new StatusStrip ();
\r
157 ts.Padding = new Padding (7);
\r
158 Assert.AreEqual (new Padding (7), ts.Padding, "B1");
\r
162 public void PropertyShowItemToolTips ()
\r
164 StatusStrip ts = new StatusStrip ();
\r
166 ts.ShowItemToolTips = true;
\r
167 Assert.AreEqual (true, ts.ShowItemToolTips, "B1");
\r
171 public void PropertySizingGrip ()
\r
173 StatusStrip ts = new StatusStrip ();
\r
175 ts.SizingGrip = false;
\r
176 Assert.AreEqual (false, ts.SizingGrip, "B1");
\r
180 public void PropertyStretch ()
\r
182 StatusStrip ts = new StatusStrip ();
\r
184 ts.Stretch = false;
\r
185 Assert.AreEqual (false, ts.Stretch, "B1");
\r
188 private class ExposeProtectedProperties : StatusStrip
\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
195 public ControlStyles GetControlStyles ()
\r
197 ControlStyles retval = (ControlStyles) 0;
\r
199 foreach (ControlStyles cs in Enum.GetValues (typeof (ControlStyles)))
\r
200 if (this.GetStyle (cs) == true)
\r