public override void SetUp() { base.SetUp(); m_Node1 = CreateNode("Node 1", new Vector2(10, 30)); m_Node2 = CreateNode("Node 2", new Vector2(270, 30)); m_Node3 = CreateNode("Node 3", new Vector2(400, 30)); // overlaps m_Node2 }
public IEnumerator EdgeConnectDragMultipleEdgesFromExecutionPortInputToOutputWorks() { IONodeModel exeStartNode = CreateNode("First Out Exe node", new Vector2(100, 100), 0, 0, 0, 1); IONodeModel exeStartNode2 = CreateNode("Second Out Exe node", new Vector2(100, 400), 0, 0, 0, 1); IONodeModel exeEndNode = CreateNode("First In Exe node", new Vector2(400, 100), 0, 0, 1, 0); IONodeModel exeEndNode2 = CreateNode("Second In Exe node", new Vector2(400, 400), 0, 0, 1, 0); IPortModel startPort = exeStartNode.GetPorts(PortDirection.Output, PortType.Execution).First(); IPortModel startPort2 = exeStartNode2.GetPorts(PortDirection.Output, PortType.Execution).First(); IPortModel endPort = exeEndNode.GetPorts(PortDirection.Input, PortType.Execution).First(); IPortModel endPort2 = exeEndNode2.GetPorts(PortDirection.Input, PortType.Execution).First(); // We start without any connection Assert.AreEqual(0, startPort.GetConnectedEdges().Count()); Assert.AreEqual(0, endPort.GetConnectedEdges().Count()); Assert.AreEqual(0, endPort2.GetConnectedEdges().Count()); MarkGraphViewStateDirty(); yield return(null); Port startPortUI = startPort.GetUI <Port>(graphView); Port startPort2UI = startPort2.GetUI <Port>(graphView); Port endPortUI = endPort.GetUI <Port>(graphView); Port endPort2UI = endPort2.GetUI <Port>(graphView); // Drag an edge between the two ports helpers.DragTo(startPortUI.GetGlobalCenter(), endPortUI.GetGlobalCenter()); helpers.DragTo(startPort2UI.GetGlobalCenter(), endPortUI.GetGlobalCenter()); // Allow one frame for the edge to be placed onto a layer yield return(null); // Allow one frame for the edge to be rendered and process its layout a first time yield return(null); // Check that the edge exists and that it connects the two ports. Assert.AreEqual(1, startPort.GetConnectedEdges().Count()); Assert.AreEqual(1, startPort2.GetConnectedEdges().Count()); Assert.AreEqual(2, endPort.GetConnectedEdges().Count()); graphView.CommandDispatcher.Dispatch(new SelectElementsCommand(SelectElementsCommand.SelectionMode.Replace, endPort.GetConnectedEdges().First(), endPort.GetConnectedEdges().Skip(1).First())); helpers.DragTo(endPortUI.GetGlobalCenter() - new Vector3(k_EdgeSelectionOffset, 0, 0), endPort2UI.GetGlobalCenter()); // Allow one frame for the edge to be placed onto a layer yield return(null); // Allow one frame for the edge to be rendered and process its layout a first time yield return(null); Assert.AreEqual(1, startPort.GetConnectedEdges().Count()); Assert.AreEqual(1, startPort2.GetConnectedEdges().Count()); Assert.AreEqual(2, endPort2.GetConnectedEdges().Count()); }
static IEnumerable <Func <BasicModel.NodeModel> > NodeModelCreators() { yield return(() => new NodeModel()); yield return(() => new SingleInputNodeModel()); yield return(() => new SingleOutputNodeModel()); yield return(() => { var model = new IONodeModel { InputCount = 3, OuputCount = 5 }; return model; }); }
protected IEnumerator SetUpUIElements(Vector2 snappingNodePos, Vector2 referenceNode1Pos = default, Vector2 referenceNode2Pos = default, bool isVerticalPort = false, bool isPortSnapping = false) { m_SnappingNodePos = snappingNodePos; m_ReferenceNode1Pos = referenceNode1Pos; m_ReferenceNode2Pos = referenceNode2Pos; snappingNodeModel = CreateNode("Snapping Node", GraphViewStaticBridge.RoundToPixelGrid(m_SnappingNodePos), inCount: 1, orientation: isVerticalPort ? PortOrientation.Vertical : PortOrientation.Horizontal); referenceNode1Model = CreateNode("Reference Node 1", GraphViewStaticBridge.RoundToPixelGrid(m_ReferenceNode1Pos), outCount: 1, orientation: isVerticalPort ? PortOrientation.Vertical : PortOrientation.Horizontal); referenceNode2Model = CreateNode("Reference Node 2", GraphViewStaticBridge.RoundToPixelGrid(m_ReferenceNode2Pos), orientation: isVerticalPort ? PortOrientation.Vertical : PortOrientation.Horizontal); if (isPortSnapping) { m_InputPort = snappingNodeModel.InputsByDisplayOrder[0]; m_OutputPort = referenceNode1Model.OutputsByDisplayOrder[0]; Assert.IsNotNull(m_OutputPort); Assert.IsNotNull(m_InputPort); MarkGraphViewStateDirty(); yield return(null); // Connect the ports together var actions = ConnectPorts(m_OutputPort, m_InputPort); while (actions.MoveNext()) { yield return(null); } } MarkGraphViewStateDirty(); yield return(null); // Get the UI nodes m_SnappedNode = snappingNodeModel.GetUI <Node>(graphView); m_ReferenceNode1 = referenceNode1Model.GetUI <Node>(graphView); m_ReferenceNode2 = referenceNode2Model.GetUI <Node>(graphView); m_SnappingNodePos = m_SnappedNode?.layout.position ?? Vector2.zero; m_ReferenceNode1Pos = m_ReferenceNode1?.layout.position ?? Vector2.zero; m_ReferenceNode2Pos = m_ReferenceNode2?.layout.position ?? Vector2.zero; Assert.IsNotNull(m_SnappedNode); Assert.IsNotNull(m_ReferenceNode1); Assert.IsNotNull(m_ReferenceNode2); }