DragAndDrop of a tree node containing child nodes fails

Mar 25, 2009 at 12:34 PM
Edited Mar 25, 2009 at 12:36 PM
Hello,

I can't find such an issue discussed before, so I'm posting it hoping you know what's going on.

I have a TreeView control in WPF and I'm automating its testing using White. Trying the DragAndDrop today I'm unable to perform it some cases. I can successfully perform drag/drop of a single node that has no children, but if it contains a child, the drag/drop fails. Of course, I can do that manually.

Do you know why the drag/drop may fail in such a case?

I'm posting a test sample below. The last DragAndDrop fails only.

        [TestMethod]
        [Description("Drag and drop of nodes test.")]
        public void DragDropTest()
        {    
            TreeNode personalFolders = tree.Nodes[0];
            Assert.IsTrue(personalFolders.IsExpanded(), "Personal Folders: is not initially expanded!");
            Assert.AreEqual<int>(1, personalFolders.Nodes.Count);

            TreeNode deletedItems = tree.Nodes[1];
            Assert.AreEqual<int>(0, deletedItems.Nodes.Count);

            // drag/drop a node from one parent to another
            Mouse.Instance.DragAndDrop(personalFolders.Nodes[0], deletedItems);
            Assert.AreEqual<int>(1, deletedItems.Nodes.Count);
            Assert.AreEqual<int>(0, personalFolders.Nodes.Count);

            // drag/drop a node from one parent to another
            Mouse.Instance.DragAndDrop(deletedItems.Nodes[0], personalFolders);
            Assert.AreEqual<int>(0, deletedItems.Nodes.Count);
            Assert.AreEqual<int>(1, personalFolders.Nodes.Count);

            // drag/drop a node into its sibling
            Mouse.Instance.DragAndDrop(deletedItems, personalFolders);
            Assert.AreEqual<int>(2, personalFolders.Nodes.Count);
            Assert.AreEqual<int>(0, deletedItems.Nodes.Count);

            TreeNode inbox14 = tree.Nodes[2];
            Assert.AreEqual<int>(1, inbox14.Nodes.Count);

            // drag/drop a node having children into its sibling
            Mouse.Instance.DragAndDrop(inbox14, personalFolders); // this call fails

            Assert.AreEqual<int>(3, personalFolders.Nodes.Count);
            Assert.AreEqual<int>(1, inbox14.Nodes.Count);
        }


Thanks,
-Konstantin
Mar 25, 2009 at 12:43 PM
Forgot to mention some facts, although I'm not sure if they can help:

- It doesn't matter whether the 'inbox' node is expanded or not when I'm trying to drag and drop it -- the call fails in both cases.
- If I stop it with a breakpoint on debugging after the failing drag/drop call, the node that should have been drag is selected. For example:
   - if Inbox from the sample is collapsed -- it is selected after DragAndDrop.
   - if Inbox is expanded -- it's child get selected after that DragAndDrop call.

Any ideas?
Apr 29, 2013 at 2:12 PM
Does anybody get a solution for this problem? I've tried to collapse the draggedNode but when the Mouse.instance.DragAndDrop(draggedNode, droppedNode); is executed the draggedNode is expanded.

Thanks,
Tatiana
Coordinator
May 2, 2013 at 12:39 PM
@tatianam or kpetkov could you post an updated test with the xaml for the treeview as well? Is this still and issue with https://github.com/TestStack/White (install TestStack.White from NuGet).

I will add a test and try to fix it.