2007-09-11 Jonathan Pobst <monkey@jpobst.com>
[mono.git] / mcs / class / Managed.Windows.Forms / Test / System.Windows.Forms / DefaultLayoutTest.cs
1 using System;
2 using System.Drawing;
3 using System.Windows.Forms;
4
5 using NUnit.Framework;
6
7 namespace MonoTests.System.Windows.Forms
8 {
9         [TestFixture]
10         public class DefaultLayoutTest
11         {
12                 int event_count;
13                 LayoutEventArgs most_recent_args;
14
15                 void p_Layout (object sender, LayoutEventArgs e)
16                 {
17                         event_count ++;
18                         most_recent_args = e;
19                 }
20
21                 [Test]
22                 public void AnchorLayoutEvents ()
23                 {
24                         Panel p;
25                         Button b;
26
27                         p = new Panel ();
28
29                         b = new Button ();
30                         p.Controls.Add (b);
31
32                         p.Layout += new LayoutEventHandler (p_Layout);
33
34                         /* set the button's anchor to something different */
35                         b.Anchor = AnchorStyles.Bottom;
36                         Assert.AreEqual (1, event_count, "1");
37                         Assert.AreEqual ("Anchor", most_recent_args.AffectedProperty, "2");
38
39                         /* reset it to something new with the panel's layout suspended */
40                         event_count = 0;
41                         p.SuspendLayout ();
42                         b.Anchor = AnchorStyles.Top;
43                         Assert.AreEqual (0, event_count, "3");
44                         p.ResumeLayout ();
45                         Assert.AreEqual (1, event_count, "4");
46                         Assert.AreEqual (null, most_recent_args.AffectedProperty, "5");
47
48                         /* with the anchor style set to something, resize the parent */
49                         event_count = 0;
50                         p.Size = new Size (500, 500);
51                         Assert.AreEqual (1, event_count, "6");
52                         Assert.AreEqual ("Bounds", most_recent_args.AffectedProperty, "7");
53
54                         /* now try it with layout suspended */
55                         event_count = 0;
56                         p.SuspendLayout ();
57                         p.Size = new Size (400, 400);
58                         Assert.AreEqual (0, event_count, "8");
59                         p.ResumeLayout ();
60                         Assert.AreEqual (1, event_count, "9");
61                         Assert.AreEqual (null, most_recent_args.AffectedProperty, "10");
62
63                         /* with the anchor style set to something, resize the child */
64                         event_count = 0;
65                         b.Size = new Size (100, 100);
66                         Assert.AreEqual (1, event_count, "11");
67                         Assert.AreEqual ("Bounds", most_recent_args.AffectedProperty, "12");
68
69                         /* and again with layout suspended */
70                         event_count = 0;
71                         p.SuspendLayout ();
72                         b.Size = new Size (200, 200);
73                         Assert.AreEqual (0, event_count, "13");
74                         p.ResumeLayout ();
75                         Assert.AreEqual (1, event_count, "14");
76                         Assert.AreEqual (null, most_recent_args.AffectedProperty, "15");
77                 }
78
79                 [Test]
80                 public void AnchorTopLeftTest ()
81                 {
82                         Form f = new Form ();
83                         f.ShowInTaskbar = false;
84
85                         f.Size = new Size (200, 200);
86
87                         Button b = new Button ();
88                         b.Size = new Size (100, 100);
89                         b.Anchor = AnchorStyles.Top | AnchorStyles.Left;
90
91                         f.Controls.Add (b);
92
93                         Assert.AreEqual (0, b.Left, "1");
94                         Assert.AreEqual (0, b.Top, "2");
95                         f.Size = new Size (300, 300);
96
97                         Assert.AreEqual (0, b.Left, "3");
98                         Assert.AreEqual (0, b.Top, "4");
99                         
100                         f.Dispose ();
101                 }
102
103                 [Test]
104                 public void AnchorTopRightTest ()
105                 {
106                         Form f = new Form ();
107                         f.ShowInTaskbar = false;
108
109                         f.Size = new Size (200, 200);
110
111                         Button b = new Button ();
112                         b.Size = new Size (100, 100);
113                         b.Anchor = AnchorStyles.Top | AnchorStyles.Right;
114
115                         f.Controls.Add (b);
116
117                         Assert.AreEqual (0, b.Left, "1");
118                         Assert.AreEqual (0, b.Top, "2");
119
120                         f.Size = new Size (300, 300);
121
122                         Assert.AreEqual (100, b.Left, "3");
123                         Assert.AreEqual (0, b.Top, "4");
124                         
125                         f.Dispose ();
126                 }
127
128                 [Test]
129                 public void AnchorLeftRightTest ()
130                 {
131                         Form f = new Form ();
132                         f.ShowInTaskbar = false;
133
134                         f.Size = new Size (200, 200);
135
136                         Button b = new Button ();
137                         b.Size = new Size (100, 100);
138                         b.Anchor = AnchorStyles.Left | AnchorStyles.Right;
139
140                         f.Controls.Add (b);
141
142                         Assert.AreEqual (0, b.Left, "1");
143                         Assert.AreEqual (100, b.Right, "2");
144
145                         f.Size = new Size (300, 300);
146
147                         Assert.AreEqual (0, b.Left, "3");
148                         Assert.AreEqual (200, b.Right, "4");
149                         
150                         f.Dispose ();
151                 }
152
153                 [Test]
154                 public void AnchorBottomLeftTest ()
155                 {
156                         Form f = new Form ();
157                         f.ShowInTaskbar = false;
158
159                         f.Size = new Size (200, 200);
160
161                         Button b = new Button ();
162                         b.Size = new Size (100, 100);
163                         b.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
164
165                         f.Controls.Add (b);
166
167                         Assert.AreEqual (0, b.Left, "1");
168                         Assert.AreEqual (0, b.Top, "2");
169
170                         f.Size = new Size (300, 300);
171
172                         Assert.AreEqual (0, b.Left, "3");
173                         Assert.AreEqual (100, b.Top, "4");
174                         
175                         f.Dispose ();
176                 }
177
178                 [Test]
179                 public void AnchorBottomRightTest ()
180                 {
181                         Form f = new Form ();
182                         f.ShowInTaskbar = false;
183
184                         f.Size = new Size (200, 200);
185
186                         Button b = new Button ();
187                         b.Size = new Size (100, 100);
188                         b.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
189
190                         f.Controls.Add (b);
191
192                         Assert.AreEqual (0, b.Left, "1");
193                         Assert.AreEqual (0, b.Top, "2");
194
195                         f.Size = new Size (300, 300);
196
197                         Assert.AreEqual (100, b.Left, "3");
198                         Assert.AreEqual (100, b.Top, "4");
199                         
200                         f.Dispose ();
201                 }
202
203                 [Test]
204                 public void AnchorTopBottomTest ()
205                 {
206                         Form f = new Form ();
207                         f.ShowInTaskbar = false;
208
209                         f.Size = new Size (200, 200);
210
211                         Button b = new Button ();
212                         b.Size = new Size (100, 100);
213                         b.Anchor = AnchorStyles.Top | AnchorStyles.Bottom;
214
215                         f.Controls.Add (b);
216
217                         Assert.AreEqual (0, b.Top, "1");
218                         Assert.AreEqual (100, b.Bottom, "2");
219
220                         f.Size = new Size (300, 300);
221
222                         Assert.AreEqual (0, b.Top, "3");
223                         Assert.AreEqual (200, b.Bottom, "4");
224                         
225                         f.Dispose ();
226                 }
227
228                 // Unit test version of the test case in bug #80336
229                 [Test]
230                 public void AnchorSuspendLayoutTest ()
231                 {
232                         Form f = new Form ();
233                         f.ShowInTaskbar = false;
234
235                         f.SuspendLayout ();
236
237                         Button b = new Button ();
238                         b.Size = new Size (100, 100);
239
240                         f.Controls.Add (b);
241
242                         f.Size = new Size (200, 200);
243
244                         b.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
245
246                         Assert.AreEqual (0, b.Top, "1");
247                         Assert.AreEqual (0, b.Left, "2");
248
249                         f.Size = new Size (300, 300);
250
251                         Assert.AreEqual (0, b.Top, "3");
252                         Assert.AreEqual (0, b.Left, "4");
253
254                         f.ResumeLayout();
255
256                         Assert.AreEqual (100, b.Top, "5");
257                         Assert.AreEqual (100, b.Left, "6");
258                         
259                         f.Dispose ();
260                 }
261
262                 // another variant of AnchorSuspendLayoutTest1, with
263                 // the SuspendLayout moved after the Anchor
264                 // assignment.
265                 [Test]
266                 public void AnchorSuspendLayoutTest2 ()
267                 {
268                         Form f = new Form ();
269                         f.ShowInTaskbar = false;
270
271                         Button b = new Button ();
272                         b.Size = new Size (100, 100);
273
274                         f.Controls.Add (b);
275
276                         f.Size = new Size (200, 200);
277
278                         b.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
279
280                         Assert.AreEqual (0, b.Top, "1");
281                         Assert.AreEqual (0, b.Left, "2");
282
283                         f.SuspendLayout ();
284
285                         f.Size = new Size (300, 300);
286
287                         Assert.AreEqual (0, b.Top, "3");
288                         Assert.AreEqual (0, b.Left, "4");
289
290                         f.ResumeLayout();
291
292                         Assert.AreEqual (100, b.Top, "5");
293                         Assert.AreEqual (100, b.Left, "6");
294                         
295                         f.Dispose ();
296                 }
297
298                 // yet another variant, this time with no Suspend/Resume.
299                 [Test]
300                 public void AnchorSuspendLayoutTest3 ()
301                 {
302                         Form f = new Form ();
303                         f.ShowInTaskbar = false;
304
305                         Button b = new Button ();
306                         b.Size = new Size (100, 100);
307
308                         f.Controls.Add (b);
309
310                         f.Size = new Size (200, 200);
311
312                         b.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
313
314                         Assert.AreEqual (0, b.Top, "1");
315                         Assert.AreEqual (0, b.Left, "2");
316
317                         f.Size = new Size (300, 300);
318
319                         Assert.AreEqual (100, b.Top, "5");
320                         Assert.AreEqual (100, b.Left, "6");
321                         
322                         f.Dispose ();
323                 }
324
325                 private string event_raised = string.Empty;
326
327                 [Test]
328                 public void TestAnchorDockInteraction ()
329                 {
330                         Panel p = new Panel ();
331                         p.DockChanged += new EventHandler (DockChanged_Handler);
332
333                         Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, p.Anchor, "A1");
334                         Assert.AreEqual (DockStyle.None, p.Dock, "A2");
335
336                         p.Dock = DockStyle.Right;
337                         Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, p.Anchor, "A3");
338                         Assert.AreEqual (DockStyle.Right, p.Dock, "A4");
339                         Assert.AreEqual ("DockStyleChanged", event_raised, "A5");
340                         event_raised = string.Empty;
341
342                         p.Anchor = AnchorStyles.Bottom;
343                         Assert.AreEqual (AnchorStyles.Bottom, p.Anchor, "A6");
344                         Assert.AreEqual (DockStyle.None, p.Dock, "A7");
345                         Assert.AreEqual (string.Empty, event_raised, "A8");
346
347                         p.Dock = DockStyle.Fill;
348                         Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, p.Anchor, "A9");
349                         Assert.AreEqual (DockStyle.Fill, p.Dock, "A10");
350                         Assert.AreEqual ("DockStyleChanged", event_raised, "A11");
351                         event_raised = string.Empty;
352
353                         p.Anchor = AnchorStyles.Top | AnchorStyles.Left;
354                         Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, p.Anchor, "A12");
355                         Assert.AreEqual (DockStyle.Fill, p.Dock, "A13");
356                         Assert.AreEqual (string.Empty, event_raised, "A14");
357
358                         p.Dock = DockStyle.None;
359                         Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, p.Anchor, "A15");
360                         Assert.AreEqual (DockStyle.None, p.Dock, "A16");
361                         Assert.AreEqual ("DockStyleChanged", event_raised, "A17");
362                         event_raised = string.Empty;
363
364                         p.Anchor = AnchorStyles.Bottom;
365                         p.Dock = DockStyle.None;
366                         Assert.AreEqual (AnchorStyles.Bottom, p.Anchor, "A18");
367                         Assert.AreEqual (DockStyle.None, p.Dock, "A19");
368                         Assert.AreEqual (string.Empty, event_raised, "A20");
369                 }
370
371                 public void DockChanged_Handler (object sender, EventArgs e)
372                 {
373                         event_raised += "DockStyleChanged";
374                 }
375
376                 [Test]  // bug #80917
377                 [Category ("NotWorking")]
378                 public void BehaviorOverriddenDisplayRectangle ()
379                 {
380                         Control c = new Control ();
381                         c.Anchor |= AnchorStyles.Bottom;
382                         c.Size = new Size (100, 100);
383
384                         Form f = new DisplayRectangleForm ();
385                         f.Controls.Add (c);
386                         f.ShowInTaskbar = false;
387                         f.Show ();
388                         
389                         Assert.AreEqual (new Size (100, 100), c.Size, "A1");
390                         
391                         f.Dispose ();
392                 }
393
394                 private class DisplayRectangleForm : Form
395                 {
396                         public override Rectangle DisplayRectangle
397                         {
398                                 get { return Rectangle.Empty; }
399                         }
400                 }
401                 
402                 [Test]  // bug 80912
403                 public void AnchoredControlWithZeroWidthAndHeight ()
404                 {
405                         Form f = new Form ();
406                         f.ShowInTaskbar = false;
407                         
408                         Control c = new Control ();
409                         c.Anchor = AnchorStyles.Left | AnchorStyles.Right;
410                         f.Controls.Add (c);
411
412                         Assert.AreEqual (new Rectangle (0, 0, 0, 0), c.Bounds, "N1");
413                 }
414
415                 [Test] // bug 81694
416                 public void TestNestedControls ()
417                 {
418                         MainForm f = new MainForm ();
419                         f.ShowInTaskbar = false;
420                         
421                         f.Show ();
422                         Assert.AreEqual (new Rectangle (210, 212, 75, 23), f._userControl._button2.Bounds, "K1");
423                         
424                         f.Dispose ();
425                 }
426
427                 [Test] // bug 81695
428                 public void TestNestedControls2 ()
429                 {
430                         MainForm f = new MainForm ();
431                         f.ShowInTaskbar = false;
432
433                         f.Show ();
434                         
435                         Size s = f.Size;
436                         f.Size = new Size (10, 10);
437                         f.Size = s;
438                         
439                         Assert.AreEqual (new Rectangle (210, 212, 75, 23), f._userControl._button2.Bounds, "K1");
440
441                         f.Dispose ();
442                 }
443
444                 private class MainForm : Form
445                 {
446                         public UserControl1 _userControl;
447                         
448                         public MainForm ()
449                         {
450                                 SuspendLayout ();
451                                 // 
452                                 // _userControl
453                                 // 
454                                 _userControl = new UserControl1 ();
455                                 _userControl.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right);
456                                 _userControl.BackColor = Color.White;
457                                 _userControl.Location = new Point (8, 8);
458                                 _userControl.Size = new Size (288, 238);
459                                 _userControl.TabIndex = 0;
460                                 Controls.Add (_userControl);
461                                 // 
462                                 // MainForm
463                                 // 
464                                 ClientSize = new Size (304, 280);
465                                 Location = new Point (250, 100);
466                                 StartPosition = FormStartPosition.Manual;
467                                 Text = "bug #81694";
468                                 ResumeLayout (false);
469                         }
470                 }
471                 
472                 private class UserControl1 : UserControl
473                 {
474                         private Button _button1;
475                         public Button _button2;
476
477                         public UserControl1 ()
478                         {
479                                 SuspendLayout ();
480                                 // 
481                                 // _button1
482                                 // 
483                                 _button1 = new Button ();
484                                 _button1.Location = new Point (4, 4);
485                                 _button1.Size = new Size (75, 23);
486                                 _button1.TabIndex = 0;
487                                 _button1.Text = "Button1";
488                                 Controls.Add (_button1);
489                                 // 
490                                 // _button2
491                                 // 
492                                 _button2 = new Button ();
493                                 _button2.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
494                                 _button2.Location = new Point (210, 212);
495                                 _button2.Size = new Size (75, 23);
496                                 _button2.TabIndex = 1;
497                                 _button2.Text = "Button2";
498                                 Controls.Add (_button2);
499                                 // 
500                                 // UserControl1
501                                 // 
502                                 BackColor = Color.White;
503                                 ClientSize = new Size (288, 238);
504                                 ResumeLayout (false);
505                         }
506                 }
507
508 #if NET_2_0
509                 [Test]
510                 public void TestDockFillWithPadding ()
511                 {
512                         Form f = new Form ();
513                         f.ShowInTaskbar = false;
514                         f.Padding = new Padding (15, 15, 15, 15);
515
516                         Control c = new Control ();
517                         c.Dock = DockStyle.Fill;
518                         f.Controls.Add (c);
519
520                         f.Show ();
521                         Assert.AreEqual (new Size (f.ClientSize.Width - 30, f.ClientSize.Height - 30), c.Size, "K1");
522
523                         f.Dispose ();
524                 }
525 #endif
526
527                 [Test]
528                 public void Bug82762 ()
529                 {
530                         if (TestHelper.RunningOnUnix)
531                                 Assert.Ignore ("WM Size dependent");
532                                 
533                         Form f = new Form ();
534                         f.ShowInTaskbar = false;
535                         
536                         Button b = new Button ();
537                         b.Size = new Size (100, 100);
538                         b.Anchor = AnchorStyles.None;
539                         f.Controls.Add (b);
540                         
541                         f.Show ();
542                         
543                         Assert.AreEqual (new Rectangle (0, 0, 100, 100), b.Bounds, "A1");
544                         
545                         f.ClientSize = new Size (600, 600);
546
547                         Assert.AreEqual (new Rectangle (158, 168, 100, 100), b.Bounds, "A2");
548
549                         f.Close ();
550                         f.Dispose ();
551                 }
552                 
553                 [Test]
554                 public void Bug82805 ()
555                 {
556                         Control c1 = new Control ();
557                         c1.Size = new Size (100, 100);
558                         Control c2 = new Control ();
559                         c2.Size = new Size (100, 100);
560
561                         c2.SuspendLayout ();
562                         c1.Anchor = AnchorStyles.Left | AnchorStyles.Right;
563                         c2.Controls.Add (c1);
564                         c2.Size = new Size (200, 200);
565                         c2.ResumeLayout ();
566
567                         Assert.AreEqual (200, c1.Width, "A1");
568                 }
569                 
570                 [Test]  // bug #81199
571                 public void NestedControls ()
572                 {
573                         Form f = new Form ();
574                         f.ShowInTaskbar = false;
575                         
576                         MyUserControl c = new MyUserControl ();
577                         c.Dock = DockStyle.Fill;
578                         c.Size = new Size (500, 500);
579                         
580                         f.SuspendLayout ();
581                         f.Controls.Add (c);
582                         f.ClientSize = new Size (500, 500);
583                         f.ResumeLayout (false);
584                         
585                         f.Show ();
586                         
587                         Assert.AreEqual (new Size (600, 600), c.lv.Size, "I1");
588                         f.Close ();
589                 }
590                 
591                 private class MyUserControl : UserControl
592                 {
593                         public ListView lv;
594                         
595                         public MyUserControl ()
596                         {
597                                 lv = new ListView ();
598                                 SuspendLayout ();
599                                 lv.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
600                                 lv.Size = new Size (300, 300);
601                                 
602                                 Controls.Add (lv);
603                                 Size = new Size (200, 200);
604                                 ResumeLayout (false);
605                         }
606                 }
607         }
608
609         [TestFixture]   
610         public class DockingTests
611         {
612                 Form form;
613                 Panel panel;
614
615                 int event_count;
616
617                 [SetUp]
618                 public void Init ()
619                 {
620                         form = new Form ();
621                         form.ShowInTaskbar = false;
622                         form.Size = new Size (400, 400);
623                         panel = new Panel ();
624                         form.Controls.Add (panel);
625                         event_count = 0;
626                 }
627
628                 [TearDown]
629                 public void Cleanup ()
630                 {
631                         form.Dispose ();
632                 }
633
634                 void IncrementEventCount (object o, EventArgs args)
635                 {
636                         event_count++;
637                 }
638
639                 [Test]
640                 public void TestDockSizeChangedEvent ()
641                 {
642                         panel.SizeChanged += new EventHandler (IncrementEventCount);
643                         panel.Dock = DockStyle.Bottom;
644                         Assert.AreEqual (1, event_count);
645                 }
646
647                 [Test]
648                 public void TestDockLocationChangedEvent ()
649                 {
650                         panel.LocationChanged += new EventHandler (IncrementEventCount);
651                         panel.Dock = DockStyle.Bottom;
652                         Assert.AreEqual (1, event_count);
653                 }
654
655                 [Test]
656                 public void TestDockFillFirst ()
657                 {
658                         Form f = new Form ();
659                         f.ShowInTaskbar = false;
660
661                         Panel b1 = new Panel ();
662                         Panel b2 = new Panel ();
663
664                         b1.Dock = DockStyle.Fill;
665                         b2.Dock = DockStyle.Left;
666
667                         f.Controls.Add (b1);
668                         f.Controls.Add (b2);
669
670                         f.Show ();
671                         Assert.AreEqual (new Rectangle (b2.Width, 0, f.ClientRectangle.Width - b2.Width, f.ClientRectangle.Height), b1.Bounds, "A1");
672                         Assert.AreEqual (new Rectangle (0, 0, 200, f.ClientRectangle.Height), b2.Bounds, "A2");
673                         f.Dispose ();
674                 }
675
676                 [Test]
677                 public void TestDockFillLast ()
678                 {
679                         Form f = new Form ();
680                         f.ShowInTaskbar = false;
681
682                         Panel b1 = new Panel ();
683                         Panel b2 = new Panel ();
684
685                         b1.Dock = DockStyle.Fill;
686                         b2.Dock = DockStyle.Left;
687
688                         f.Controls.Add (b2);
689                         f.Controls.Add (b1);
690
691                         f.Show ();
692                         Assert.AreEqual (new Rectangle (0, 0, f.ClientRectangle.Width, f.ClientRectangle.Height), b1.Bounds, "B1");
693                         Assert.AreEqual (new Rectangle (0, 0, 200, f.ClientRectangle.Height), b2.Bounds, "B2");
694                         f.Dispose ();
695                 }
696                 
697                 [Test]  // bug #81397
698                 public void TestDockingWithCustomDisplayRectangle ()
699                 {
700                         MyControl mc = new MyControl ();
701                         mc.Size = new Size (200, 200);
702                         
703                         Control c = new Control ();
704                         c.Dock = DockStyle.Fill;
705                         
706                         mc.Controls.Add (c);
707                         
708                         Form f = new Form ();
709                         f.ShowInTaskbar = false;
710                         
711                         f.Controls.Add (mc);
712                         f.Show ();
713                         
714                         Assert.AreEqual (new Point (20, 20), c.Location, "A1");
715                         Assert.AreEqual (new Size (160, 160), c.Size, "A2");
716                         
717                         f.Dispose ();
718                 }
719                 
720                 private class MyControl : Control
721                 {
722                         public override Rectangle DisplayRectangle { 
723                                 get { return new Rectangle (20, 20, this.Width - 40, this.Height - 40); }
724                         }
725                 }
726         }
727
728         [TestFixture]   
729         public class UndockingTests
730         {
731                 class TestPanel : Panel {
732
733                         public void InvokeSetBoundsCore ()
734                         {
735                                 SetBoundsCore (37, 37, 37, 37, BoundsSpecified.All);
736                         }
737
738                         public void InvokeUpdateBounds ()
739                         {
740                                 UpdateBounds (37, 37, 37, 37);
741                         }
742                 }
743
744                 Form form;
745                 TestPanel panel;
746
747                 [SetUp]
748                 public void Init ()
749                 {
750                         form = new Form ();
751                         form.ShowInTaskbar = false;
752                         form.Size = new Size (400, 400);
753                         panel = new TestPanel ();
754                         form.Controls.Add (panel);
755                 }
756
757                 [TearDown]
758                 public void Cleanup ()
759                 {
760                         form.Dispose ();
761                 }
762
763                 [Test]
764                 public void TestUndockDefaultLocation ()
765                 {
766                         Point loc = panel.Location;
767                         panel.Dock = DockStyle.Bottom;
768                         panel.Dock = DockStyle.None;
769                         Assert.AreEqual (loc, panel.Location);
770                 }
771
772                 [Test]
773                 public void TestUndockDefaultLocationVisible ()
774                 {
775                         form.Show ();
776                         Point loc = panel.Location;
777                         panel.Dock = DockStyle.Bottom;
778                         panel.Dock = DockStyle.None;
779                         Assert.AreEqual (loc, panel.Location);
780                 }
781
782                 [Test]
783                 public void TestUndockExplicitLeft ()
784                 {
785                         panel.Left = 150;
786                         panel.Dock = DockStyle.Top;
787                         panel.Dock = DockStyle.None;
788                         Assert.AreEqual (150, panel.Left);
789                 }
790
791                 [Test]
792                 public void TestUndockExplicitTop ()
793                 {
794                         panel.Top = 150;
795                         panel.Dock = DockStyle.Top;
796                         panel.Dock = DockStyle.None;
797                         Assert.AreEqual (150, panel.Top);
798                 }
799
800                 [Test]
801                 public void TestUndockExplicitLocation ()
802                 {
803                         panel.Location = new Point (50, 50);
804                         Point loc = panel.Location;
805                         panel.Dock = DockStyle.Bottom;
806                         panel.Dock = DockStyle.None;
807                         Assert.AreEqual (loc, panel.Location);
808                 }
809
810                 [Test]
811                 public void TestUndockExplicitLeftVisible ()
812                 {
813                         form.Show ();
814                         panel.Left = 150;
815                         panel.Dock = DockStyle.Top;
816                         panel.Dock = DockStyle.None;
817                         Assert.AreEqual (150, panel.Left);
818                 }
819
820                 [Test]
821                 public void TestUndockExplicitTopVisible ()
822                 {
823                         form.Show ();
824                         panel.Top = 150;
825                         panel.Dock = DockStyle.Top;
826                         panel.Dock = DockStyle.None;
827                         Assert.AreEqual (150, panel.Top);
828                 }
829
830                 [Test]
831                 public void TestUndockExplicitLocationVisible ()
832                 {
833                         form.Show ();
834                         panel.Location = new Point (50, 50);
835                         Point loc = panel.Location;
836                         panel.Dock = DockStyle.Bottom;
837                         panel.Dock = DockStyle.None;
838                         Assert.AreEqual (loc, panel.Location);
839                 }
840
841                 [Test]
842                 public void TestUndockDefaultSize ()
843                 {
844                         Size sz = panel.Size;
845                         panel.Dock = DockStyle.Fill;
846                         panel.Dock = DockStyle.None;
847                         Assert.AreEqual (sz, panel.Size);
848                 }
849
850                 [Test]
851                 public void TestUndockExplicitHeight ()
852                 {
853                         panel.Height = 50;
854                         panel.Dock = DockStyle.Left;
855                         panel.Dock = DockStyle.None;
856                         Assert.AreEqual (50, panel.Height);
857                 }
858
859                 [Test]
860                 public void TestUndockExplicitSize ()
861                 {
862                         panel.Size = new Size (50, 50);
863                         Size sz = panel.Size;
864                         panel.Dock = DockStyle.Fill;
865                         panel.Dock = DockStyle.None;
866                         Assert.AreEqual (sz, panel.Size);
867                 }
868
869                 [Test]
870                 public void TestUndockExplicitWidth ()
871                 {
872                         panel.Width = 50;
873                         panel.Dock = DockStyle.Top;
874                         panel.Dock = DockStyle.None;
875                         Assert.AreEqual (50, panel.Width);
876                 }
877
878                 [Test]
879                 public void TestUndockExplicitHeightVisible ()
880                 {
881                         form.Show ();
882                         panel.Height = 50;
883                         panel.Dock = DockStyle.Left;
884                         panel.Dock = DockStyle.None;
885                         Assert.AreEqual (50, panel.Height);
886                 }
887
888                 [Test]
889                 public void TestUndockExplicitSizeVisible ()
890                 {
891                         form.Show ();
892                         panel.Size = new Size (50, 50);
893                         Size sz = panel.Size;
894                         panel.Dock = DockStyle.Fill;
895                         panel.Dock = DockStyle.None;
896                         Assert.AreEqual (sz, panel.Size);
897                 }
898
899                 [Test]
900                 public void TestUndockExplicitWidthVisible ()
901                 {
902                         form.Show ();
903                         panel.Width = 50;
904                         panel.Dock = DockStyle.Top;
905                         panel.Dock = DockStyle.None;
906                         Assert.AreEqual (50, panel.Width);
907                 }
908
909                 [Test]
910                 public void TestUndockSetBounds ()
911                 {
912                         panel.SetBounds (50, 50, 50, 50, BoundsSpecified.All);
913                         panel.Dock = DockStyle.Top;
914                         panel.Dock = DockStyle.None;
915                         Assert.AreEqual (50, panel.Height, "Height");
916                         Assert.AreEqual (50, panel.Left, "Left");
917                         Assert.AreEqual (50, panel.Top, "Top");
918                         Assert.AreEqual (50, panel.Width, "Width");
919                 }
920
921                 [Test]
922                 public void TestUndockSetBoundsVisible ()
923                 {
924                         form.Show ();
925                         panel.SetBounds (50, 50, 50, 50, BoundsSpecified.All);
926                         panel.Dock = DockStyle.Top;
927                         panel.Dock = DockStyle.None;
928                         Assert.AreEqual (50, panel.Height, "Height");
929                         Assert.AreEqual (50, panel.Left, "Left");
930                         Assert.AreEqual (50, panel.Top, "Top");
931                         Assert.AreEqual (50, panel.Width, "Width");
932                 }
933
934                 [Test]
935                 public void TestUndockSetBoundsCore ()
936                 {
937                         panel.InvokeSetBoundsCore ();
938                         panel.Dock = DockStyle.Top;
939                         panel.Dock = DockStyle.None;
940                         Assert.AreEqual (37, panel.Height, "Height");
941                         Assert.AreEqual (37, panel.Left, "Left");
942                         Assert.AreEqual (37, panel.Top, "Top");
943                         Assert.AreEqual (37, panel.Width, "Width");
944                 }
945
946                 [Test]
947                 public void TestUndockSetBoundsCoreVisible ()
948                 {
949                         form.Show ();
950                         panel.InvokeSetBoundsCore ();
951                         panel.Dock = DockStyle.Top;
952                         panel.Dock = DockStyle.None;
953                         Assert.AreEqual (37, panel.Height, "Height");
954                         Assert.AreEqual (37, panel.Left, "Left");
955                         Assert.AreEqual (37, panel.Top, "Top");
956                         Assert.AreEqual (37, panel.Width, "Width");
957                 }
958
959                 [Test]
960                 public void TestUndockUpdateBounds ()
961                 {
962                         panel.InvokeUpdateBounds ();
963                         panel.Dock = DockStyle.Top;
964                         panel.Dock = DockStyle.None;
965                         Assert.AreEqual (37, panel.Height, "Height");
966                         Assert.AreEqual (37, panel.Left, "Left");
967                         Assert.AreEqual (37, panel.Top, "Top");
968                         Assert.AreEqual (37, panel.Width, "Width");
969                 }
970
971                 [Test]
972                 public void TestUndockUpdateBoundsVisible ()
973                 {
974                         form.Show ();
975                         panel.InvokeUpdateBounds ();
976                         panel.Dock = DockStyle.Top;
977                         panel.Dock = DockStyle.None;
978                         Assert.AreEqual (37, panel.Height, "Height");
979                         Assert.AreEqual (37, panel.Left, "Left");
980                         Assert.AreEqual (37, panel.Top, "Top");
981                         Assert.AreEqual (37, panel.Width, "Width");
982                 }
983         }
984 }