ToolBarTest.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. //
  2. // ToolBarTest.cs: Test cases for ToolBar.
  3. //
  4. // Author:
  5. // Ritvik Mayank ([email protected])
  6. //
  7. // (C) 2005 Novell, Inc. (http://www.novell.com)
  8. //
  9. using System;
  10. using System.Drawing;
  11. using System.Globalization;
  12. using System.Windows.Forms;
  13. using NUnit.Framework;
  14. namespace MonoTests.System.Windows.Forms
  15. {
  16. [TestFixture]
  17. public class ToolBarTest
  18. {
  19. [Test] // bug #79863
  20. public void TabStop ()
  21. {
  22. ToolBar tb = new ToolBar ();
  23. Assert.IsFalse (tb.TabStop);
  24. }
  25. [Test]
  26. public void ToolBarPropertyTest ()
  27. {
  28. Form myform = new Form ();
  29. myform.ShowInTaskbar = false;
  30. ToolBar myToolBar = new ToolBar ();
  31. ToolBarButton myToolBarButton1 = new ToolBarButton ();
  32. ToolBarButton myToolBarButton2 = new ToolBarButton ();
  33. myToolBarButton1.Text = "A";
  34. myToolBarButton2.Text = "B";
  35. myToolBar.Buttons.Add (myToolBarButton1);
  36. myToolBar.Buttons.Add (myToolBarButton2);
  37. myform.Controls.Add (myToolBar);
  38. // A
  39. Assert.AreEqual (ToolBarAppearance.Normal, myToolBar.Appearance, "#A1");
  40. Assert.AreEqual (true, myToolBar.AutoSize, "#A2");
  41. // B
  42. Assert.AreEqual ("Control", myToolBar.BackColor.Name, "#B1");
  43. myToolBar.BackgroundImage = Image.FromFile ("M.gif");
  44. Assert.AreEqual (60, myToolBar.BackgroundImage.Height, "#B3");
  45. Assert.AreEqual (BorderStyle.None, myToolBar.BorderStyle, "#B4");
  46. myToolBar.BorderStyle = BorderStyle.Fixed3D;
  47. Assert.AreEqual (BorderStyle.Fixed3D, myToolBar.BorderStyle, "#B5");
  48. Assert.AreEqual (2, myToolBar.Buttons.Count, "#B6");
  49. Assert.AreEqual ("B", myToolBar.Buttons [1].Text, "#B7");
  50. // D
  51. Assert.AreEqual (DockStyle.Top, myToolBar.Dock, "#D1");
  52. Assert.AreEqual (true, myToolBar.Divider, "#D2");
  53. Assert.AreEqual (true, myToolBar.DropDownArrows, "#D3");
  54. // F
  55. Assert.AreEqual ("ControlText", myToolBar.ForeColor.Name, "#F2");
  56. // I
  57. ImageList myImageList = new ImageList ();
  58. myImageList.Images.Add (Image.FromFile ("M.gif"));
  59. myToolBar.ImageList = myImageList;
  60. Assert.AreEqual (1, myToolBar.ImageList.Images.Count, "#I1");
  61. Assert.AreEqual (16, myToolBar.ImageSize.Height, "#I2");
  62. Assert.AreEqual (16, myToolBar.ImageSize.Width, "#I3");
  63. Assert.AreEqual (ImeMode.Disable, myToolBar.ImeMode, "#I4");
  64. // R
  65. Assert.AreEqual (RightToLeft.No, myToolBar.RightToLeft, "#R1");
  66. // S
  67. Assert.AreEqual (true, myToolBar.ShowToolTips, "#S1");
  68. // T
  69. Assert.AreEqual ("", myToolBar.Text, "#T1");
  70. myToolBar.Text = "MONO TOOLBAR";
  71. Assert.AreEqual ("MONO TOOLBAR", myToolBar.Text, "#T2");
  72. Assert.AreEqual (ToolBarTextAlign.Underneath, myToolBar.TextAlign, "#T3");
  73. // WXYZ
  74. Assert.AreEqual (true, myToolBar.Wrappable, "#W1");
  75. myform.Dispose ();
  76. }
  77. [Test]
  78. public void ToStringMethodTest ()
  79. {
  80. ToolBar tb = new ToolBar ();
  81. tb.Text = "New ToolBar";
  82. Assert.AreEqual ("System.Windows.Forms.ToolBar, Buttons.Count: 0",
  83. tb.ToString (), "#1");
  84. ToolBarButton buttonA = new ToolBarButton ("A");
  85. ToolBarButton buttonB = new ToolBarButton ("B");
  86. tb.Buttons.Add (buttonA);
  87. tb.Buttons.Add (buttonB);
  88. Assert.AreEqual ("System.Windows.Forms.ToolBar, Buttons.Count: 2, " +
  89. "Buttons[0]: ToolBarButton: A, Style: PushButton",
  90. tb.ToString (), "#2");
  91. }
  92. [Test]
  93. public void ToolbarButtonRectangleTest ()
  94. {
  95. ToolBar myToolBar = new ToolBar ();
  96. ToolBarButton tbb = new ToolBarButton ("hi");
  97. Assert.IsTrue (tbb.Rectangle.IsEmpty, "#T0");
  98. myToolBar.Visible = false;
  99. myToolBar.Buttons.Add (tbb);
  100. Assert.IsFalse (tbb.Rectangle.IsEmpty, "#T1");
  101. myToolBar.Visible = true;
  102. Assert.IsFalse (tbb.Rectangle.IsEmpty, "#T2");
  103. tbb.Visible = false;
  104. Assert.IsTrue (tbb.Rectangle.IsEmpty, "#T3");
  105. }
  106. }
  107. // [MonoTODO ("Add test for ButtonClickEvent (Visual Test)"]
  108. // [MonoTODO ("Add test for ButtonDropDownEvent (Visual Test)"]
  109. }