2010-04-06 Jb Evain <jbevain@novell.com>
[mcs.git] / class / Managed.Windows.Forms / Test / System.Windows.Forms / ToolStripOverflowButtonTest.cs
blob94b220495ceed9fe3158552fd8d10db7ef973f69
1 //
2 // ToolStripOverflowButtonTest.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.
23 // Copyright (c) 2006 Jonathan Pobst
25 // Authors:
26 // Jonathan Pobst (monkey@jpobst.com)
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;
36 namespace MonoTests.System.Windows.Forms
38 [TestFixture]
39 public class ToolStripOverflowButtonTests : TestHelper
41 [Test]
42 public void Constructor ()
46 [Test]
47 public void ProtectedProperties ()
49 ExposeProtectedProperties epp = new ExposeProtectedProperties ();
51 Assert.AreEqual (new Padding (0, 1, 0, 2), epp.DefaultMargin, "C1");
54 [Test]
55 [Category ("NotWorking")]
56 public void Size2 ()
58 Form f = new Form ();
59 f.ShowInTaskbar = false;
60 f.Show ();
62 ToolStrip ts = new ToolStrip ();
63 f.Controls.Add (ts);
64 ToolStripOverflowButton tsi = ts.OverflowButton;
66 Assert.AreEqual (new Size (16, 25), tsi.Size, "B1");
67 Assert.AreEqual (false, tsi.Visible, "B3");
68 ToolStripItem test = ts.Items.Add ("test");
69 test.Overflow = ToolStripItemOverflow.Always;
70 ts.PerformLayout ();
72 Assert.AreEqual (Size.Empty, tsi.Size, "B2");
73 f.Hide ();
76 [Test]
77 [Category ("NotWorking")]
78 public void MethodGetPreferredSize ()
80 Form f = new Form ();
81 f.ShowInTaskbar = false;
82 f.Show ();
84 ToolStrip ts = new ToolStrip ();
85 f.Controls.Add (ts);
86 ToolStripOverflowButton tsi = ts.OverflowButton;
88 Assert.AreEqual (Size.Empty, tsi.GetPreferredSize (Size.Empty), "B1");
89 Assert.AreEqual (false, tsi.Visible, "B2");
91 ToolStripItem test = ts.Items.Add ("test");
92 test.Overflow = ToolStripItemOverflow.Always;
93 ts.PerformLayout ();
95 Assert.AreEqual (new Size (16, 25), tsi.GetPreferredSize (new Size (100, 100)), "B3");
96 Assert.AreEqual (false, tsi.Visible, "B4");
97 f.Hide ();
100 [Test]
101 [Category ("NotWorking")]
102 public void BehaviorItemsOnOverflow ()
104 Form f = new Form ();
105 f.ShowInTaskbar = false;
106 MyToolStrip ts = new MyToolStrip ();
107 f.Controls.Add (ts);
108 f.Show ();
110 Assert.AreEqual (0, ts.Items.Count, "A1");
111 Assert.AreEqual (1, ts.PublicDisplayedItems.Count, "A2");
112 Assert.AreEqual (false, ts.OverflowButton.Visible, "A3");
113 Assert.AreEqual (0, ts.OverflowButton.DropDown.Items.Count, "A3");
115 ToolStripItem tsi = ts.Items.Add ("test");
117 Assert.AreEqual (1, ts.Items.Count, "A4");
118 Assert.AreEqual (2, ts.PublicDisplayedItems.Count, "A5");
119 Assert.AreEqual (false, ts.OverflowButton.Visible, "A3");
120 Assert.AreEqual (0, ts.OverflowButton.DropDown.Items.Count, "A6");
122 tsi.Overflow = ToolStripItemOverflow.Always;
124 Assert.AreEqual (1, ts.Items.Count, "A7");
125 Assert.AreEqual (2, ts.PublicDisplayedItems.Count, "A8");
126 Assert.AreEqual (true, ts.OverflowButton.Visible, "A3");
127 Assert.AreEqual (0, ts.OverflowButton.DropDown.Items.Count, "A9");
128 Console.WriteLine (ts.PublicDisplayedItems[1].GetType().ToString());
129 f.Dispose ();
132 private class ExposeProtectedProperties : ToolStripButton
134 public new Padding DefaultMargin { get { return base.DefaultMargin; } }
137 private class MyToolStrip : ToolStrip
139 public ToolStripItemCollection PublicDisplayedItems {
140 get { return base.DisplayedItems; }
145 #endif