StatusBarPanelTest.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. //
  2. // StatusBarPanelTest.cs: Test cases for StatusBar.
  3. //
  4. // (C) 2006 Novell, Inc. (http://www.novell.com)
  5. //
  6. using System;
  7. using NUnit.Framework;
  8. using System.Windows.Forms;
  9. using System.Drawing;
  10. using System.Runtime.Remoting;
  11. namespace MonoTests.System.Windows.Forms
  12. {
  13. [TestFixture]
  14. public class StatusBarPanelTest : TestHelper
  15. {
  16. [Test]
  17. public void MinimumWidth1 ()
  18. {
  19. StatusBarPanel p = new StatusBarPanel ();
  20. Assert.AreEqual (10, p.MinWidth, "1");
  21. }
  22. [Test]
  23. public void MinimumWidth2 ()
  24. {
  25. StatusBarPanel p = new StatusBarPanel ();
  26. p.Width = 50;
  27. p.MinWidth = 100;
  28. Assert.AreEqual (100, p.Width, "1");
  29. }
  30. [Test]
  31. public void MinimumWidth3 ()
  32. {
  33. StatusBarPanel p = new StatusBarPanel ();
  34. p.Width = 50;
  35. p.MinWidth = 200;
  36. p.MinWidth = 25;
  37. Assert.AreEqual (200, p.Width, "#1");
  38. p = new StatusBarPanel ();
  39. p.Width = 50;
  40. p.MinWidth = 25;
  41. Assert.AreEqual (50, p.Width, "#2");
  42. p = new StatusBarPanel ();
  43. p.Width = 50;
  44. p.MinWidth = 100;
  45. Assert.AreEqual (100, p.Width, "#3");
  46. p = new StatusBarPanel ();
  47. p.MinWidth = 200;
  48. Assert.AreEqual (200, p.Width, "#4");
  49. }
  50. [Test]
  51. #if NET_2_0
  52. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  53. #else
  54. [ExpectedException(typeof(ArgumentException))]
  55. #endif
  56. public void MinimumWidth4 ()
  57. {
  58. StatusBarPanel p = new StatusBarPanel ();
  59. p.MinWidth = -50;
  60. }
  61. [Test]
  62. public void MinWidth_AutoSize_None ()
  63. {
  64. StatusBarPanel p = new StatusBarPanel ();
  65. p.Width = 50;
  66. Assert.AreEqual (10, p.MinWidth, "#1");
  67. }
  68. [Test]
  69. public void ToStringTest ()
  70. {
  71. StatusBarPanel p = new StatusBarPanel ();
  72. Assert.AreEqual ("StatusBarPanel: {}", p.ToString(), "1");
  73. p.Text = "Hello";
  74. Assert.AreEqual ("StatusBarPanel: {Hello}", p.ToString(), "2");
  75. p.Text = "}";
  76. Assert.AreEqual ("StatusBarPanel: {}}", p.ToString(), "3");
  77. }
  78. [Test]
  79. public void DefaultPropertiesTest ()
  80. {
  81. StatusBarPanel p = new StatusBarPanel ();
  82. Assert.AreEqual (100, p.Width, "#1");
  83. Assert.AreEqual (10, p.MinWidth, "#2");
  84. Assert.AreEqual (String.Empty, p.Text, "#3");
  85. Assert.AreEqual (HorizontalAlignment.Left, p.Alignment, "#4");
  86. Assert.AreEqual (StatusBarPanelAutoSize.None, p.AutoSize, "#5");
  87. Assert.AreEqual (StatusBarPanelBorderStyle.Sunken, p.BorderStyle, "#6");
  88. Assert.AreEqual (StatusBarPanelStyle.Text, p.Style, "#7");
  89. Assert.AreEqual (String.Empty, p.ToolTipText, "#8");
  90. }
  91. [Test] // bug 82487
  92. public void IconWidth ()
  93. {
  94. using (Form f = new Form ()) {
  95. StatusBar _statusBar;
  96. StatusBarPanel _myComputerPanel;
  97. _statusBar = new StatusBar ();
  98. _statusBar.ShowPanels = true;
  99. //Controls.Add (_statusBar);
  100. _myComputerPanel = new StatusBarPanel ();
  101. _myComputerPanel.AutoSize = StatusBarPanelAutoSize.Contents;
  102. _myComputerPanel.Text = "My Computer";
  103. _statusBar.Panels.Add (_myComputerPanel);
  104. int width = _myComputerPanel.Width;
  105. _myComputerPanel.Icon = f.Icon;
  106. Assert.AreEqual (width + 21, _myComputerPanel.Width, "#01");
  107. }
  108. }
  109. #if NET_2_0
  110. [Test]
  111. public void TagTest ()
  112. {
  113. StatusBarPanel p = new StatusBarPanel ();
  114. Assert.AreEqual (null, p.Tag, "#1");
  115. p.Tag = "a";
  116. Assert.AreEqual ("a", p.Tag, "#2");
  117. p.Tag = null;
  118. Assert.AreEqual (null, p.Tag, "#3");
  119. }
  120. [Test]
  121. public void NameTest ()
  122. {
  123. StatusBarPanel p = new StatusBarPanel ();
  124. Assert.AreEqual ("", p.Name, "#1");
  125. p.Name = "a";
  126. Assert.AreEqual ("a", p.Name, "#2");
  127. p.Name = null;
  128. Assert.AreEqual ("", p.Name, "#3");
  129. }
  130. #endif
  131. }
  132. }