2 // ToolStripOverflowButtonTest.cs
\r
4 // Permission is hereby granted, free of charge, to any person obtaining
\r
5 // a copy of this software and associated documentation files (the
\r
6 // "Software"), to deal in the Software without restriction, including
\r
7 // without limitation the rights to use, copy, modify, merge, publish,
\r
8 // distribute, sublicense, and/or sell copies of the Software, and to
\r
9 // permit persons to whom the Software is furnished to do so, subject to
\r
10 // the following conditions:
\r
12 // The above copyright notice and this permission notice shall be
\r
13 // included in all copies or substantial portions of the Software.
\r
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
\r
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
\r
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
\r
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
23 // Copyright (c) 2006 Jonathan Pobst
\r
26 // Jonathan Pobst (monkey@jpobst.com)
\r
30 using System.Collections.Generic;
\r
32 using NUnit.Framework;
\r
33 using System.Drawing;
\r
34 using System.Windows.Forms;
\r
36 namespace MonoTests.System.Windows.Forms
\r
39 public class ToolStripOverflowButtonTests : TestHelper
\r
42 public void Constructor ()
\r
47 public void ProtectedProperties ()
\r
49 ExposeProtectedProperties epp = new ExposeProtectedProperties ();
\r
51 Assert.AreEqual (new Padding (0, 1, 0, 2), epp.DefaultMargin, "C1");
\r
55 [Category ("NotWorking")]
\r
56 public void Size2 ()
\r
58 Form f = new Form ();
\r
59 f.ShowInTaskbar = false;
\r
62 ToolStrip ts = new ToolStrip ();
\r
63 f.Controls.Add (ts);
\r
64 ToolStripOverflowButton tsi = ts.OverflowButton;
\r
66 Assert.AreEqual (new Size (16, 25), tsi.Size, "B1");
\r
67 Assert.AreEqual (false, tsi.Visible, "B3");
\r
68 ToolStripItem test = ts.Items.Add ("test");
\r
69 test.Overflow = ToolStripItemOverflow.Always;
\r
70 ts.PerformLayout ();
\r
72 Assert.AreEqual (Size.Empty, tsi.Size, "B2");
\r
77 [Category ("NotWorking")]
\r
78 public void MethodGetPreferredSize ()
\r
80 Form f = new Form ();
\r
81 f.ShowInTaskbar = false;
\r
84 ToolStrip ts = new ToolStrip ();
\r
85 f.Controls.Add (ts);
\r
86 ToolStripOverflowButton tsi = ts.OverflowButton;
\r
88 Assert.AreEqual (Size.Empty, tsi.GetPreferredSize (Size.Empty), "B1");
\r
89 Assert.AreEqual (false, tsi.Visible, "B2");
\r
91 ToolStripItem test = ts.Items.Add ("test");
\r
92 test.Overflow = ToolStripItemOverflow.Always;
\r
93 ts.PerformLayout ();
\r
95 Assert.AreEqual (new Size (16, 25), tsi.GetPreferredSize (new Size (100, 100)), "B3");
\r
96 Assert.AreEqual (false, tsi.Visible, "B4");
\r
101 [Category ("NotWorking")]
\r
102 public void BehaviorItemsOnOverflow ()
\r
104 Form f = new Form ();
\r
105 f.ShowInTaskbar = false;
\r
106 MyToolStrip ts = new MyToolStrip ();
\r
107 f.Controls.Add (ts);
\r
110 Assert.AreEqual (0, ts.Items.Count, "A1");
\r
111 Assert.AreEqual (1, ts.PublicDisplayedItems.Count, "A2");
\r
112 Assert.AreEqual (false, ts.OverflowButton.Visible, "A3");
\r
113 Assert.AreEqual (0, ts.OverflowButton.DropDown.Items.Count, "A3");
\r
115 ToolStripItem tsi = ts.Items.Add ("test");
\r
117 Assert.AreEqual (1, ts.Items.Count, "A4");
\r
118 Assert.AreEqual (2, ts.PublicDisplayedItems.Count, "A5");
\r
119 Assert.AreEqual (false, ts.OverflowButton.Visible, "A3");
\r
120 Assert.AreEqual (0, ts.OverflowButton.DropDown.Items.Count, "A6");
\r
122 tsi.Overflow = ToolStripItemOverflow.Always;
\r
124 Assert.AreEqual (1, ts.Items.Count, "A7");
\r
125 Assert.AreEqual (2, ts.PublicDisplayedItems.Count, "A8");
\r
126 Assert.AreEqual (true, ts.OverflowButton.Visible, "A3");
\r
127 Assert.AreEqual (0, ts.OverflowButton.DropDown.Items.Count, "A9");
\r
128 Console.WriteLine (ts.PublicDisplayedItems[1].GetType().ToString());
\r
132 private class ExposeProtectedProperties : ToolStripButton
\r
134 public new Padding DefaultMargin { get { return base.DefaultMargin; } }
\r
137 private class MyToolStrip : ToolStrip
\r
139 public ToolStripItemCollection PublicDisplayedItems {
\r
140 get { return base.DisplayedItems; }
\r