2007-05-03 Chris Toshok <toshok@ximian.com>
authorChris Toshok <toshok@novell.com>
Thu, 3 May 2007 21:25:18 +0000 (21:25 -0000)
committerChris Toshok <toshok@novell.com>
Thu, 3 May 2007 21:25:18 +0000 (21:25 -0000)
* CurrencyManager.cs (CurrencyManager.ListChangeHandler): in the
2.0 block, pass listposition + 1 to ChangeRecordState when a row
was added before the current listposition.  Fixes the
TestInsertRowBeforeCurrent unit test.

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

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/CurrencyManager.cs
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataBindingTests.cs

index 3c1e5c840e1aa3188bdab9ab6d4d1428ce8e25bd..4e67b96c3209b676191c4fc704c387de2c84f6fb 100644 (file)
@@ -1,3 +1,10 @@
+2007-05-03  Chris Toshok  <toshok@ximian.com>
+
+       * CurrencyManager.cs (CurrencyManager.ListChangeHandler): in the
+       2.0 block, pass listposition + 1 to ChangeRecordState when a row
+       was added before the current listposition.  Fixes the
+       TestInsertRowBeforeCurrent unit test.
+
 2007-05-03  Jonathan Pobst  <monkey@jpobst.com>
 
        * Application.cs: Add RaiseIdle.
index cc013632116339b6463117223e730ff6dd48a51d..7b2ae4fcacb38bf83128d28c9808633d4f274e52 100644 (file)
@@ -329,7 +329,7 @@ namespace System.Windows.Forms {
                        if (listposition >= list.Count)
                                listposition = list.Count - 1;
 
-                       if (listposition != -1)
+                       if (old_index != -1 && listposition != -1)
                                OnCurrentChanged (EventArgs.Empty);
 
                        if (firePositionChanged)
@@ -415,12 +415,16 @@ namespace System.Windows.Forms {
                                        ChangeRecordState (e.NewIndex,
                                                           false, false, true, false);
 
+#if ONLY_1_1
+                                       UpdateIsBinding ();
+#else
                                        OnItemChanged (new ItemChangedEventArgs (-1));
+#endif
                                }
                                else {
 #if NET_2_0
                                        if (e.NewIndex <= listposition) {
-                                               ChangeRecordState (listposition,
+                                               ChangeRecordState (listposition + 1,
                                                                   false, false, false, false);
                                                OnItemChanged (new ItemChangedEventArgs (-1));
                                                OnPositionChanged (EventArgs.Empty);
index 62f14b8acbb73c97d77162a59f9c21744aaaee71..fb451294a39efb71d27f8b3be5068a5a86999c26 100644 (file)
@@ -462,11 +462,6 @@ namespace MonoTests.System.Windows.Forms.DataBinding
                [Test]
                public void TestInsertRowBeforeCurrent ()
                {
-#if NET_2_0
-                       if (TestHelper.RunningOnUnix) {
-                               Assert.Ignore ("Fails with 2.0 profile");
-                       }
-#endif
                        Control c = new Control ();
                        c.CreateControl ();
                        Binding binding;
@@ -963,6 +958,49 @@ namespace MonoTests.System.Windows.Forms.DataBinding
                        Assert.AreEqual (2, cm.Count, "5");
                }
 
+               [Test]
+               public void CancelAddNew ()
+               {
+                       if (TestHelper.RunningOnUnix) {
+                               Assert.Ignore ("Fails at the moment");
+                       }
+
+                       Control c = new Control ();
+                       c.CreateControl ();
+                       Binding binding;
+                       CurrencyManager cm;
+
+                       DataSet dataSet1 = new DataSet();
+                       dataSet1.Tables.Add();
+                       dataSet1.Tables[0].Columns.Add();
+
+                       c.BindingContext = new BindingContext ();
+                       cm = (CurrencyManager) c.BindingContext[dataSet1, dataSet1.Tables[0].TableName];
+                       binding = c.DataBindings.Add ("Text", dataSet1.Tables[0], dataSet1.Tables[0].Columns[0].ColumnName);
+
+                       HookupCurrencyManager (cm);
+#if WITH_BINDINGS
+                       HookupBinding (binding);
+#endif
+                       event_log = "";
+                       event_num = 0;
+
+                       cm.AddNew ();
+
+                       cm.CancelCurrentEdit ();
+
+                       Console.WriteLine (event_log);
+
+                       Assert.AreEqual (
+#if NET_2_0
+                                "0: PositionChanged (to 0)\n1: CurrentChanged\n2: CurrentItemChanged\n3: ItemChanged (index = -1)\n4: ItemChanged (index = -1)\n5: PositionChanged (to -1)\n6: ItemChanged (index = -1)\n7: PositionChanged (to -1)\n8: CurrentChanged\n9: CurrentItemChanged\n10: ItemChanged (index = -1)\n11: ItemChanged (index = -1)\n",
+#else
+                                "0: PositionChanged (to 0)\n1: CurrentChanged\n2: ItemChanged (index = -1)\n3: ItemChanged (index = -1)\n4: CurrentChanged\n5: PositionChanged (to -1)\n6: ItemChanged (index = -1)\n7: ItemChanged (index = -1)\n8: ItemChanged (index = -1)\n",
+#endif
+                                event_log, "1");
+
+               }
+
        }
 
        [TestFixture]