StatusStripTest.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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
  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. }
  56. [Test]
  57. public void ControlStyle ()
  58. {
  59. ExposeProtectedProperties epp = new ExposeProtectedProperties ();
  60. ControlStyles cs = ControlStyles.ContainerControl;
  61. cs |= ControlStyles.UserPaint;
  62. cs |= ControlStyles.ResizeRedraw;
  63. cs |= ControlStyles.StandardClick;
  64. cs |= ControlStyles.SupportsTransparentBackColor;
  65. cs |= ControlStyles.StandardDoubleClick;
  66. cs |= ControlStyles.AllPaintingInWmPaint;
  67. cs |= ControlStyles.OptimizedDoubleBuffer;
  68. cs |= ControlStyles.UseTextForAccessibility;
  69. Assert.AreEqual (cs, epp.GetControlStyles (), "Styles");
  70. }
  71. [Test]
  72. public void ProtectedProperties ()
  73. {
  74. ExposeProtectedProperties epp = new ExposeProtectedProperties ();
  75. Assert.AreEqual (DockStyle.Bottom, epp.DefaultDock, "C1");
  76. Assert.AreEqual (new Padding (1, 0, 14, 0), epp.DefaultPadding, "C2");
  77. Assert.AreEqual (false, epp.DefaultShowItemToolTips, "C3");
  78. Assert.AreEqual (new Size (200, 22), epp.DefaultSize, "C4");
  79. }
  80. [Test]
  81. public void PropertyCanOverflow ()
  82. {
  83. StatusStrip ts = new StatusStrip ();
  84. ts.CanOverflow = true;
  85. Assert.AreEqual (true, ts.CanOverflow, "B1");
  86. }
  87. [Test]
  88. public void PropertyDock ()
  89. {
  90. StatusStrip ts = new StatusStrip ();
  91. ts.Dock = DockStyle.Top;
  92. Assert.AreEqual (DockStyle.Top, ts.Dock, "B1");
  93. }
  94. [Test]
  95. [ExpectedException (typeof (InvalidEnumArgumentException))]
  96. public void PropertyDockIEAE ()
  97. {
  98. StatusStrip ts = new StatusStrip ();
  99. ts.Dock = (DockStyle)42;
  100. }
  101. [Test]
  102. public void PropertyGripStyle ()
  103. {
  104. StatusStrip ts = new StatusStrip ();
  105. ts.GripStyle = ToolStripGripStyle.Visible;
  106. Assert.AreEqual (ToolStripGripStyle.Visible, ts.GripStyle, "B1");
  107. }
  108. [Test]
  109. [ExpectedException (typeof (InvalidEnumArgumentException))]
  110. public void PropertyGripStyleIEAE ()
  111. {
  112. StatusStrip ts = new StatusStrip ();
  113. ts.GripStyle = (ToolStripGripStyle) 42;
  114. }
  115. [Test]
  116. public void PropertyLayoutStyle ()
  117. {
  118. StatusStrip ts = new StatusStrip ();
  119. ts.LayoutStyle = ToolStripLayoutStyle.VerticalStackWithOverflow;
  120. Assert.AreEqual (ToolStripLayoutStyle.VerticalStackWithOverflow, ts.LayoutStyle, "B1");
  121. }
  122. [Test]
  123. [ExpectedException (typeof (InvalidEnumArgumentException))]
  124. public void PropertyLayoutStyleIEAE ()
  125. {
  126. StatusStrip ts = new StatusStrip ();
  127. ts.LayoutStyle = (ToolStripLayoutStyle) 42;
  128. }
  129. [Test]
  130. public void PropertyPadding ()
  131. {
  132. StatusStrip ts = new StatusStrip ();
  133. ts.Padding = new Padding (7);
  134. Assert.AreEqual (new Padding (7), ts.Padding, "B1");
  135. }
  136. [Test]
  137. public void PropertyShowItemToolTips ()
  138. {
  139. StatusStrip ts = new StatusStrip ();
  140. ts.ShowItemToolTips = true;
  141. Assert.AreEqual (true, ts.ShowItemToolTips, "B1");
  142. }
  143. [Test]
  144. public void PropertySizingGrip ()
  145. {
  146. StatusStrip ts = new StatusStrip ();
  147. ts.SizingGrip = false;
  148. Assert.AreEqual (false, ts.SizingGrip, "B1");
  149. }
  150. [Test]
  151. public void PropertyStretch ()
  152. {
  153. StatusStrip ts = new StatusStrip ();
  154. ts.Stretch = false;
  155. Assert.AreEqual (false, ts.Stretch, "B1");
  156. }
  157. private class ExposeProtectedProperties : StatusStrip
  158. {
  159. public new DockStyle DefaultDock { get { return base.DefaultDock; } }
  160. public new Padding DefaultPadding { get { return base.DefaultPadding; } }
  161. public new bool DefaultShowItemToolTips { get { return base.DefaultShowItemToolTips; } }
  162. public new Size DefaultSize { get { return base.DefaultSize; } }
  163. public ControlStyles GetControlStyles ()
  164. {
  165. ControlStyles retval = (ControlStyles) 0;
  166. foreach (ControlStyles cs in Enum.GetValues (typeof (ControlStyles)))
  167. if (this.GetStyle (cs) == true)
  168. retval |= cs;
  169. return retval;
  170. }
  171. }
  172. }
  173. }
  174. #endif