* PrintDialogTest.cs: Fixed DefaultValues test on 2.0 profile.
[mono.git] / mcs / class / Managed.Windows.Forms / Test / System.Windows.Forms / ToolStripTest.cs
1 //
2 // ToolStripTests.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.
22 //
23 // Copyright (c) 2006 Jonathan Pobst
24 //
25 // Authors:
26 //      Jonathan Pobst (monkey@jpobst.com)
27 //
28
29 #if NET_2_0
30 using System;
31 using System.Collections.Generic;
32 using System.ComponentModel;
33 using System.Drawing;
34 using System.Text;
35 using System.Windows.Forms;
36
37 using NUnit.Framework;
38
39 namespace MonoTests.System.Windows.Forms
40 {
41         [TestFixture]
42         public class ToolStripTests
43         {
44                 [Test]
45                 public void Constructor ()
46                 {
47                         ToolStrip ts = new ToolStrip ();
48
49                         Assert.AreEqual (false, ts.AllowDrop, "A1");
50                         //Assert.AreEqual (false, ts.AllowItemReorder, "A2");
51                         //Assert.AreEqual (true, ts.AllowMerge, "A3");
52                         Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, ts.Anchor, "A4");
53                         Assert.AreEqual (true, ts.AutoSize, "A5");
54                         Assert.AreEqual (SystemColors.Control, ts.BackColor, "A6");
55                         Assert.AreEqual (null, ts.BindingContext, "A7");
56                         //Assert.AreEqual (true, ts.CanOverflow, "A8");
57                         Assert.AreEqual (false, ts.CausesValidation, "A9");
58                         Assert.AreEqual (Cursors.Default, ts.Cursor, "A10");
59                         //Assert.AreEqual (ToolStripDropDownDirection.BelowRight, ts.DefaultDropDownDirection, "A11");
60                         Assert.AreEqual (new Rectangle (7, 0, 92, 25), ts.DisplayRectangle, "A12");
61                         Assert.AreEqual (DockStyle.Top, ts.Dock, "A13");
62                         Assert.AreEqual (new Font ("Tahoma", 8.25f), ts.Font, "A14");
63                         Assert.AreEqual (SystemColors.ControlText, ts.ForeColor, "A15");
64                         Assert.AreEqual (ToolStripGripDisplayStyle.Vertical, ts.GripDisplayStyle, "A16");
65                         Assert.AreEqual (new Padding (2), ts.GripMargin, "A17");
66                         Assert.AreEqual (new Rectangle (2, 0, 3, 25), ts.GripRectangle, "A18");
67                         Assert.AreEqual (ToolStripGripStyle.Visible, ts.GripStyle, "A19");
68                         Assert.AreEqual (null, ts.ImageList, "A20");
69                         Assert.AreEqual (new Size (16, 16), ts.ImageScalingSize, "A21");
70                         //Assert.AreEqual (false, ts.IsCurrentlyDragging, "A22");
71                         Assert.AreEqual (false, ts.IsDropDown, "A23");
72                         Assert.AreEqual ("System.Windows.Forms.ToolStripItemCollection", ts.Items.ToString (), "A24");
73                         Assert.AreEqual ("System.Windows.Forms.ToolStripSplitStackLayout", ts.LayoutEngine.ToString (), "A25");
74                         Assert.AreEqual (null, ts.LayoutSettings, "A26");
75                         Assert.AreEqual (ToolStripLayoutStyle.HorizontalStackWithOverflow, ts.LayoutStyle, "A27");
76                         Assert.AreEqual (Orientation.Horizontal, ts.Orientation, "A28");
77                         //Assert.AreEqual ("System.Windows.Forms.ToolStripOverflowButton", ts.OverflowButton.ToString (), "A29");
78                         Assert.AreEqual ("System.Windows.Forms.ToolStripProfessionalRenderer", ts.Renderer.ToString (), "A30");
79                         Assert.AreEqual (ToolStripRenderMode.ManagerRenderMode, ts.RenderMode, "A31");
80                         Assert.AreEqual (true, ts.ShowItemToolTips, "A32");
81                         Assert.AreEqual (false, ts.Stretch, "A33");
82                         Assert.AreEqual (false, ts.TabStop, "A34");
83                         //Assert.AreEqual (ToolStripTextDirection.Horizontal, ts.TextDirection, "A35");
84                         
85                         ts = new ToolStrip (new ToolStripButton (), new ToolStripSeparator (), new ToolStripButton ());
86                         Assert.AreEqual (3, ts.Items.Count, "A36");
87                 }
88
89                 [Test]
90                 public void ControlStyle ()
91                 {
92                         ExposeProtectedProperties epp = new ExposeProtectedProperties ();
93                 
94                         ControlStyles cs = ControlStyles.ContainerControl;
95                         cs |= ControlStyles.UserPaint;
96                         cs |= ControlStyles.StandardClick;
97                         cs |= ControlStyles.SupportsTransparentBackColor;
98                         cs |= ControlStyles.StandardDoubleClick;
99                         cs |= ControlStyles.AllPaintingInWmPaint;
100                         cs |= ControlStyles.OptimizedDoubleBuffer;
101                         cs |= ControlStyles.UseTextForAccessibility;
102
103                         Assert.AreEqual (cs, epp.GetControlStyles (), "Styles");
104                 }
105
106                 [Test] // bug #80762
107                 [NUnit.Framework.Category ("NotWorking")]
108                 public void DockSize ()
109                 {
110                         ToolStrip ts = new ToolStrip();
111                         Assert.AreEqual (new Size (100, 25), ts.Size, "#1");
112                         ts.Dock = DockStyle.None;
113                         Assert.AreEqual (new Size (100, 25), ts.Size, "#2");
114                 }
115
116                 [Test]
117                 public void ProtectedProperties ()
118                 {
119                         ExposeProtectedProperties epp = new ExposeProtectedProperties ();
120
121                         Assert.AreEqual (DockStyle.Top, epp.DefaultDock, "C1");
122                         Assert.AreEqual (new Padding (2), epp.DefaultGripMargin, "C2");
123                         Assert.AreEqual (new Padding (0), epp.DefaultMargin, "C3");
124                         Assert.AreEqual (new Padding (0,0,1,0), epp.DefaultPadding, "C4");
125                         Assert.AreEqual (true, epp.DefaultShowItemToolTips, "C5");
126                         Assert.AreEqual (new Size (100, 25), epp.DefaultSize, "C6");
127                         //Assert.AreEqual (new Size (92, 25), epp.MaxItemSize, "C7");
128                 }
129                 
130                 [Test]
131                 public void PropertyAllowDrop ()
132                 {
133                         ToolStrip ts = new ToolStrip ();
134                         EventWatcher ew = new EventWatcher (ts);
135                         
136                         ts.AllowDrop = true;
137                         Assert.AreEqual (true, ts.AllowDrop, "B1");
138                         Assert.AreEqual (string.Empty, ew.ToString (), "B2");
139                 }
140
141                 //[Test]        
142                 //public void PropertyAllowItemReorder ()
143                 //{
144                 //        ToolStrip ts = new ToolStrip ();
145                 //        EventWatcher ew = new EventWatcher (ts);
146
147                 //        ts.AllowItemReorder = true;
148                 //        Assert.AreEqual (true, ts.AllowItemReorder, "B1");
149                 //        Assert.AreEqual (string.Empty, ew.ToString (), "B2");
150                 //}
151
152                 //[Test]
153                 //[ExpectedException (typeof (ArgumentException))]
154                 //public void PropertyAllowDropAndAllowItemReorderAE ()
155                 //{
156                 //        ToolStrip ts = new ToolStrip ();
157                 //        EventWatcher ew = new EventWatcher (ts);
158
159                 //        ts.AllowDrop = true;
160                 //        ts.AllowItemReorder = true;
161                 //}
162
163                 //[Test]
164                 //[ExpectedException (typeof (ArgumentException))]
165                 //public void PropertyAllowDropAndAllowItemReorderAE2 ()
166                 //{
167                 //        ToolStrip ts = new ToolStrip ();
168                 //        EventWatcher ew = new EventWatcher (ts);
169
170                 //        ts.AllowItemReorder = true;
171                 //        ts.AllowDrop = true;
172                 //}
173
174                 //[Test]
175                 //public void PropertyAllowMerge ()
176                 //{
177                 //        ToolStrip ts = new ToolStrip ();
178                 //        EventWatcher ew = new EventWatcher (ts);
179
180                 //        ts.AllowMerge = false;
181                 //        Assert.AreEqual (false, ts.AllowMerge, "B1");
182                 //        Assert.AreEqual (string.Empty, ew.ToString (), "B2");
183                 //}
184
185                 [Test]
186                 public void PropertyAnchorAndDocking ()
187                 {
188                         ToolStrip ts = new ToolStrip ();
189
190                         ts.Anchor = AnchorStyles.Top | AnchorStyles.Bottom;
191
192                         Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Bottom, ts.Anchor, "A1");
193                         Assert.AreEqual (DockStyle.None, ts.Dock, "A2");
194                         Assert.AreEqual (Orientation.Horizontal, ts.Orientation, "A3");
195
196                         ts.Anchor = AnchorStyles.Left | AnchorStyles.Right;
197
198                         Assert.AreEqual (AnchorStyles.Left | AnchorStyles.Right, ts.Anchor, "A1");
199                         Assert.AreEqual (DockStyle.None, ts.Dock, "A2");
200                         Assert.AreEqual (Orientation.Horizontal, ts.Orientation, "A3");
201
202                         ts.Dock = DockStyle.Left;
203
204                         Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, ts.Anchor, "A1");
205                         Assert.AreEqual (DockStyle.Left, ts.Dock, "A2");
206                         Assert.AreEqual (Orientation.Vertical, ts.Orientation, "A3");
207
208                         ts.Dock = DockStyle.None;
209
210                         Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, ts.Anchor, "A1");
211                         Assert.AreEqual (DockStyle.None, ts.Dock, "A2");
212                         Assert.AreEqual (Orientation.Horizontal, ts.Orientation, "A3");
213
214                         ts.Dock = DockStyle.Top;
215
216                         Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, ts.Anchor, "A1");
217                         Assert.AreEqual (DockStyle.Top, ts.Dock, "A2");
218                         Assert.AreEqual (Orientation.Horizontal, ts.Orientation, "A3");
219                 }
220
221                 [Test]
222                 public void PropertyAutoSize ()
223                 {
224                         ToolStrip ts = new ToolStrip ();
225                         EventWatcher ew = new EventWatcher (ts);
226
227                         ts.AutoSize = false;
228                         Assert.AreEqual (false, ts.AutoSize, "B1");
229                         Assert.AreEqual ("AutoSizeChanged", ew.ToString (), "B2");
230                         
231                         ew.Clear ();
232                         ts.AutoSize = false;
233                         Assert.AreEqual (string.Empty, ew.ToString (), "B3");
234                 }
235
236                 [Test]
237                 public void PropertyBackColor ()
238                 {
239                         ToolStrip ts = new ToolStrip ();
240                         EventWatcher ew = new EventWatcher (ts);
241
242                         ts.BackColor = Color.BurlyWood;
243                         Assert.AreEqual (Color.BurlyWood, ts.BackColor, "B1");
244                         Assert.AreEqual (string.Empty, ew.ToString (), "B2");
245                 }
246
247                 [Test]
248                 public void PropertyBindingContext ()
249                 {
250                         ToolStrip ts = new ToolStrip ();
251                         EventWatcher ew = new EventWatcher (ts);
252
253                         BindingContext b = new BindingContext ();
254                         ts.BindingContext = b;
255                         Assert.AreSame (b, ts.BindingContext, "B1");
256                         Assert.AreEqual (string.Empty, ew.ToString (), "B2");
257                 }
258
259                 //[Test]
260                 //public void PropertyCanOverflow ()
261                 //{
262                 //        ToolStrip ts = new ToolStrip ();
263                 //        EventWatcher ew = new EventWatcher (ts);
264
265                 //        ts.CanOverflow = false;
266                 //        Assert.AreEqual (false, ts.CanOverflow, "B1");
267                 //        Assert.AreEqual (string.Empty, ew.ToString (), "B2");
268                 //}
269
270                 [Test]
271                 public void PropertyCausesValidation ()
272                 {
273                         ToolStrip ts = new ToolStrip ();
274                         EventWatcher ew = new EventWatcher (ts);
275
276                         ts.CausesValidation = true;
277                         Assert.AreEqual (true, ts.CausesValidation, "B1");
278                         Assert.AreEqual ("CausesValidationChanged", ew.ToString (), "B2");
279
280                         ew.Clear ();
281                         ts.CausesValidation = true;
282                         Assert.AreEqual (string.Empty, ew.ToString (), "B3");
283                 }
284
285                 [Test]
286                 public void PropertyCursor ()
287                 {
288                         ToolStrip ts = new ToolStrip ();
289                         EventWatcher ew = new EventWatcher (ts);
290
291                         ts.Cursor = Cursors.Cross;
292                         Assert.AreEqual (Cursors.Cross, ts.Cursor, "B1");
293                         Assert.AreEqual ("CursorChanged", ew.ToString (), "B2");
294
295                         ew.Clear ();
296                         ts.Cursor = Cursors.Cross;
297                         Assert.AreEqual (string.Empty, ew.ToString (), "B3");
298                 }
299
300                 //[Test]
301                 //public void PropertyDefaultDropDownDirection ()
302                 //{
303                 //        ToolStrip ts = new ToolStrip ();
304                 //        EventWatcher ew = new EventWatcher (ts);
305
306                 //        ts.DefaultDropDownDirection = ToolStripDropDownDirection.AboveLeft;
307                 //        Assert.AreEqual (ToolStripDropDownDirection.AboveLeft, ts.DefaultDropDownDirection, "B1");
308                 //        Assert.AreEqual (string.Empty, ew.ToString (), "B2");
309                 //}
310
311                 //[Test]
312                 //[ExpectedException (typeof (InvalidEnumArgumentException))]
313                 //public void PropertyDefaultDropDownDirectionIEAE ()
314                 //{
315                 //        ToolStrip ts = new ToolStrip ();
316                 //        EventWatcher ew = new EventWatcher (ts);
317
318                 //        ts.DefaultDropDownDirection = (ToolStripDropDownDirection) 42;
319                 //}
320
321                 [Test]
322                 [ExpectedException (typeof (InvalidEnumArgumentException))]
323                 public void PropertyDockIEAE ()
324                 {
325                         ToolStrip ts = new ToolStrip ();
326                         ts.Dock = (DockStyle)42;
327                 }
328
329                 [Test]
330                 public void PropertyFont ()
331                 {
332                         ToolStrip ts = new ToolStrip ();
333                         EventWatcher ew = new EventWatcher (ts);
334
335                         Font f = new Font ("Arial", 12);
336                         
337                         ts.Font = f;
338                         Assert.AreSame (f, ts.Font, "B1");
339                         Assert.AreEqual ("LayoutCompleted", ew.ToString (), "B2");
340
341                         ew.Clear ();
342                         ts.Font = f;
343                         Assert.AreEqual (string.Empty, ew.ToString (), "B3");
344                 }
345
346                 [Test]
347                 public void PropertyForeColor ()
348                 {
349                         ToolStrip ts = new ToolStrip ();
350                         EventWatcher ew = new EventWatcher (ts);
351
352                         ts.ForeColor = Color.BurlyWood;
353                         Assert.AreEqual (Color.BurlyWood, ts.ForeColor, "B1");
354                         Assert.AreEqual ("ForeColorChanged", ew.ToString (), "B2");
355
356                         ew.Clear ();
357                         ts.ForeColor = Color.BurlyWood;
358                         Assert.AreEqual (string.Empty, ew.ToString (), "B3");
359                 }
360
361                 [Test]
362                 public void PropertyGripMargin ()
363                 {
364                         ToolStrip ts = new ToolStrip ();
365                         EventWatcher ew = new EventWatcher (ts);
366
367                         ts.GripMargin = new Padding (6);
368                         Assert.AreEqual (new Padding (6), ts.GripMargin, "B1");
369                         Assert.AreEqual ("LayoutCompleted", ew.ToString (), "B2");
370
371                         ew.Clear ();
372                         ts.GripMargin = new Padding (6);
373                         Assert.AreEqual (string.Empty, ew.ToString (), "B3");
374                 }
375
376                 [Test]
377                 public void PropertyGripStyle ()
378                 {
379                         ToolStrip ts = new ToolStrip ();
380                         EventWatcher ew = new EventWatcher (ts);
381
382                         ts.GripStyle = ToolStripGripStyle.Hidden;
383                         Assert.AreEqual (ToolStripGripStyle.Hidden, ts.GripStyle, "B1");
384                         Assert.AreEqual ("LayoutCompleted", ew.ToString (), "B2");
385
386                         ew.Clear ();
387                         ts.GripStyle = ToolStripGripStyle.Hidden;
388                         Assert.AreEqual (string.Empty, ew.ToString (), "B3");
389                 }
390
391                 [Test]
392                 [ExpectedException (typeof (InvalidEnumArgumentException))]
393                 public void PropertyGripStyleIEAE ()
394                 {
395                         ToolStrip ts = new ToolStrip ();
396
397                         ts.GripStyle = (ToolStripGripStyle) 42;
398                 }
399
400                 [Test]
401                 public void PropertyImageList ()
402                 {
403                         ToolStrip ts = new ToolStrip ();
404                         EventWatcher ew = new EventWatcher (ts);
405
406                         ImageList il = new ImageList ();
407
408                         ts.ImageList = il;
409                         Assert.AreSame (il, ts.ImageList, "B1");
410                         Assert.AreEqual (string.Empty, ew.ToString (), "B2");
411                 }
412
413                 [Test]
414                 public void PropertyImageScalingSize ()
415                 {
416                         ToolStrip ts = new ToolStrip ();
417                         EventWatcher ew = new EventWatcher (ts);
418
419                         ts.ImageScalingSize = new Size (32, 32);
420                         Assert.AreEqual (new Size (32, 32), ts.ImageScalingSize, "B1");
421                         Assert.AreEqual (string.Empty, ew.ToString (), "B2");
422                 }
423
424                 [Test]
425                 public void PropertyLayoutStyle ()
426                 {
427                         ToolStrip ts = new ToolStrip ();
428                         EventWatcher ew = new EventWatcher (ts);
429
430                         ts.LayoutStyle = ToolStripLayoutStyle.VerticalStackWithOverflow;
431                         Assert.AreEqual (ToolStripLayoutStyle.VerticalStackWithOverflow, ts.LayoutStyle, "B1");
432                         Assert.AreEqual ("LayoutCompleted;LayoutStyleChanged", ew.ToString (), "B2");
433
434                         ew.Clear ();
435                         ts.LayoutStyle = ToolStripLayoutStyle.VerticalStackWithOverflow;
436                         Assert.AreEqual (string.Empty, ew.ToString (), "B3");
437                 }
438
439                 [Test]
440                 [ExpectedException (typeof (InvalidEnumArgumentException))]
441                 public void PropertyLayoutStyleIEAE ()
442                 {
443                         ToolStrip ts = new ToolStrip ();
444
445                         ts.LayoutStyle = (ToolStripLayoutStyle) 42;
446                 }
447
448                 [Test]
449                 public void PropertyRenderer ()
450                 {
451                         ToolStrip ts = new ToolStrip ();
452                         EventWatcher ew = new EventWatcher (ts);
453
454                         ToolStripProfessionalRenderer pr = new ToolStripProfessionalRenderer ();
455
456                         ts.Renderer = pr;
457                         Assert.AreSame (pr, ts.Renderer, "B1");
458                         Assert.AreEqual ("LayoutCompleted;RendererChanged", ew.ToString (), "B2");
459                         Assert.AreEqual (ToolStripRenderMode.Custom, ts.RenderMode, "B4");
460                         
461                         ew.Clear ();
462                         ts.Renderer = pr;
463                         Assert.AreEqual (string.Empty, ew.ToString (), "B3");
464                 }
465
466                 [Test]
467                 public void PropertyRenderMode ()
468                 {
469                         ToolStrip ts = new ToolStrip ();
470                         EventWatcher ew = new EventWatcher (ts);
471
472                         ts.RenderMode = ToolStripRenderMode.System;
473                         Assert.AreEqual (ToolStripRenderMode.System, ts.RenderMode, "B1");
474                         Assert.AreEqual ("LayoutCompleted;RendererChanged", ew.ToString (), "B2");
475
476                         ew.Clear ();
477                         ts.RenderMode = ToolStripRenderMode.System;
478                         Assert.AreEqual ("LayoutCompleted;RendererChanged", ew.ToString (), "B3");
479                 }
480
481                 [Test]
482                 [ExpectedException (typeof (NotSupportedException))]
483                 public void PropertyRenderModeNSE ()
484                 {
485                         ToolStrip ts = new ToolStrip ();
486
487                         ts.RenderMode = ToolStripRenderMode.Custom;
488                 }
489
490                 [Test]
491                 [ExpectedException (typeof (InvalidEnumArgumentException))]
492                 public void PropertyRenderModeIEAE ()
493                 {
494                         ToolStrip ts = new ToolStrip ();
495
496                         ts.RenderMode = (ToolStripRenderMode) 42;
497                 }
498
499                 [Test]
500                 public void PropertyShowItemToolTips ()
501                 {
502                         ToolStrip ts = new ToolStrip ();
503                         EventWatcher ew = new EventWatcher (ts);
504
505                         ts.ShowItemToolTips = false;
506                         Assert.AreEqual (false, ts.ShowItemToolTips, "B1");
507                         Assert.AreEqual (string.Empty, ew.ToString (), "B2");
508                 }
509
510                 [Test]
511                 public void PropertyStretch ()
512                 {
513                         ToolStrip ts = new ToolStrip ();
514                         EventWatcher ew = new EventWatcher (ts);
515
516                         ts.Stretch = true;
517                         Assert.AreEqual (true, ts.Stretch, "B1");
518                         Assert.AreEqual (string.Empty, ew.ToString (), "B2");
519                 }
520
521                 [Test]
522                 public void PropertyTabStop ()
523                 {
524                         ToolStrip ts = new ToolStrip ();
525                         EventWatcher ew = new EventWatcher (ts);
526
527                         ts.TabStop = true;
528                         Assert.AreEqual (true, ts.TabStop, "B1");
529                         Assert.AreEqual (string.Empty, ew.ToString (), "B2");
530                 }
531
532                 //[Test]
533                 //public void PropertyTextDirection ()
534                 //{
535                 //        ToolStrip ts = new ToolStrip ();
536                 //        EventWatcher ew = new EventWatcher (ts);
537
538                 //        ts.TextDirection = ToolStripTextDirection.Vertical270;
539                 //        Assert.AreEqual (ToolStripTextDirection.Vertical270, ts.TextDirection, "B1");
540                 //        Assert.AreEqual ("LayoutCompleted", ew.ToString (), "B2");
541
542                 //        ew.Clear ();
543                 //        ts.TextDirection = ToolStripTextDirection.Vertical270;
544                 //        Assert.AreEqual ("LayoutCompleted", ew.ToString (), "B3");
545                 //}
546
547                 //[Test]
548                 //[ExpectedException (typeof (InvalidEnumArgumentException))]
549                 //public void PropertyTextDirectionIEAE ()
550                 //{
551                 //        ToolStrip ts = new ToolStrip ();
552                 //        EventWatcher ew = new EventWatcher (ts);
553
554                 //        ts.TextDirection = (ToolStripTextDirection) 42;
555                 //}
556
557                 [Test]
558                 public void TestToolStrip ()
559                 {
560                         ToolStrip ts = new ToolStrip ();
561
562                         ts.Items.Add (new ToolStripButton ());
563                         Assert.AreEqual (new Rectangle (0, 0, 100, 25), ts.Bounds, "D1");
564                         Assert.AreEqual (new Rectangle (7, 0, 92, 25), ts.DisplayRectangle, "D2");
565                         Assert.AreEqual (new Rectangle (2, 0, 3, 25), ts.GripRectangle, "D4");
566                         Assert.AreEqual (new Padding (2), ts.GripMargin, "D5");
567
568                         ts.GripStyle = ToolStripGripStyle.Hidden;
569
570                         Assert.AreEqual (new Rectangle (0, 0, 0, 0), ts.GripRectangle, "D8");
571                         Assert.AreEqual (new Rectangle (0, 0, 99, 25), ts.DisplayRectangle, "D3");
572                         Assert.AreEqual (new Padding (2), ts.GripMargin, "D5");
573
574                         ts.BackColor = Color.Aquamarine;
575                         Assert.AreEqual (Color.Aquamarine, ts.BackColor, "A2");
576
577                         ts.ForeColor = Color.LightSalmon;
578                         Assert.AreEqual (Color.LightSalmon, ts.ForeColor, "A5");
579
580                         ts.GripMargin = new Padding (3);
581                         Assert.AreEqual (new Padding (3), ts.GripMargin, "A7");
582                 }
583                 
584                 [Test]
585                 [Ignore ("Accessibility still needs some work")]
586                 public void Accessibility ()
587                 {
588                         ToolStrip ts = new ToolStrip ();
589                         AccessibleObject ao = ts.AccessibilityObject;
590
591                         Assert.AreEqual ("ControlAccessibleObject: Owner = " + ts.ToString (), ao.ToString (), "L");
592                         //Assert.AreEqual (Rectangle.Empty, ao.Bounds, "L1");
593                         Assert.AreEqual (null, ao.DefaultAction, "L2");
594                         Assert.AreEqual (null, ao.Description, "L3");
595                         Assert.AreEqual (null, ao.Help, "L4");
596                         Assert.AreEqual (null, ao.KeyboardShortcut, "L5");
597                         Assert.AreEqual (null, ao.Name, "L6");
598                         //Assert.AreEqual (null, ao.Parent, "L7");
599                         Assert.AreEqual (AccessibleRole.ToolBar, ao.Role, "L8");
600                         Assert.AreEqual (AccessibleStates.None, ao.State, "L9");
601                         Assert.AreEqual (null, ao.Value, "L10");
602
603                         ts.Name = "Label1";
604                         ts.Text = "Test Label";
605                         ts.AccessibleDescription = "Label Desc";
606
607                         //Assert.AreEqual (Rectangle.Empty, ao.Bounds, "L11");
608                         Assert.AreEqual (null, ao.DefaultAction, "L12");
609                         Assert.AreEqual ("Label Desc", ao.Description, "L13");
610                         Assert.AreEqual (null, ao.Help, "L14");
611                         Assert.AreEqual (null, ao.KeyboardShortcut, "L15");
612                         //Assert.AreEqual ("Test Label", ao.Name, "L16");
613                         //Assert.AreEqual (null, ao.Parent, "L17");
614                         Assert.AreEqual (AccessibleRole.ToolBar, ao.Role, "L18");
615                         Assert.AreEqual (AccessibleStates.None, ao.State, "L19");
616                         Assert.AreEqual (null, ao.Value, "L20");
617
618                         ts.AccessibleName = "Access Label";
619                         Assert.AreEqual ("Access Label", ao.Name, "L21");
620
621                         ts.Text = "Test Label";
622                         Assert.AreEqual ("Access Label", ao.Name, "L22");
623
624                         ts.AccessibleDefaultActionDescription = "AAA";
625                         Assert.AreEqual ("AAA", ts.AccessibleDefaultActionDescription, "L23");
626                 }
627                 
628                 private class EventWatcher
629                 {
630                         private string events = string.Empty;
631                         
632                         public EventWatcher (ToolStrip ts)
633                         {
634                                 ts.AutoSizeChanged += new EventHandler (delegate (Object obj, EventArgs e) { events += ("AutoSizeChanged;"); });
635                                 //ts.BeginDrag += new EventHandler (delegate (Object obj, EventArgs e) { events += ("BeginDrag;"); });
636                                 ts.CausesValidationChanged += new EventHandler (delegate (Object obj, EventArgs e) { events += ("CausesValidationChanged;"); });
637                                 ts.CursorChanged += new EventHandler (delegate (Object obj, EventArgs e) { events += ("CursorChanged;"); });
638                                 //ts.EndDrag += new EventHandler (delegate (Object obj, EventArgs e) { events += ("EndDrag;"); });
639                                 ts.ForeColorChanged += new EventHandler (delegate (Object obj, EventArgs e) { events += ("ForeColorChanged;"); });
640                                 ts.ItemAdded += new ToolStripItemEventHandler (delegate (Object obj, ToolStripItemEventArgs e) { events += ("ItemAdded;"); });
641                                 ts.ItemClicked += new ToolStripItemClickedEventHandler (delegate (Object obj, ToolStripItemClickedEventArgs e) { events += ("ItemClicked;"); });
642                                 ts.ItemRemoved += new ToolStripItemEventHandler (delegate (Object obj, ToolStripItemEventArgs e) { events += ("ItemRemoved;"); });
643                                 ts.LayoutCompleted += new EventHandler (delegate (Object obj, EventArgs e) { events += ("LayoutCompleted;"); });
644                                 ts.LayoutStyleChanged += new EventHandler (delegate (Object obj, EventArgs e) { events += ("LayoutStyleChanged;"); });
645                                 ts.PaintGrip += new PaintEventHandler (delegate (Object obj, PaintEventArgs e) { events += ("PaintGrip;"); });
646                                 ts.RendererChanged += new EventHandler (delegate (Object obj, EventArgs e) { events += ("RendererChanged;"); });
647                         }
648
649                         public override string ToString ()
650                         {
651                                 return events.TrimEnd (';');
652                         }
653                         
654                         public void Clear ()
655                         {
656                                 events = string.Empty;
657                         }
658                 }
659                 
660                 private class ExposeProtectedProperties : ToolStrip
661                 {
662                         public new DockStyle DefaultDock { get { return base.DefaultDock; } }
663                         public new Padding DefaultGripMargin { get { return base.DefaultGripMargin; } }
664                         public new Padding DefaultMargin { get { return base.DefaultMargin; } }
665                         public new Padding DefaultPadding { get { return base.DefaultPadding; } }
666                         public new bool DefaultShowItemToolTips { get { return base.DefaultShowItemToolTips; } }
667                         public new Size DefaultSize { get { return base.DefaultSize; } }
668                         //public new Size MaxItemSize { get { return base.MaxItemSize; } }
669                         
670                         public ControlStyles GetControlStyles ()
671                         {
672                                 ControlStyles retval = (ControlStyles) 0;
673                                 
674                                 foreach (ControlStyles cs in Enum.GetValues (typeof (ControlStyles)))
675                                         if (this.GetStyle (cs) == true)
676                                                 retval |= cs;
677                                                 
678                                 return retval;
679                         }
680                 }
681         }
682 }
683 #endif