ToolStripContainerTest.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // ToolStripContainerTests.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) 2007 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 ToolStripContainerTests : TestHelper
  39. {
  40. [Test]
  41. public void Constructor ()
  42. {
  43. ToolStripContainer tsc = new ToolStripContainer ();
  44. Assert.AreEqual ("System.Windows.Forms.ToolStripPanel", tsc.BottomToolStripPanel.ToString (), "A1");
  45. Assert.AreEqual (true, tsc.BottomToolStripPanelVisible, "A2");
  46. Assert.AreEqual ("System.Windows.Forms.ToolStripContentPanel", tsc.ContentPanel.GetType ().ToString (), "A3");
  47. Assert.AreEqual ("System.Windows.Forms.ToolStripPanel", tsc.LeftToolStripPanel.ToString (), "A4");
  48. Assert.AreEqual (true, tsc.LeftToolStripPanelVisible, "A5");
  49. Assert.AreEqual ("System.Windows.Forms.ToolStripPanel", tsc.RightToolStripPanel.ToString (), "A6");
  50. Assert.AreEqual (true, tsc.RightToolStripPanelVisible, "A7");
  51. Assert.AreEqual ("System.Windows.Forms.ToolStripPanel", tsc.TopToolStripPanel.ToString (), "A8");
  52. Assert.AreEqual (true, tsc.TopToolStripPanelVisible, "A9");
  53. }
  54. [Test]
  55. public void ProtectedProperties ()
  56. {
  57. ExposeProtectedProperties epp = new ExposeProtectedProperties ();
  58. Assert.AreEqual (new Size (150, 175), epp.DefaultSize, "C1");
  59. }
  60. [Test]
  61. public void PropertyBottomToolStripPanelVisible ()
  62. {
  63. ToolStripContainer tsc = new ToolStripContainer ();
  64. tsc.BottomToolStripPanelVisible = false; ;
  65. Assert.AreEqual (false, tsc.BottomToolStripPanelVisible, "B1");
  66. }
  67. [Test]
  68. public void PropertyLeftToolStripPanelVisible ()
  69. {
  70. ToolStripContainer tsc = new ToolStripContainer ();
  71. tsc.LeftToolStripPanelVisible = false; ;
  72. Assert.AreEqual (false, tsc.LeftToolStripPanelVisible, "B1");
  73. }
  74. [Test]
  75. public void PropertyRightToolStripPanelVisible ()
  76. {
  77. ToolStripContainer tsc = new ToolStripContainer ();
  78. tsc.RightToolStripPanelVisible = false; ;
  79. Assert.AreEqual (false, tsc.RightToolStripPanelVisible, "B1");
  80. }
  81. [Test]
  82. public void PropertyTopToolStripPanelVisible ()
  83. {
  84. ToolStripContainer tsc = new ToolStripContainer ();
  85. tsc.TopToolStripPanelVisible = false; ;
  86. Assert.AreEqual (false, tsc.TopToolStripPanelVisible, "B1");
  87. }
  88. [Test]
  89. public void MethodCreateControlsInstance ()
  90. {
  91. ExposeProtectedProperties epp = new ExposeProtectedProperties ();
  92. Assert.AreEqual ("System.Windows.Forms.ToolStripContainer+ToolStripContainerTypedControlCollection", epp.CreateControlsInstance (). GetType ().ToString (), "B1");
  93. }
  94. [Test]
  95. public void ControlStyle ()
  96. {
  97. ExposeProtectedProperties epp = new ExposeProtectedProperties ();
  98. ControlStyles cs = ControlStyles.ContainerControl;
  99. cs |= ControlStyles.UserPaint;
  100. cs |= ControlStyles.StandardClick;
  101. cs |= ControlStyles.SupportsTransparentBackColor;
  102. cs |= ControlStyles.StandardDoubleClick;
  103. cs |= ControlStyles.Selectable;
  104. cs |= ControlStyles.ResizeRedraw;
  105. cs |= ControlStyles.UseTextForAccessibility;
  106. Assert.AreEqual (cs, epp.GetControlStyles (), "Styles");
  107. }
  108. private class ExposeProtectedProperties : ToolStripContainer
  109. {
  110. public new Size DefaultSize { get { return base.DefaultSize; } }
  111. public new ControlCollection CreateControlsInstance () { return base.CreateControlsInstance (); }
  112. public ControlStyles GetControlStyles ()
  113. {
  114. ControlStyles retval = (ControlStyles)0;
  115. foreach (ControlStyles cs in Enum.GetValues (typeof (ControlStyles)))
  116. if (this.GetStyle (cs) == true)
  117. retval |= cs;
  118. return retval;
  119. }
  120. }
  121. }
  122. }
  123. #endif