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
29 using System.Collections.Generic;
\r
31 using NUnit.Framework;
\r
32 using System.Drawing;
\r
33 using System.Windows.Forms;
\r
35 namespace MonoTests.System.Windows.Forms
\r
38 public class ToolStripOverflowButtonTests : TestHelper
\r
41 public void Constructor ()
\r
46 public void ProtectedProperties ()
\r
48 ExposeProtectedProperties epp = new ExposeProtectedProperties ();
\r
50 Assert.AreEqual (new Padding (0, 1, 0, 2), epp.DefaultMargin, "C1");
\r
54 [Category ("NotWorking")]
\r
55 public void Size2 ()
\r
57 Form f = new Form ();
\r
58 f.ShowInTaskbar = false;
\r
61 ToolStrip ts = new ToolStrip ();
\r
62 f.Controls.Add (ts);
\r
63 ToolStripOverflowButton tsi = ts.OverflowButton;
\r
65 Assert.AreEqual (new Size (16, 25), tsi.Size, "B1");
\r
66 Assert.AreEqual (false, tsi.Visible, "B3");
\r
67 ToolStripItem test = ts.Items.Add ("test");
\r
68 test.Overflow = ToolStripItemOverflow.Always;
\r
69 ts.PerformLayout ();
\r
71 Assert.AreEqual (Size.Empty, tsi.Size, "B2");
\r
76 [Category ("NotWorking")]
\r
77 public void MethodGetPreferredSize ()
\r
79 Form f = new Form ();
\r
80 f.ShowInTaskbar = false;
\r
83 ToolStrip ts = new ToolStrip ();
\r
84 f.Controls.Add (ts);
\r
85 ToolStripOverflowButton tsi = ts.OverflowButton;
\r
87 Assert.AreEqual (Size.Empty, tsi.GetPreferredSize (Size.Empty), "B1");
\r
88 Assert.AreEqual (false, tsi.Visible, "B2");
\r
90 ToolStripItem test = ts.Items.Add ("test");
\r
91 test.Overflow = ToolStripItemOverflow.Always;
\r
92 ts.PerformLayout ();
\r
94 Assert.AreEqual (new Size (16, 25), tsi.GetPreferredSize (new Size (100, 100)), "B3");
\r
95 Assert.AreEqual (false, tsi.Visible, "B4");
\r
100 [Category ("NotWorking")]
\r
101 public void BehaviorItemsOnOverflow ()
\r
103 Form f = new Form ();
\r
104 f.ShowInTaskbar = false;
\r
105 MyToolStrip ts = new MyToolStrip ();
\r
106 f.Controls.Add (ts);
\r
109 Assert.AreEqual (0, ts.Items.Count, "A1");
\r
110 Assert.AreEqual (1, ts.PublicDisplayedItems.Count, "A2");
\r
111 Assert.AreEqual (false, ts.OverflowButton.Visible, "A3");
\r
112 Assert.AreEqual (0, ts.OverflowButton.DropDown.Items.Count, "A3");
\r
114 ToolStripItem tsi = ts.Items.Add ("test");
\r
116 Assert.AreEqual (1, ts.Items.Count, "A4");
\r
117 Assert.AreEqual (2, ts.PublicDisplayedItems.Count, "A5");
\r
118 Assert.AreEqual (false, ts.OverflowButton.Visible, "A3");
\r
119 Assert.AreEqual (0, ts.OverflowButton.DropDown.Items.Count, "A6");
\r
121 tsi.Overflow = ToolStripItemOverflow.Always;
\r
123 Assert.AreEqual (1, ts.Items.Count, "A7");
\r
124 Assert.AreEqual (2, ts.PublicDisplayedItems.Count, "A8");
\r
125 Assert.AreEqual (true, ts.OverflowButton.Visible, "A3");
\r
126 Assert.AreEqual (0, ts.OverflowButton.DropDown.Items.Count, "A9");
\r
127 Console.WriteLine (ts.PublicDisplayedItems[1].GetType().ToString());
\r
131 private class ExposeProtectedProperties : ToolStripButton
\r
133 public new Padding DefaultMargin { get { return base.DefaultMargin; } }
\r
136 private class MyToolStrip : ToolStrip
\r
138 public ToolStripItemCollection PublicDisplayedItems {
\r
139 get { return base.DisplayedItems; }
\r