NodeCreationTests.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <QLineEdit>
  10. #include <QMenu>
  11. #include <QString>
  12. #include <GraphCanvas/Components/Nodes/NodeBus.h>
  13. #include <GraphCanvas/Components/SceneBus.h>
  14. #include <GraphCanvas/Components/Slots/SlotBus.h>
  15. #include <GraphCanvas/Components/VisualBus.h>
  16. #include <GraphCanvas/Utils/ConversionUtils.h>
  17. #include <ScriptCanvas/Bus/RequestBus.h>
  18. #include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h>
  19. #include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/ConnectionStates.h>
  20. #include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/CreateElementsStates.h>
  21. #include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/EditorViewStates.h>
  22. #include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/ElementInteractionStates.h>
  23. #include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/GraphStates.h>
  24. #include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/UtilityStates.h>
  25. #include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/VariableStates.h>
  26. namespace ScriptCanvas::Developer
  27. {
  28. /**
  29. EditorautomationTest that creates a node from the node palette using drag/drop
  30. */
  31. class CreateNodeFromPaletteTest
  32. : public EditorAutomationTest
  33. {
  34. public:
  35. CreateNodeFromPaletteTest(const AZStd::string& nodeName, GraphCanvas::NodePaletteWidget* paletteWidget)
  36. : EditorAutomationTest(AZStd::string::format("Create %s from Node Palette", nodeName.c_str()).c_str())
  37. {
  38. AutomationStateModelId viewCenterModelId = "ViewCenter";
  39. AddState(new CreateRuntimeGraphState());
  40. AddState(new FindViewCenterState(viewCenterModelId));
  41. AddState(new CreateNodeFromPaletteState(paletteWidget, nodeName.c_str(), CreateNodeFromPaletteState::CreationType::ScenePosition, viewCenterModelId));
  42. AddState(new ForceCloseActiveGraphState());
  43. }
  44. };
  45. /**
  46. EditorautomationTest that creates a node from the context menu
  47. */
  48. class CreateNodeFromContextMenuTest
  49. : public EditorAutomationTest
  50. {
  51. public:
  52. CreateNodeFromContextMenuTest(const AZStd::string& nodeName)
  53. : EditorAutomationTest(AZStd::string::format("Create %s from Context Menu", nodeName.c_str()).c_str())
  54. {
  55. AutomationStateModelId viewCenterModelId = "ViewCenter";
  56. AddState(new CreateRuntimeGraphState());
  57. AddState(new FindViewCenterState(viewCenterModelId));
  58. AddState(new CreateNodeFromContextMenuState(nodeName.c_str(), CreateNodeFromContextMenuState::CreationType::ScenePosition, viewCenterModelId));
  59. AddState(new ForceCloseActiveGraphState());
  60. }
  61. };
  62. /**
  63. EditorautomationTest that creates a simple graph from the node palette and coupling.
  64. */
  65. class CreateHelloWorldFromPalette
  66. : public EditorAutomationTest
  67. {
  68. public:
  69. CreateHelloWorldFromPalette(GraphCanvas::NodePaletteWidget* paletteWidget)
  70. : EditorAutomationTest("Create Hello World From Palette")
  71. {
  72. AddState(new CreateRuntimeGraphState());
  73. AutomationStateModelId onGraphStartTargetPointId = "OnGraphStartScenePoint";
  74. AutomationStateModelId onGraphStartId = "OnGraphStartId";
  75. AddState(new FindViewCenterState(onGraphStartTargetPointId));
  76. AddState(new CreateNodeFromPaletteState(paletteWidget, "On Graph Start", CreateNodeFromPaletteState::CreationType::ScenePosition, onGraphStartTargetPointId, onGraphStartId));
  77. AutomationStateModelId printTargetPoint = "PrintScenePoint";
  78. AutomationStateModelId printId = "PrintId";
  79. FindPositionOffsets offsets;
  80. offsets.m_horizontalPosition = 1;
  81. offsets.m_horizontalOffset = 50;
  82. AddState(new FindNodePosition(onGraphStartId, printTargetPoint, offsets));
  83. AddState(new CreateNodeFromPaletteState(paletteWidget, "Print", CreateNodeFromPaletteState::CreationType::ScenePosition, printTargetPoint, printId));
  84. AddState(new CoupleNodesState(onGraphStartId, GraphCanvas::ConnectionType::CT_Output, printId));
  85. AddState(new ForceCloseActiveGraphState());
  86. }
  87. };
  88. /**
  89. EditorautomationTest that creates a simple graph from the context menu and coupling.
  90. */
  91. class CreateHelloWorldFromContextMenu
  92. : public EditorAutomationTest
  93. {
  94. public:
  95. CreateHelloWorldFromContextMenu()
  96. : EditorAutomationTest("Create Hello World From Context Menu")
  97. {
  98. AddState(new CreateRuntimeGraphState());
  99. AutomationStateModelId onGraphStartTargetPointId = "OnGraphStartScenePoint";
  100. AutomationStateModelId onGraphStartId = "OnGraphStartId";
  101. AddState(new FindViewCenterState(onGraphStartTargetPointId));
  102. AddState(new CreateNodeFromContextMenuState("On Graph Start", CreateNodeFromContextMenuState::CreationType::ScenePosition, onGraphStartTargetPointId, onGraphStartId));
  103. AutomationStateModelId printTargetPoint = "PrintScenePoint";
  104. AutomationStateModelId printId = "PrintId";
  105. FindPositionOffsets offsets;
  106. offsets.m_horizontalPosition = 1;
  107. offsets.m_horizontalOffset = 50;
  108. AddState(new FindNodePosition(onGraphStartId, printTargetPoint, offsets));
  109. AddState(new CreateNodeFromContextMenuState("Print", CreateNodeFromContextMenuState::CreationType::ScenePosition, printTargetPoint, printId));
  110. AddState(new CoupleNodesState(onGraphStartId, GraphCanvas::ConnectionType::CT_Output, printId));
  111. AddState(new ForceCloseActiveGraphState());
  112. }
  113. };
  114. /**
  115. EditorautomationTest that creates all of the nodes under the specified category
  116. */
  117. class CreateCategoryTest
  118. : public EditorAutomationTest
  119. {
  120. public:
  121. CreateCategoryTest(AZStd::string categoryString, GraphCanvas::NodePaletteWidget* nodePaletteWidget);
  122. ~CreateCategoryTest() override = default;
  123. };
  124. /**
  125. EditorautomationTest that will splice the specified node onto a simple graph using execution connections and the context menu
  126. */
  127. class CreateExecutionSplicedNodeTest
  128. : public EditorAutomationTest
  129. {
  130. public:
  131. CreateExecutionSplicedNodeTest(QString nodeName);
  132. ~CreateExecutionSplicedNodeTest() override = default;
  133. };
  134. /**
  135. EditorautomationTest that will splice the specified node onto a simple graph using execution connections and dragging/dropping
  136. */
  137. class CreateDragDropExecutionSpliceNodeTest
  138. : public EditorAutomationTest
  139. {
  140. public:
  141. CreateDragDropExecutionSpliceNodeTest(GraphCanvas::NodePaletteWidget* nodePaletteWidget, QString nodeName);
  142. ~CreateDragDropExecutionSpliceNodeTest() override = default;
  143. };
  144. }