2 // GroupBoxTest.cs: Test cases for GroupBox.
5 // Ritvik Mayank (mritvik@novell.com)
7 // (C) 2005 Novell, Inc. (http://www.novell.com)
11 using System.Windows.Forms;
13 using System.Reflection;
14 using NUnit.Framework;
16 namespace MonoTests.System.Windows.Forms
19 public class GroupBoxTest : TestHelper
22 public void Constructor ()
24 GroupBox gb = new GroupBox ();
26 Assert.AreEqual (false, gb.AllowDrop, "A1");
27 // Top/Height are dependent on font height
28 // Assert.AreEqual (new Rectangle (3, 16, 194, 81), gb.DisplayRectangle, "A2");
29 Assert.AreEqual (FlatStyle.Standard, gb.FlatStyle, "A3");
30 Assert.AreEqual (false, gb.TabStop, "A4");
31 Assert.AreEqual (string.Empty, gb.Text, "A5");
33 Assert.AreEqual (false, gb.AutoSize, "A6");
34 Assert.AreEqual (AutoSizeMode.GrowOnly, gb.AutoSizeMode, "A7");
35 Assert.AreEqual (true, gb.UseCompatibleTextRendering, "A8");
36 Assert.AreEqual ("System.Windows.Forms.GroupBox+GroupBoxAccessibleObject", gb.AccessibilityObject.GetType ().ToString (), "A9");
40 public void GroupBoxPropertyTest ()
42 Form myform = new Form ();
43 myform.ShowInTaskbar = false;
44 GroupBox mygrpbox = new GroupBox ();
45 RadioButton myradiobutton1 = new RadioButton ();
46 RadioButton myradiobutton2 = new RadioButton ();
47 mygrpbox.Controls.Add (myradiobutton1);
48 mygrpbox.Controls.Add (myradiobutton2);
50 Assert.AreEqual (FlatStyle.Standard, mygrpbox.FlatStyle, "#1");
51 mygrpbox.FlatStyle = FlatStyle.Popup;
52 Assert.AreEqual (FlatStyle.Popup, mygrpbox.FlatStyle, "#2");
53 mygrpbox.FlatStyle = FlatStyle.Flat;
54 Assert.AreEqual (FlatStyle.Flat, mygrpbox.FlatStyle, "#3");
55 mygrpbox.FlatStyle = FlatStyle.System;
56 Assert.AreEqual (FlatStyle.System, mygrpbox.FlatStyle, "#4");
61 public void AutoSize ()
63 if (TestHelper.RunningOnUnix)
64 Assert.Ignore ("Dependent on font height and theme, values are for windows.");
67 f.ShowInTaskbar = false;
69 GroupBox p = new GroupBox ();
73 Button b = new Button ();
74 b.Size = new Size (200, 200);
75 b.Location = new Point (200, 200);
80 Assert.AreEqual (new Size (406, 419), p.ClientSize, "A1");
82 p.Controls.Remove (b);
83 Assert.AreEqual (new Size (200, 100), p.ClientSize, "A2");
85 p.AutoSizeMode = AutoSizeMode.GrowAndShrink;
86 Assert.AreEqual (new Size (6, 19), p.ClientSize, "A3");
92 public void PropertyDisplayRectangle ()
94 GroupBox gb = new GroupBox ();
95 gb.Size = new Size (200, 200);
97 Assert.AreEqual (new Padding (3), gb.Padding, "A0");
98 gb.Padding = new Padding (25, 25, 25, 25);
100 Assert.AreEqual (new Rectangle (0, 0, 200, 200), gb.ClientRectangle, "A1");
102 // Basically, we are testing that the DisplayRectangle includes
103 // Padding. Top/Height are affected by font height, so we aren't
104 // using exact numbers.
105 Assert.AreEqual (25, gb.DisplayRectangle.Left, "A2");
106 Assert.AreEqual (150, gb.DisplayRectangle.Width, "A3");
107 Assert.IsTrue (gb.DisplayRectangle.Top > gb.Padding.Top, "A4");
108 Assert.IsTrue (gb.DisplayRectangle.Height < (gb.Height - gb.Padding.Vertical), "A5");
112 public void MethodScaleControl ()
114 Form f = new Form ();
115 f.ShowInTaskbar = false;
119 PublicGroupBox gb = new PublicGroupBox ();
120 gb.Location = new Point (5, 10);
123 Assert.AreEqual (new Rectangle (5, 10, 200, 100), gb.Bounds, "A1");
125 gb.PublicScaleControl (new SizeF (2.0f, 2.0f), BoundsSpecified.All);
126 Assert.AreEqual (new Rectangle (10, 20, 400, 200), gb.Bounds, "A2");
128 gb.PublicScaleControl (new SizeF (.5f, .5f), BoundsSpecified.Location);
129 Assert.AreEqual (new Rectangle (5, 10, 400, 200), gb.Bounds, "A3");
131 gb.PublicScaleControl (new SizeF (.5f, .5f), BoundsSpecified.Size);
132 Assert.AreEqual (new Rectangle (5, 10, 200, 100), gb.Bounds, "A4");
137 private class PublicGroupBox : GroupBox
139 public void PublicScaleControl (SizeF factor, BoundsSpecified specified)
141 base.ScaleControl (factor, specified);