GroupBoxTest.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // GroupBoxTest.cs: Test cases for GroupBox.
  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.Windows.Forms;
  11. using System.Drawing;
  12. using System.Reflection;
  13. using NUnit.Framework;
  14. namespace MonoTests.System.Windows.Forms
  15. {
  16. [TestFixture]
  17. public class GroupBoxTest
  18. {
  19. [Test]
  20. public void Constructor ()
  21. {
  22. GroupBox gb = new GroupBox ();
  23. Assert.AreEqual (false, gb.AllowDrop, "A1");
  24. // Top/Height are dependent on font height
  25. // Assert.AreEqual (new Rectangle (3, 16, 194, 81), gb.DisplayRectangle, "A2");
  26. Assert.AreEqual (FlatStyle.Standard, gb.FlatStyle, "A3");
  27. Assert.AreEqual (false, gb.TabStop, "A4");
  28. Assert.AreEqual (string.Empty, gb.Text, "A5");
  29. #if NET_2_0
  30. Assert.AreEqual (false, gb.AutoSize, "A6");
  31. //Assert.AreEqual (AutoSizeMode.GrowOnly, gb.AutoSizeMode, "A7");
  32. Assert.AreEqual (true, gb.UseCompatibleTextRendering, "A8");
  33. #endif
  34. }
  35. [Test]
  36. public void GroupBoxPropertyTest ()
  37. {
  38. Form myform = new Form ();
  39. myform.ShowInTaskbar = false;
  40. GroupBox mygrpbox = new GroupBox ();
  41. RadioButton myradiobutton1 = new RadioButton ();
  42. RadioButton myradiobutton2 = new RadioButton ();
  43. mygrpbox.Controls.Add (myradiobutton1);
  44. mygrpbox.Controls.Add (myradiobutton2);
  45. myform.Show ();
  46. Assert.AreEqual (FlatStyle.Standard, mygrpbox.FlatStyle, "#1");
  47. mygrpbox.FlatStyle = FlatStyle.Popup;
  48. Assert.AreEqual (FlatStyle.Popup, mygrpbox.FlatStyle, "#2");
  49. mygrpbox.FlatStyle = FlatStyle.Flat;
  50. Assert.AreEqual (FlatStyle.Flat, mygrpbox.FlatStyle, "#3");
  51. mygrpbox.FlatStyle = FlatStyle.System;
  52. Assert.AreEqual (FlatStyle.System, mygrpbox.FlatStyle, "#4");
  53. myform.Dispose ();
  54. }
  55. #if NET_2_0
  56. [Test]
  57. public void PropertyDisplayRectangle ()
  58. {
  59. GroupBox gb = new GroupBox ();
  60. gb.Size = new Size (200, 200);
  61. Assert.AreEqual (new Padding (3), gb.Padding, "A0");
  62. gb.Padding = new Padding (25, 25, 25, 25);
  63. Assert.AreEqual (new Rectangle (0, 0, 200, 200), gb.ClientRectangle, "A1");
  64. // Basically, we are testing that the DisplayRectangle includes
  65. // Padding. Top/Height are affected by font height, so we aren't
  66. // using exact numbers.
  67. Assert.AreEqual (25, gb.DisplayRectangle.Left, "A2");
  68. Assert.AreEqual (150, gb.DisplayRectangle.Width, "A3");
  69. Assert.IsTrue (gb.DisplayRectangle.Top > gb.Padding.Top, "A4");
  70. Assert.IsTrue (gb.DisplayRectangle.Height < (gb.Height - gb.Padding.Vertical), "A5");
  71. }
  72. #endif
  73. }
  74. }