ToolStripSeparatorTest.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // ToolStripSeparatorTests.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 ToolStripSeparatorTests
  39. {
  40. [Test]
  41. public void Constructor ()
  42. {
  43. ToolStripSeparator tsi = new ToolStripSeparator ();
  44. Assert.AreEqual (false, tsi.CanSelect, "A1");
  45. }
  46. [Test]
  47. public void ProtectedProperties ()
  48. {
  49. ExposeProtectedProperties epp = new ExposeProtectedProperties ();
  50. Assert.AreEqual (new Padding (0), epp.DefaultMargin, "C1");
  51. Assert.AreEqual (new Size (6, 6), epp.DefaultSize, "C2");
  52. }
  53. [Test]
  54. public void Accessibility ()
  55. {
  56. ToolStripSeparator tsi = new ToolStripSeparator ();
  57. AccessibleObject ao = tsi.AccessibilityObject;
  58. Assert.AreEqual ("ToolStripItemAccessibleObject: Owner = " + tsi.ToString (), ao.ToString (), "L");
  59. Assert.AreEqual (Rectangle.Empty, ao.Bounds, "L1");
  60. Assert.AreEqual ("Press", ao.DefaultAction, "L2");
  61. Assert.AreEqual (null, ao.Description, "L3");
  62. Assert.AreEqual (null, ao.Help, "L4");
  63. Assert.AreEqual (string.Empty, ao.KeyboardShortcut, "L5");
  64. Assert.AreEqual (string.Empty, ao.Name, "L6");
  65. Assert.AreEqual (null, ao.Parent, "L7");
  66. Assert.AreEqual (AccessibleRole.Separator, ao.Role, "L8");
  67. Assert.AreEqual (AccessibleStates.None, ao.State, "L9");
  68. Assert.AreEqual (string.Empty, ao.Value, "L10");
  69. tsi.Name = "Label1";
  70. tsi.Text = "Test Label";
  71. tsi.AccessibleDescription = "Label Desc";
  72. Assert.AreEqual (Rectangle.Empty, ao.Bounds, "L11");
  73. Assert.AreEqual ("Press", ao.DefaultAction, "L12");
  74. Assert.AreEqual ("Label Desc", ao.Description, "L13");
  75. Assert.AreEqual (null, ao.Help, "L14");
  76. Assert.AreEqual (string.Empty, ao.KeyboardShortcut, "L15");
  77. Assert.AreEqual ("Test Label", ao.Name, "L16");
  78. Assert.AreEqual (null, ao.Parent, "L17");
  79. Assert.AreEqual (AccessibleRole.Separator, ao.Role, "L18");
  80. Assert.AreEqual (AccessibleStates.None, ao.State, "L19");
  81. Assert.AreEqual (string.Empty, ao.Value, "L20");
  82. tsi.AccessibleName = "Access Label";
  83. Assert.AreEqual ("Access Label", ao.Name, "L21");
  84. tsi.Text = "Test Label";
  85. Assert.AreEqual ("Access Label", ao.Name, "L22");
  86. tsi.AccessibleDefaultActionDescription = "AAA";
  87. Assert.AreEqual ("AAA", tsi.AccessibleDefaultActionDescription, "L23");
  88. }
  89. private class ExposeProtectedProperties : ToolStripSeparator
  90. {
  91. public new Padding DefaultMargin { get { return base.DefaultMargin; } }
  92. public new Size DefaultSize { get { return base.DefaultSize; } }
  93. }
  94. }
  95. }
  96. #endif