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