public IEnumerator DragRemoveSelectionFromStackNode() { // Creates a stack and add node1, node2, node3 StackNode stack = CreateStackNode(k_DefaultX, k_DefaultY); stack.AddElement(m_Node1); stack.AddElement(m_Node2); stack.AddElement(m_Node3); // Allow two frames to compute the layout of the stack and nodes yield return(null); yield return(null); // Select node1 and node2 m_Node1.Select(graphView, false); m_Node2.Select(graphView, true); Vector2 start = m_Node1.worldBound.center; Vector2 outsideStackNode = stack.LocalToWorld(k_OutsidePosition); // Drag node1 and node2 away from the stack helpers.DragTo(start, outsideStackNode); Assert.AreEqual(1, stack.childCount); Assert.IsTrue(stack.Contains(m_Node3)); }
[UnityTest] // Case 1015984 public IEnumerator DragRemoveAndThenAddSelectionBackToStackNode() { // Creates a stack and add node1 StackNode stack = CreateStackNode(k_DefaultX, k_DefaultY); stack.AddElement(m_Node1); // Allow two frames to compute the layout of the stack and nodes yield return(null); yield return(null); // Select node1 m_Node1.Select(graphView, false); Vector2 start = m_Node1.worldBound.center; Vector2 outsideStackNode = stack.LocalToWorld(k_OutsidePosition); // Drag node1 away from the stack helpers.DragTo(start, outsideStackNode); Assert.AreEqual(0, stack.childCount); // Allow one frame to compute the layout of the stack and node1 yield return(null); start = m_Node1.worldBound.center; Vector2 centerOfStack = stack.LocalToWorld(stack.GetRect().center); // Center of the stack // Drag node1 onto the stack helpers.DragTo(start, centerOfStack); // Verify that node1 has been added back to the stack Assert.AreEqual(1, stack.childCount); Assert.AreEqual(stack, m_Node1.parent); }
public IEnumerator DragAddSelectionToStackNode() { // Create a stack StackNode stack = CreateStackNode(k_DefaultX, k_DefaultY); // Allow two frames to compute the layout of the stack and nodes yield return(null); yield return(null); // Select node1 m_Node1.Select(graphView, false); Vector2 start = m_Node1.worldBound.center; Vector2 centerOfStack = stack.LocalToWorld(stack.GetRect().center); // Center of the stack // Drag node1 onto the stack helpers.DragTo(start, centerOfStack); // Verify that node1 has been added to stack Assert.AreEqual(1, stack.childCount); Assert.AreEqual(stack, m_Node1.parent); // Allow one frame to compute the layout of the stack yield return(null); // Select node2 m_Node2.Select(graphView, false); start = m_Node2.worldBound.center; Vector2 centerOfNode1 = m_Node1.worldBound.center; // Center of Node1 // Drag node2 onto the stack at the position of node1 helpers.DragTo(start, centerOfNode1); // Verify that node2 has been added to the stack at the previous index of node1 Assert.AreEqual(2, stack.childCount); Assert.AreEqual(stack, m_Node2.parent); Assert.AreEqual(0, stack.IndexOf(m_Node2)); }
public IEnumerator DragReorderSelectionInStackNode() { // Creates a stack and add node1, node2, node3 StackNode stack = CreateStackNode(k_DefaultX, k_DefaultY); stack.AddElement(m_Node1); stack.AddElement(m_Node2); stack.AddElement(m_Node3); // Allow two frames to compute the layout of the stack and nodes yield return(null); yield return(null); // Select node1 m_Node1.Select(graphView, false); Vector2 start = m_Node1.worldBound.center; Vector2 outsideStackNode = stack.LocalToWorld(k_OutsidePosition); // Drag node1 away from the stack helpers.MouseDownEvent(start, MouseButton.LeftMouse); helpers.MouseDragEvent(start, outsideStackNode, MouseButton.LeftMouse); // Allow one frame to compute the layout of the stack yield return(null); Vector2 centerOfNode3 = m_Node3.worldBound.center; helpers.MouseDragEvent(outsideStackNode, centerOfNode3, MouseButton.LeftMouse); helpers.MouseUpEvent(centerOfNode3); // Verify that node1 has been moved to index 1 (before node3) Assert.AreEqual(3, stack.childCount); Assert.AreEqual(1, stack.IndexOf(m_Node1)); }