|
| 1 | +#include "SimpleTest.hpp" |
| 2 | +#include "NUIE_NodeEditor.hpp" |
| 3 | +#include "BI_InputUINodes.hpp" |
| 4 | +#include "BI_ViewerUINodes.hpp" |
| 5 | +#include "VisualTestFramework.hpp" |
| 6 | + |
| 7 | +using namespace NE; |
| 8 | +using namespace NUIE; |
| 9 | +using namespace BI; |
| 10 | + |
| 11 | +namespace NodeEditorVisualTestReconnection |
| 12 | +{ |
| 13 | + |
| 14 | +class ReconnectionTestEnv : public NodeEditorTestEnv |
| 15 | +{ |
| 16 | +public: |
| 17 | + ReconnectionTestEnv (const BasicSkinParams& skinParams) : |
| 18 | + NodeEditorTestEnv (skinParams) |
| 19 | + { |
| 20 | + integerUpDownNode.reset (new BI::IntegerUpDownNode (LocString (L"Integer"), NUIE::Point (100, 100), 1, 1)); |
| 21 | + doubleUpDownNode.reset (new BI::DoubleUpDownNode (LocString (L"Number"), NUIE::Point (100, 300), 2.0, 1.0)); |
| 22 | + listBuilder1Node.reset (new BI::ListBuilderNode (LocString (L"List"), NUIE::Point (350, 200))); |
| 23 | + listBuilder2Node.reset (new BI::ListBuilderNode (LocString (L"List"), NUIE::Point (350, 400))); |
| 24 | + viewer1Node.reset (new BI::MultiLineViewerNode (LocString (L"Viewer"), NUIE::Point (600, 100), 5)); |
| 25 | + viewer2Node.reset (new BI::MultiLineViewerNode (LocString (L"Viewer"), NUIE::Point (600, 300), 5)); |
| 26 | + viewer3Node.reset (new BI::MultiLineViewerNode (LocString (L"Viewer"), NUIE::Point (600, 500), 5)); |
| 27 | + |
| 28 | + nodeEditor.AddNode (integerUpDownNode); |
| 29 | + nodeEditor.AddNode (doubleUpDownNode); |
| 30 | + nodeEditor.AddNode (listBuilder1Node); |
| 31 | + nodeEditor.AddNode (listBuilder2Node); |
| 32 | + nodeEditor.AddNode (viewer1Node); |
| 33 | + nodeEditor.AddNode (viewer2Node); |
| 34 | + nodeEditor.AddNode (viewer3Node); |
| 35 | + |
| 36 | + nodeEditor.ConnectOutputSlotToInputSlot (integerUpDownNode->GetUIOutputSlot (SlotId ("out")), listBuilder1Node->GetUIInputSlot (SlotId ("in"))); |
| 37 | + nodeEditor.ConnectOutputSlotToInputSlot (doubleUpDownNode->GetUIOutputSlot (SlotId ("out")), listBuilder1Node->GetUIInputSlot (SlotId ("in"))); |
| 38 | + |
| 39 | + nodeEditor.ConnectOutputSlotToInputSlot (listBuilder1Node->GetUIOutputSlot (SlotId ("out")), viewer1Node->GetUIInputSlot (SlotId ("in"))); |
| 40 | + nodeEditor.ConnectOutputSlotToInputSlot (listBuilder1Node->GetUIOutputSlot (SlotId ("out")), viewer2Node->GetUIInputSlot (SlotId ("in"))); |
| 41 | + |
| 42 | + nodeEditor.ConnectOutputSlotToInputSlot (listBuilder2Node->GetUIOutputSlot (SlotId ("out")), viewer3Node->GetUIInputSlot (SlotId ("in"))); |
| 43 | + |
| 44 | + nodeEditor.Update (); |
| 45 | + RecalcPositions (); |
| 46 | + } |
| 47 | + |
| 48 | + void RecalcPositions () |
| 49 | + { |
| 50 | + listBuilder1InputSlotPosition = listBuilder1Node->GetInputSlotRect (uiEnvironment, SlotId ("in")).GetCenter (); |
| 51 | + listBuilder2InputSlotPosition = listBuilder2Node->GetInputSlotRect (uiEnvironment, SlotId ("in")).GetCenter (); |
| 52 | + listBuilder1OutputSlotPosition = listBuilder1Node->GetOutputSlotRect (uiEnvironment, SlotId ("out")).GetCenter (); |
| 53 | + listBuilder2OutputSlotPosition = listBuilder2Node->GetOutputSlotRect (uiEnvironment, SlotId ("out")).GetCenter (); |
| 54 | + } |
| 55 | + |
| 56 | + UINodePtr integerUpDownNode; |
| 57 | + UINodePtr doubleUpDownNode; |
| 58 | + UINodePtr listBuilder1Node; |
| 59 | + UINodePtr listBuilder2Node; |
| 60 | + UINodePtr viewer1Node; |
| 61 | + UINodePtr viewer2Node; |
| 62 | + UINodePtr viewer3Node; |
| 63 | + |
| 64 | + Point listBuilder1InputSlotPosition; |
| 65 | + Point listBuilder2InputSlotPosition; |
| 66 | + Point listBuilder1OutputSlotPosition; |
| 67 | + Point listBuilder2OutputSlotPosition; |
| 68 | +}; |
| 69 | + |
| 70 | +TEST (ReconnectionTest_ReconnectInputSlot) |
| 71 | +{ |
| 72 | + ReconnectionTestEnv env (GetDefaultSkinParams ()); |
| 73 | + ModifierKeys commandKey ({ ModifierKeyCode::Command }); |
| 74 | + ASSERT (env.CheckReference (L"Reconnection_InputSlotBasic.svg")); |
| 75 | + |
| 76 | + { |
| 77 | + env.DragDrop (commandKey, env.listBuilder1InputSlotPosition, env.listBuilder2InputSlotPosition); |
| 78 | + ASSERT (env.CheckReference (L"Reconnection_InputSlotReconnected.svg")); |
| 79 | + } |
| 80 | + |
| 81 | + { |
| 82 | + Point disconnectPosition = env.listBuilder2InputSlotPosition - Point (0, 100); |
| 83 | + env.DragDrop (commandKey, env.listBuilder2InputSlotPosition, disconnectPosition, [&] () { |
| 84 | + ASSERT (env.CheckReference (L"Reconnection_InputSlotBeforeDisconnect.svg")); |
| 85 | + }); |
| 86 | + ASSERT (env.CheckReference (L"Reconnection_InputSlotDisconnected.svg")); |
| 87 | + } |
| 88 | +} |
| 89 | + |
| 90 | +TEST (ReconnectionTest_ReconnectOutputSlot) |
| 91 | +{ |
| 92 | + ReconnectionTestEnv env (GetDefaultSkinParams ()); |
| 93 | + ModifierKeys commandKey ({ ModifierKeyCode::Command }); |
| 94 | + |
| 95 | + env.DragDrop (commandKey, env.listBuilder1InputSlotPosition, env.listBuilder2InputSlotPosition); |
| 96 | + ASSERT (env.CheckReference (L"Reconnection_OutputSlotBasic.svg")); |
| 97 | + |
| 98 | + { |
| 99 | + env.DragDrop (commandKey, env.listBuilder1OutputSlotPosition, env.listBuilder2OutputSlotPosition); |
| 100 | + ASSERT (env.CheckReference (L"Reconnection_OutputSlotReconnected1.svg")); |
| 101 | + } |
| 102 | + |
| 103 | + { |
| 104 | + env.DragDrop (commandKey, env.listBuilder2OutputSlotPosition, env.listBuilder1OutputSlotPosition); |
| 105 | + ASSERT (env.CheckReference (L"Reconnection_OutputSlotReconnected2.svg")); |
| 106 | + } |
| 107 | + |
| 108 | + { |
| 109 | + Point disconnectPosition = env.listBuilder1OutputSlotPosition + Point (50, 100); |
| 110 | + env.DragDrop (commandKey, env.listBuilder1OutputSlotPosition, disconnectPosition, [&] () { |
| 111 | + ASSERT (env.CheckReference (L"Reconnection_OutputSlotBeforeDisconnect.svg")); |
| 112 | + }); |
| 113 | + ASSERT (env.CheckReference (L"Reconnection_OutputSlotDisconnected.svg")); |
| 114 | + } |
| 115 | +} |
| 116 | + |
| 117 | +} |
0 commit comments