ToolStripStatusLabelTest.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. //
  2. // ToolStripStatusLabelTests.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 Jonathan Pobst
  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. namespace MonoTests.System.Windows.Forms
  36. {
  37. [TestFixture]
  38. public class ToolStripStatusLabelTests : TestHelper
  39. {
  40. //[Test]
  41. //public void Constructor ()
  42. //{
  43. // ToolStripLabel tsi = new ToolStripLabel ();
  44. // Assert.AreEqual (Color.Red, tsi.ActiveLinkColor, "A1");
  45. // Assert.AreEqual (false, tsi.CanSelect, "A2");
  46. // Assert.AreEqual (false, tsi.IsLink, "A3");
  47. // Assert.AreEqual (LinkBehavior.SystemDefault, tsi.LinkBehavior, "A4");
  48. // Assert.AreEqual (Color.FromArgb (0,0,255), tsi.LinkColor, "A5");
  49. // Assert.AreEqual (false, tsi.LinkVisited, "A6");
  50. // Assert.AreEqual (Color.FromArgb (128, 0, 128), tsi.VisitedLinkColor, "A7");
  51. // int count = 0;
  52. // EventHandler oc = new EventHandler (delegate (object sender, EventArgs e) { count++; });
  53. // Image i = new Bitmap (1,1);
  54. // tsi = new ToolStripLabel (i);
  55. // tsi.PerformClick();
  56. // Assert.AreEqual (null, tsi.Text, "A8");
  57. // Assert.AreSame (i, tsi.Image, "A9");
  58. // Assert.AreEqual (false, tsi.IsLink, "A10");
  59. // Assert.AreEqual (0, count, "A11");
  60. // Assert.AreEqual (string.Empty, tsi.Name, "A12");
  61. // tsi = new ToolStripLabel ("Text");
  62. // tsi.PerformClick ();
  63. // Assert.AreEqual ("Text", tsi.Text, "A13");
  64. // Assert.AreSame (null, tsi.Image, "A14");
  65. // Assert.AreEqual (false, tsi.IsLink, "A15");
  66. // Assert.AreEqual (0, count, "A16");
  67. // Assert.AreEqual (string.Empty, tsi.Name, "A17");
  68. // tsi = new ToolStripLabel ("Text", i);
  69. // tsi.PerformClick ();
  70. // Assert.AreEqual ("Text", tsi.Text, "A18");
  71. // Assert.AreSame (i, tsi.Image, "A19");
  72. // Assert.AreEqual (false, tsi.IsLink, "A20");
  73. // Assert.AreEqual (0, count, "A21");
  74. // Assert.AreEqual (string.Empty, tsi.Name, "A22");
  75. // tsi = new ToolStripLabel ("Text", i, true);
  76. // tsi.PerformClick ();
  77. // Assert.AreEqual ("Text", tsi.Text, "A23");
  78. // Assert.AreSame (i, tsi.Image, "A24");
  79. // Assert.AreEqual (true, tsi.IsLink, "A25");
  80. // Assert.AreEqual (0, count, "A26");
  81. // Assert.AreEqual (string.Empty, tsi.Name, "A27");
  82. // tsi = new ToolStripLabel ("Text", i, true, oc);
  83. // tsi.PerformClick ();
  84. // Assert.AreEqual ("Text", tsi.Text, "A28");
  85. // Assert.AreSame (i, tsi.Image, "A29");
  86. // Assert.AreEqual (true, tsi.IsLink, "A30");
  87. // Assert.AreEqual (1, count, "A31");
  88. // Assert.AreEqual (string.Empty, tsi.Name, "A32");
  89. // tsi = new ToolStripLabel ("Text", i, true, oc, "Name");
  90. // tsi.PerformClick ();
  91. // Assert.AreEqual ("Text", tsi.Text, "A33");
  92. // Assert.AreSame (i, tsi.Image, "A34");
  93. // Assert.AreEqual (true, tsi.IsLink, "A35");
  94. // Assert.AreEqual (2, count, "A36");
  95. // Assert.AreEqual ("Name", tsi.Name, "A37");
  96. //}
  97. [Test]
  98. public void ProtectedProperties ()
  99. {
  100. ExposeProtectedProperties epp = new ExposeProtectedProperties ();
  101. Assert.AreEqual (new Padding (0, 3, 0, 2), epp.DefaultMargin, "C3");
  102. }
  103. //[Test]
  104. //public void PropertyActiveLinkColor ()
  105. //{
  106. // ToolStripLabel tsi = new ToolStripLabel ();
  107. // tsi.ActiveLinkColor = Color.Green;
  108. // Assert.AreEqual (Color.Green, tsi.ActiveLinkColor, "B1");
  109. //}
  110. //[Test]
  111. //public void PropertyIsLink ()
  112. //{
  113. // ToolStripLabel tsi = new ToolStripLabel ();
  114. // tsi.IsLink = true;
  115. // Assert.AreEqual (true, tsi.IsLink, "B1");
  116. //}
  117. //[Test]
  118. //public void PropertyLinkBehavior ()
  119. //{
  120. // ToolStripLabel tsi = new ToolStripLabel ();
  121. // tsi.LinkBehavior = LinkBehavior.NeverUnderline;
  122. // Assert.AreEqual (LinkBehavior.NeverUnderline, tsi.LinkBehavior, "B1");
  123. //}
  124. //[Test]
  125. //public void PropertyLinkColor ()
  126. //{
  127. // ToolStripLabel tsi = new ToolStripLabel ();
  128. // tsi.LinkColor = Color.Green;
  129. // Assert.AreEqual (Color.Green, tsi.LinkColor, "B1");
  130. //}
  131. //[Test]
  132. //public void PropertyLinkVisited ()
  133. //{
  134. // ToolStripLabel tsi = new ToolStripLabel ();
  135. // tsi.LinkVisited = true;
  136. // Assert.AreEqual (true, tsi.LinkVisited, "B1");
  137. //}
  138. //[Test]
  139. //public void PropertyVisitedLinkColor ()
  140. //{
  141. // ToolStripLabel tsi = new ToolStripLabel ();
  142. // tsi.VisitedLinkColor = Color.Green;
  143. // Assert.AreEqual (Color.Green, tsi.VisitedLinkColor, "B1");
  144. //}
  145. //[Test]
  146. //public void PropertyAnchorAndDocking ()
  147. //{
  148. // ToolStripItem ts = new NullToolStripItem ();
  149. // ts.Anchor = AnchorStyles.Top | AnchorStyles.Bottom;
  150. // Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Bottom, ts.Anchor, "A1");
  151. // Assert.AreEqual (DockStyle.None, ts.Dock, "A2");
  152. // ts.Anchor = AnchorStyles.Left | AnchorStyles.Right;
  153. // Assert.AreEqual (AnchorStyles.Left | AnchorStyles.Right, ts.Anchor, "A1");
  154. // Assert.AreEqual (DockStyle.None, ts.Dock, "A2");
  155. // ts.Dock = DockStyle.Left;
  156. // Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, ts.Anchor, "A1");
  157. // Assert.AreEqual (DockStyle.Left, ts.Dock, "A2");
  158. // ts.Dock = DockStyle.None;
  159. // Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, ts.Anchor, "A1");
  160. // Assert.AreEqual (DockStyle.None, ts.Dock, "A2");
  161. // ts.Dock = DockStyle.Top;
  162. // Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, ts.Anchor, "A1");
  163. // Assert.AreEqual (DockStyle.Top, ts.Dock, "A2");
  164. //}
  165. private class ExposeProtectedProperties : ToolStripStatusLabel
  166. {
  167. public new Padding DefaultMargin { get { return base.DefaultMargin; } }
  168. }
  169. }
  170. }
  171. #endif