2007-01-10 Chris Toshok <toshok@ximian.com>
[mono-project.git] / mcs / class / Managed.Windows.Forms / Test / System.Windows.Forms / ToolStripProgressBarTest.cs
blob98a400ea27e02691dc521bd49e63e4a541f63b54
1 //
2 // ToolStripProgressBarTests.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;
35 using System.ComponentModel;
37 namespace MonoTests.System.Windows.Forms
39 [TestFixture]
40 public class ToolStripProgressBarTests
42 [Test]
43 public void Constructor ()
45 ToolStripProgressBar tsi = new ToolStripProgressBar ();
47 //Assert.AreEqual (100, tsi.MarqueeAnimationSpeed, "A1");
48 Assert.AreEqual (100, tsi.Maximum, "A2");
49 Assert.AreEqual (0, tsi.Minimum, "A3");
50 Assert.AreEqual ("System.Windows.Forms.ProgressBar", tsi.ProgressBar.GetType ().ToString (), "A4");
51 //Assert.AreEqual (false, tsi.RightToLeftLayout, "A5");
52 Assert.AreEqual (10, tsi.Step, "A6");
53 Assert.AreEqual (ProgressBarStyle.Blocks, tsi.Style, "A7");
54 Assert.AreEqual (string.Empty, tsi.Text, "A8");
55 Assert.AreEqual (0, tsi.Value, "A9");
57 tsi = new ToolStripProgressBar ("Bob");
58 Assert.AreEqual ("Bob", tsi.Name, "A10");
59 Assert.AreEqual (string.Empty, tsi.Control.Name, "A11");
62 [Test]
63 public void ProtectedProperties ()
65 ExposeProtectedProperties epp = new ExposeProtectedProperties ();
67 Assert.AreEqual (new Padding (1, 2, 1, 1), epp.DefaultMargin, "C1");
68 Assert.AreEqual (new Size (100, 15), epp.DefaultSize, "C2");
71 //[Test]
72 //public void PropertyMarqueeAnimationSpeed ()
73 //{
74 // ToolStripProgressBar tsi = new ToolStripProgressBar ();
75 // EventWatcher ew = new EventWatcher (tsi);
77 // tsi.MarqueeAnimationSpeed = 200;
78 // Assert.AreEqual (200, tsi.MarqueeAnimationSpeed, "B1");
79 // Assert.AreEqual (string.Empty, ew.ToString (), "B2");
81 // ew.Clear ();
82 // tsi.MarqueeAnimationSpeed = 200;
83 // Assert.AreEqual (string.Empty, ew.ToString (), "B3");
84 //}
86 [Test]
87 public void PropertyMaximum ()
89 ToolStripProgressBar tsi = new ToolStripProgressBar ();
90 EventWatcher ew = new EventWatcher (tsi);
92 tsi.Maximum = 200;
93 Assert.AreEqual (200, tsi.Maximum, "B1");
94 Assert.AreEqual (string.Empty, ew.ToString (), "B2");
96 ew.Clear ();
97 tsi.Maximum = 200;
98 Assert.AreEqual (string.Empty, ew.ToString (), "B3");
101 [Test]
102 public void PropertyMinimum ()
104 ToolStripProgressBar tsi = new ToolStripProgressBar ();
105 EventWatcher ew = new EventWatcher (tsi);
107 tsi.Minimum = 200;
108 Assert.AreEqual (200, tsi.Minimum, "B1");
109 Assert.AreEqual (string.Empty, ew.ToString (), "B2");
111 ew.Clear ();
112 tsi.Minimum = 200;
113 Assert.AreEqual (string.Empty, ew.ToString (), "B3");
116 //[Test]
117 //public void PropertyRightToLeft ()
119 // ToolStripProgressBar tsi = new ToolStripProgressBar ();
120 // EventWatcher ew = new EventWatcher (tsi);
122 // tsi.RightToLeftLayout = true;
123 // Assert.AreEqual (true, tsi.RightToLeftLayout, "B1");
124 // Assert.AreEqual ("RightToLeftLayoutChanged", ew.ToString (), "B2");
126 // ew.Clear ();
127 // tsi.RightToLeftLayout = true;
128 // Assert.AreEqual (string.Empty, ew.ToString (), "B3");
132 [Test]
133 public void PropertyStep ()
135 ToolStripProgressBar tsi = new ToolStripProgressBar ();
136 EventWatcher ew = new EventWatcher (tsi);
138 tsi.Step = 200;
139 Assert.AreEqual (200, tsi.Step, "B1");
140 Assert.AreEqual (string.Empty, ew.ToString (), "B2");
142 ew.Clear ();
143 tsi.Step = 200;
144 Assert.AreEqual (string.Empty, ew.ToString (), "B3");
147 [Test]
148 public void PropertyStyle ()
150 ToolStripProgressBar tsi = new ToolStripProgressBar ();
151 EventWatcher ew = new EventWatcher (tsi);
153 tsi.Style = ProgressBarStyle.Continuous;
154 Assert.AreEqual (ProgressBarStyle.Continuous, tsi.Style, "B1");
155 Assert.AreEqual (string.Empty, ew.ToString (), "B2");
157 ew.Clear ();
158 tsi.Style = ProgressBarStyle.Continuous;
159 Assert.AreEqual (string.Empty, ew.ToString (), "B3");
162 [Test]
163 public void PropertyText ()
165 ToolStripProgressBar tsi = new ToolStripProgressBar ();
166 EventWatcher ew = new EventWatcher (tsi);
168 tsi.Text = "Hi";
169 Assert.AreEqual ("Hi", tsi.Text, "B1");
170 Assert.AreEqual ("Hi", tsi.ProgressBar.Text, "B2");
171 Assert.AreEqual (string.Empty, ew.ToString (), "B3");
173 ew.Clear ();
174 tsi.Text = "Hi";
175 Assert.AreEqual (string.Empty, ew.ToString (), "B4");
178 [Test]
179 public void PropertyValue ()
181 ToolStripProgressBar tsi = new ToolStripProgressBar ();
182 EventWatcher ew = new EventWatcher (tsi);
184 tsi.Value = 30;
185 Assert.AreEqual (30, tsi.Value, "B1");
186 Assert.AreEqual (string.Empty, ew.ToString (), "B2");
188 ew.Clear ();
189 tsi.Value = 30;
190 Assert.AreEqual (string.Empty, ew.ToString (), "B3");
193 [Test]
194 [Ignore ("ProgressBar throws AE, not AOORE")]
195 [ExpectedException (typeof (ArgumentOutOfRangeException))]
196 public void PropertyValueAOORE ()
198 ToolStripProgressBar tsi = new ToolStripProgressBar ();
200 tsi.Value = 200;
203 [Test]
204 public void BehaviorIncrement ()
206 ToolStripProgressBar tsi = new ToolStripProgressBar ();
208 tsi.Increment (14);
209 Assert.AreEqual (14, tsi.Value, "B1");
211 tsi.Increment (104);
212 Assert.AreEqual (100, tsi.Value, "B2");
214 tsi.Increment (-245);
215 Assert.AreEqual (0, tsi.Value, "B3");
218 [Test]
219 public void BehaviorPerformStep ()
221 ToolStripProgressBar tsi = new ToolStripProgressBar ();
223 tsi.PerformStep ();
224 Assert.AreEqual (10, tsi.Value, "B1");
227 //[Test]
228 //public void PropertyAnchorAndDocking ()
230 // ToolStripItem ts = new NullToolStripItem ();
232 // ts.Anchor = AnchorStyles.Top | AnchorStyles.Bottom;
234 // Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Bottom, ts.Anchor, "A1");
235 // Assert.AreEqual (DockStyle.None, ts.Dock, "A2");
237 // ts.Anchor = AnchorStyles.Left | AnchorStyles.Right;
239 // Assert.AreEqual (AnchorStyles.Left | AnchorStyles.Right, ts.Anchor, "A1");
240 // Assert.AreEqual (DockStyle.None, ts.Dock, "A2");
242 // ts.Dock = DockStyle.Left;
244 // Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, ts.Anchor, "A1");
245 // Assert.AreEqual (DockStyle.Left, ts.Dock, "A2");
247 // ts.Dock = DockStyle.None;
249 // Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, ts.Anchor, "A1");
250 // Assert.AreEqual (DockStyle.None, ts.Dock, "A2");
252 // ts.Dock = DockStyle.Top;
254 // Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, ts.Anchor, "A1");
255 // Assert.AreEqual (DockStyle.Top, ts.Dock, "A2");
258 //[Test]
259 //[Ignore ("Accessibility still needs some work")]
260 //public void Accessibility ()
262 // ToolStripControlHost tsi = new ToolStripControlHost (new Button ());
263 // AccessibleObject ao = tsi.AccessibilityObject;
265 // Assert.AreEqual ("Press", ao.DefaultAction, "L2");
266 // Assert.AreEqual (null, ao.Description, "L3");
267 // Assert.AreEqual (null, ao.Help, "L4");
268 // Assert.AreEqual (null, ao.KeyboardShortcut, "L5");
269 // Assert.AreEqual (null, ao.Name, "L6");
270 // Assert.AreEqual (AccessibleRole.PushButton, ao.Role, "L8");
271 // Assert.AreEqual (AccessibleStates.None, ao.State, "L9");
272 // Assert.AreEqual (null, ao.Value, "L10");
274 // tsi.Name = "Label1";
275 // tsi.Text = "Test Label";
276 // tsi.AccessibleDescription = "Label Desc";
278 // Assert.AreEqual ("Press", ao.DefaultAction, "L12");
279 // Assert.AreEqual ("Label Desc", ao.Description, "L13");
280 // Assert.AreEqual (null, ao.Help, "L14");
281 // Assert.AreEqual (null, ao.KeyboardShortcut, "L15");
282 // //Assert.AreEqual ("Test Label", ao.Name, "L16");
283 // Assert.AreEqual (AccessibleRole.PushButton, ao.Role, "L18");
284 // Assert.AreEqual (AccessibleStates.None, ao.State, "L19");
285 // Assert.AreEqual (null, ao.Value, "L20");
287 // tsi.AccessibleName = "Access Label";
288 // Assert.AreEqual ("Access Label", ao.Name, "L21");
290 // tsi.Text = "Test Label";
291 // Assert.AreEqual ("Access Label", ao.Name, "L22");
293 // tsi.AccessibleDefaultActionDescription = "AAA";
294 // Assert.AreEqual ("AAA", tsi.AccessibleDefaultActionDescription, "L23");
297 private class EventWatcher
299 private string events = string.Empty;
301 public EventWatcher (ToolStripProgressBar tsi)
303 //tsi.RightToLeftLayoutChanged += new EventHandler (delegate (Object obj, EventArgs e) { events += ("RightToLeftLayoutChanged;"); });
306 public override string ToString ()
308 return events.TrimEnd (';');
311 public void Clear ()
313 events = string.Empty;
317 private class ExposeProtectedProperties : ToolStripProgressBar
319 public ExposeProtectedProperties () : base () {}
321 public new Padding DefaultMargin { get { return base.DefaultMargin; } }
322 public new Size DefaultSize { get { return base.DefaultSize; } }
326 #endif