2008-04-29 Carlos Alberto Cortez <calberto.cortez@gmail.com>
authorCarlos Alberto Cortez <calberto.cortez@gmail.com>
Tue, 29 Apr 2008 21:30:45 +0000 (21:30 -0000)
committerCarlos Alberto Cortez <calberto.cortez@gmail.com>
Tue, 29 Apr 2008 21:30:45 +0000 (21:30 -0000)
* DragAndDropTest.cs: New test.

svn path=/trunk/mcs/; revision=102152

mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DragAndDropTest.cs

index b5fd09e8ea9790528103a515e799e13e1c249d5a..d3dc96194ffc8450e3a5867da50a2758da55913a 100644 (file)
@@ -1,3 +1,7 @@
+2008-04-29  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * DragAndDropTest.cs: New test.
+
 2008-04-28  Jonathan Pobst  <monkey@jpobst.com>
        
        * ScrollBarTest.cs: Add test for bug #384182.
index 401fbee6c843b342e338ef7885d6c182c17c66d9..98e6de6175aa29d244670b53eb3702da5e11d16d 100755 (executable)
@@ -248,6 +248,59 @@ namespace MonoTests.System.Windows.Forms
                        Assert.AreEqual (1, form.DropControl.LeaveFiredCount, "A2");
                        Assert.AreEqual (DragDropEffects.Move, form.DragControl.PerformedEffect, "A3");
                }
+
+               [Test]
+               public void DragDropInSameControl ()
+               {
+                       DNDForm form = new DNDForm ();
+                       form.Text = MethodBase.GetCurrentMethod ().Name;
+                       form.InstructionsText =
+                               "Instructions:" + Environment.NewLine + Environment.NewLine +
+                               "1. Click with left button on the control on the left, holding it." + Environment.NewLine +
+                               "2. Move the mouse inside left control. " + Environment.NewLine +
+                               "3. Drop on left control (same)." + Environment.NewLine + Environment.NewLine +
+                               "4. Click with left button on the control on the left again, holding it." + Environment.NewLine +
+                               "5. Press ESC, release mouse button and move mouse pointer outside control." + Environment.NewLine +
+                               "4. Close the form.";
+                       form.DragControl.DragData = "SameControl";
+                       form.DragControl.AllowDrop = true;
+                       form.DragControl.AllowedEffects = DragDropEffects.Copy;
+
+                       data = null;
+                       drag_enter_count = drag_leave_count = 0;
+                       form.DragControl.DragEnter += new DragEventHandler (DragDropInSameControl_DragEnter);
+                       form.DragControl.DragLeave += new EventHandler (DragDropInSameControl_DragLeave);
+                       form.DragControl.DragDrop += new DragEventHandler (DragDropInSameControl_DragDrop);
+
+                       Application.Run (form);
+
+                       Assert.AreEqual (2, drag_enter_count, "A1");
+                       Assert.AreEqual (1, drag_leave_count, "A2");
+                       Assert.AreEqual (1, drag_drop_count, "A3");
+                       Assert.AreEqual ("SameControl", data, "A4");
+               }
+
+               int drag_enter_count;
+               int drag_leave_count;
+               int drag_drop_count;
+               object data;
+
+               void DragDropInSameControl_DragDrop (object sender, DragEventArgs e)
+               {
+                       drag_drop_count++;
+                       data = e.Data.GetData (typeof (string));
+               }
+
+               void DragDropInSameControl_DragLeave (object sender, EventArgs e)
+               {
+                       drag_leave_count++;
+               }
+
+               void DragDropInSameControl_DragEnter (object sender, DragEventArgs e)
+               {
+                       e.Effect = DragDropEffects.Copy;
+                       drag_enter_count++;
+               }
        }
 
        public class DNDForm : Form
@@ -262,11 +315,12 @@ namespace MonoTests.System.Windows.Forms
                        test_name = new Label ();
                        test_name.Location = new Point (5, 5);
                        test_name.AutoSize = true;
-                       //test_name.Font += new Font (Font, FontStyle.Bold | Font.Style);
+                       test_name.Font = new Font (Font, FontStyle.Bold | Font.Style);
                        test_name.Text = Text;
 
                        instructions_tb = new TextBox ();
                        instructions_tb.Multiline = true;
+                       instructions_tb.ScrollBars = ScrollBars.Vertical;
                        instructions_tb.Location = new Point (5, test_name.Bottom + 5);
                        instructions_tb.Size = new Size (460, 180);