2 // ToolStripOverflowButtonTest.cs
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:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
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
26 // Jonathan Pobst (monkey@jpobst.com)
30 using System
.Collections
.Generic
;
32 using NUnit
.Framework
;
34 using System
.Windows
.Forms
;
36 namespace MonoTests
.System
.Windows
.Forms
39 public class ToolStripOverflowButtonTests
: TestHelper
42 public void Constructor ()
47 public void ProtectedProperties ()
49 ExposeProtectedProperties epp
= new ExposeProtectedProperties ();
51 Assert
.AreEqual (new Padding (0, 1, 0, 2), epp
.DefaultMargin
, "C1");
55 [Category ("NotWorking")]
59 f
.ShowInTaskbar
= false;
62 ToolStrip ts
= new ToolStrip ();
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
;
72 Assert
.AreEqual (Size
.Empty
, tsi
.Size
, "B2");
77 [Category ("NotWorking")]
78 public void MethodGetPreferredSize ()
81 f
.ShowInTaskbar
= false;
84 ToolStrip ts
= new ToolStrip ();
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
;
95 Assert
.AreEqual (new Size (16, 25), tsi
.GetPreferredSize (new Size (100, 100)), "B3");
96 Assert
.AreEqual (false, tsi
.Visible
, "B4");
101 [Category ("NotWorking")]
102 public void BehaviorItemsOnOverflow ()
104 Form f
= new Form ();
105 f
.ShowInTaskbar
= false;
106 MyToolStrip ts
= new MyToolStrip ();
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());
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; }