StatusStripTest.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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 ([email protected])
  27. //
  28. #if NET_2_0
  29. using System;
  30. using System.Collections.Generic;
  31. using System.Text;
  32. using NUnit.Framework;
  33. using System.Drawing;
  34. using System.Windows.Forms;
  35. using System.ComponentModel;
  36. namespace MonoTests.System.Windows.Forms
  37. {
  38. [TestFixture]
  39. public class StatusStripTests : TestHelper
  40. {
  41. [Test]
  42. public void Constructor ()
  43. {
  44. StatusStrip ts = new StatusStrip ();
  45. Assert.AreEqual (false, ts.CanOverflow, "A1");
  46. Assert.AreEqual (new Rectangle (1, 0, 185, 22), ts.DisplayRectangle, "A2");
  47. Assert.AreEqual (DockStyle.Bottom, ts.Dock, "A3");
  48. Assert.AreEqual (ToolStripGripStyle.Hidden, ts.GripStyle, "A4");
  49. Assert.AreEqual (ToolStripLayoutStyle.Table, ts.LayoutStyle, "A5");
  50. Assert.AreEqual (new Padding (1, 0, 14, 0), ts.Padding, "A6");
  51. Assert.AreEqual (false, ts.ShowItemToolTips, "A7");
  52. Assert.AreEqual (new Rectangle (188, 0, 12, 22), ts.SizeGripBounds, "A8");
  53. Assert.AreEqual (true, ts.SizingGrip, "A9");
  54. Assert.AreEqual (true, ts.Stretch, "A10");
  55. Assert.AreEqual (ToolStripRenderMode.System, ts.RenderMode, "A11");
  56. Assert.AreEqual ("System.Windows.Forms.StatusStrip+StatusStripAccessibleObject", ts.AccessibilityObject.GetType ().ToString ());
  57. }
  58. [Test]
  59. public void ControlStyle ()
  60. {
  61. ExposeProtectedProperties epp = new ExposeProtectedProperties ();
  62. ControlStyles cs = ControlStyles.ContainerControl;
  63. cs |= ControlStyles.UserPaint;
  64. cs |= ControlStyles.ResizeRedraw;
  65. cs |= ControlStyles.StandardClick;
  66. cs |= ControlStyles.SupportsTransparentBackColor;
  67. cs |= ControlStyles.StandardDoubleClick;
  68. cs |= ControlStyles.AllPaintingInWmPaint;
  69. cs |= ControlStyles.OptimizedDoubleBuffer;
  70. cs |= ControlStyles.UseTextForAccessibility;
  71. Assert.AreEqual (cs, epp.GetControlStyles (), "Styles");
  72. }
  73. [Test]
  74. public void ProtectedProperties ()
  75. {
  76. ExposeProtectedProperties epp = new ExposeProtectedProperties ();
  77. Assert.AreEqual (DockStyle.Bottom, epp.DefaultDock, "C1");
  78. Assert.AreEqual (new Padding (1, 0, 14, 0), epp.DefaultPadding, "C2");
  79. Assert.AreEqual (false, epp.DefaultShowItemToolTips, "C3");
  80. Assert.AreEqual (new Size (200, 22), epp.DefaultSize, "C4");
  81. }
  82. [Test]
  83. public void PropertyCanOverflow ()
  84. {
  85. StatusStrip ts = new StatusStrip ();
  86. ts.CanOverflow = true;
  87. Assert.AreEqual (true, ts.CanOverflow, "B1");
  88. }
  89. [Test]
  90. public void PropertyDock ()
  91. {
  92. StatusStrip ts = new StatusStrip ();
  93. ts.Dock = DockStyle.Top;
  94. Assert.AreEqual (DockStyle.Top, ts.Dock, "B1");
  95. }
  96. [Test]
  97. [ExpectedException (typeof (InvalidEnumArgumentException))]
  98. public void PropertyDockIEAE ()
  99. {
  100. StatusStrip ts = new StatusStrip ();
  101. ts.Dock = (DockStyle)42;
  102. }
  103. [Test]
  104. public void PropertyGripStyle ()
  105. {
  106. StatusStrip ts = new StatusStrip ();
  107. ts.GripStyle = ToolStripGripStyle.Visible;
  108. Assert.AreEqual (ToolStripGripStyle.Visible, ts.GripStyle, "B1");
  109. }
  110. [Test]
  111. [ExpectedException (typeof (InvalidEnumArgumentException))]
  112. public void PropertyGripStyleIEAE ()
  113. {
  114. StatusStrip ts = new StatusStrip ();
  115. ts.GripStyle = (ToolStripGripStyle) 42;
  116. }
  117. [Test]
  118. public void PropertyLayoutStyle ()
  119. {
  120. StatusStrip ts = new StatusStrip ();
  121. ts.LayoutStyle = ToolStripLayoutStyle.VerticalStackWithOverflow;
  122. Assert.AreEqual (ToolStripLayoutStyle.VerticalStackWithOverflow, ts.LayoutStyle, "B1");
  123. }
  124. [Test]
  125. [ExpectedException (typeof (InvalidEnumArgumentException))]
  126. public void PropertyLayoutStyleIEAE ()
  127. {
  128. StatusStrip ts = new StatusStrip ();
  129. ts.LayoutStyle = (ToolStripLayoutStyle) 42;
  130. }
  131. [Test]
  132. public void PropertyPadding ()
  133. {
  134. StatusStrip ts = new StatusStrip ();
  135. ts.Padding = new Padding (7);
  136. Assert.AreEqual (new Padding (7), ts.Padding, "B1");
  137. }
  138. [Test]
  139. public void PropertyShowItemToolTips ()
  140. {
  141. StatusStrip ts = new StatusStrip ();
  142. ts.ShowItemToolTips = true;
  143. Assert.AreEqual (true, ts.ShowItemToolTips, "B1");
  144. }
  145. [Test]
  146. public void PropertySizingGrip ()
  147. {
  148. StatusStrip ts = new StatusStrip ();
  149. ts.SizingGrip = false;
  150. Assert.AreEqual (false, ts.SizingGrip, "B1");
  151. }
  152. [Test]
  153. public void PropertyStretch ()
  154. {
  155. StatusStrip ts = new StatusStrip ();
  156. ts.Stretch = false;
  157. Assert.AreEqual (false, ts.Stretch, "B1");
  158. }
  159. private class ExposeProtectedProperties : StatusStrip
  160. {
  161. public new DockStyle DefaultDock { get { return base.DefaultDock; } }
  162. public new Padding DefaultPadding { get { return base.DefaultPadding; } }
  163. public new bool DefaultShowItemToolTips { get { return base.DefaultShowItemToolTips; } }
  164. public new Size DefaultSize { get { return base.DefaultSize; } }
  165. public ControlStyles GetControlStyles ()
  166. {
  167. ControlStyles retval = (ControlStyles) 0;
  168. foreach (ControlStyles cs in Enum.GetValues (typeof (ControlStyles)))
  169. if (this.GetStyle (cs) == true)
  170. retval |= cs;
  171. return retval;
  172. }
  173. }
  174. }
  175. }
  176. #endif