ToolStripDropDownTest.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // ToolStripDropDownTests.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 ToolStripDropDownTests
  39. {
  40. [Test]
  41. public void Constructor ()
  42. {
  43. ToolStripDropDown tsdd = new ToolStripDropDown ();
  44. Assert.AreEqual (false, tsdd.AllowTransparency, "A1");
  45. Assert.AreEqual (true, tsdd.AutoClose, "A2");
  46. Assert.AreEqual (false, tsdd.CanOverflow, "A3");
  47. Assert.AreEqual (ToolStripDropDownDirection.Right, tsdd.DefaultDropDownDirection, "A4");
  48. Assert.AreEqual (true, tsdd.DropShadowEnabled, "A5");
  49. Assert.AreEqual (false, tsdd.IsAutoGenerated, "A6");
  50. Assert.AreEqual (1, tsdd.Opacity, "A7");
  51. Assert.AreEqual (null, tsdd.OwnerItem, "A8");
  52. Assert.AreEqual (null, tsdd.Region, "A9");
  53. Assert.AreEqual (RightToLeft.No, tsdd.RightToLeft, "A10");
  54. //Assert.AreEqual (ToolStripTextDirection.Horizontal, tsdd.TextDirection, "A11");
  55. Assert.AreEqual (true, tsdd.TopLevel, "A12");
  56. Assert.AreEqual (false, tsdd.Visible, "A13");
  57. }
  58. [Test]
  59. public void ProtectedProperties ()
  60. {
  61. ExposeProtectedProperties epp = new ExposeProtectedProperties ();
  62. Assert.AreEqual (WindowStyles.WS_TILED | WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_POPUP, (WindowStyles)epp.CreateParams.Style, "C1");
  63. // This makes no sense
  64. // Assert.AreEqual (WindowExStyles.WS_EX_CONTROLPARENT, (WindowExStyles)epp.CreateParams.ExStyle, "C2");
  65. Assert.AreEqual (DockStyle.None, epp.DefaultDock, "C3");
  66. Assert.AreEqual (new Padding (1, 2, 1, 2), epp.DefaultPadding, "C4");
  67. Assert.AreEqual (true, epp.DefaultShowItemToolTips, "C5");
  68. // Dependent on monitor resolution
  69. // Assert.AreEqual (new Size (1678, 1016), epp.MaxItemSize, "C6");
  70. Assert.AreEqual (true, epp.TopMost, "C7");
  71. }
  72. [Test]
  73. public void MethodCreateLayoutSettings ()
  74. {
  75. ExposeProtectedProperties ts = new ExposeProtectedProperties ();
  76. Assert.AreEqual ("System.Windows.Forms.FlowLayoutSettings", ts.PublicCreateLayoutSettings (ToolStripLayoutStyle.Flow).ToString (), "A1");
  77. Assert.AreEqual (null, ts.PublicCreateLayoutSettings (ToolStripLayoutStyle.HorizontalStackWithOverflow), "A2");
  78. Assert.AreEqual (null, ts.PublicCreateLayoutSettings (ToolStripLayoutStyle.StackWithOverflow), "A3");
  79. //Assert.AreEqual ("System.Windows.Forms.TableLayoutSettings", ts.PublicCreateLayoutSettings (ToolStripLayoutStyle.Table).ToString (), "A4");
  80. Assert.AreEqual (null, ts.PublicCreateLayoutSettings (ToolStripLayoutStyle.VerticalStackWithOverflow), "A5");
  81. }
  82. //[Test]
  83. //public void Accessibility ()
  84. //{
  85. // ToolStripSeparator tsi = new ToolStripSeparator ();
  86. // AccessibleObject ao = tsi.AccessibilityObject;
  87. // Assert.AreEqual ("ToolStripItemAccessibleObject: Owner = " + tsi.ToString (), ao.ToString (), "L");
  88. // Assert.AreEqual (Rectangle.Empty, ao.Bounds, "L1");
  89. // Assert.AreEqual ("Press", ao.DefaultAction, "L2");
  90. // Assert.AreEqual (null, ao.Description, "L3");
  91. // Assert.AreEqual (null, ao.Help, "L4");
  92. // Assert.AreEqual (string.Empty, ao.KeyboardShortcut, "L5");
  93. // Assert.AreEqual (string.Empty, ao.Name, "L6");
  94. // Assert.AreEqual (null, ao.Parent, "L7");
  95. // Assert.AreEqual (AccessibleRole.Separator, ao.Role, "L8");
  96. // Assert.AreEqual (AccessibleStates.None, ao.State, "L9");
  97. // Assert.AreEqual (string.Empty, ao.Value, "L10");
  98. // tsi.Name = "Label1";
  99. // tsi.Text = "Test Label";
  100. // tsi.AccessibleDescription = "Label Desc";
  101. // Assert.AreEqual (Rectangle.Empty, ao.Bounds, "L11");
  102. // Assert.AreEqual ("Press", ao.DefaultAction, "L12");
  103. // Assert.AreEqual ("Label Desc", ao.Description, "L13");
  104. // Assert.AreEqual (null, ao.Help, "L14");
  105. // Assert.AreEqual (string.Empty, ao.KeyboardShortcut, "L15");
  106. // Assert.AreEqual ("Test Label", ao.Name, "L16");
  107. // Assert.AreEqual (null, ao.Parent, "L17");
  108. // Assert.AreEqual (AccessibleRole.Separator, ao.Role, "L18");
  109. // Assert.AreEqual (AccessibleStates.None, ao.State, "L19");
  110. // Assert.AreEqual (string.Empty, ao.Value, "L20");
  111. // tsi.AccessibleName = "Access Label";
  112. // Assert.AreEqual ("Access Label", ao.Name, "L21");
  113. // tsi.Text = "Test Label";
  114. // Assert.AreEqual ("Access Label", ao.Name, "L22");
  115. // tsi.AccessibleDefaultActionDescription = "AAA";
  116. // Assert.AreEqual ("AAA", tsi.AccessibleDefaultActionDescription, "L23");
  117. //}
  118. private class ExposeProtectedProperties : ToolStripDropDown
  119. {
  120. public new CreateParams CreateParams { get { return base.CreateParams; } }
  121. public new DockStyle DefaultDock { get { return base.DefaultDock; } }
  122. public new Padding DefaultPadding { get { return base.DefaultPadding; } }
  123. public new bool DefaultShowItemToolTips { get { return base.DefaultShowItemToolTips; } }
  124. //public new Size MaxItemSize { get { return base.MaxItemSize; } }
  125. public new bool TopMost { get { return base.TopMost; } }
  126. public LayoutSettings PublicCreateLayoutSettings (ToolStripLayoutStyle style) { return base.CreateLayoutSettings (style); }
  127. }
  128. }
  129. }
  130. #endif