Integrating latest 47acbe8
This commit is contained in:
+153
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QString>
|
||||
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/WidgetActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ConnectionActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/CreateElementsActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ElementInteractions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/GraphActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/VariableActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
DefineStateId(OpenMenuTest_OpenMenuState);
|
||||
|
||||
/**
|
||||
EditorAutomationTest to test the general systems. Will open the Developer menu.
|
||||
*/
|
||||
class OpenMenuTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
class OpenMenuState : public StaticIdAutomationState<OpenMenuTest_OpenMenuStateId>
|
||||
{
|
||||
public:
|
||||
OpenMenuState(QMenu* targetMenu)
|
||||
: m_targetMenu(targetMenu)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
m_shownMenu = false;
|
||||
|
||||
if (m_clickAction == nullptr)
|
||||
{
|
||||
QPoint targetPoint = m_targetMenu->mapToGlobal(QPoint(15, -10));
|
||||
|
||||
m_clickAction = aznew MouseClickAction(Qt::MouseButton::LeftButton, targetPoint);
|
||||
actionRunner.AddAction(m_clickAction);
|
||||
}
|
||||
|
||||
actionRunner.AddAction(&m_delayAction);
|
||||
|
||||
m_eventConnection = QObject::connect(m_targetMenu, &QMenu::aboutToShow, [this]()
|
||||
{
|
||||
this->OnTargetMenuShown();
|
||||
});
|
||||
}
|
||||
|
||||
void OnStateActionsComplete()
|
||||
{
|
||||
QObject::disconnect(m_eventConnection);
|
||||
|
||||
if (!m_shownMenu)
|
||||
{
|
||||
ReportError("Failed to show the menu");
|
||||
}
|
||||
|
||||
delete m_clickAction;
|
||||
m_clickAction = nullptr;
|
||||
}
|
||||
|
||||
void OnTargetMenuShown()
|
||||
{
|
||||
m_shownMenu = true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
QMenu* m_targetMenu;
|
||||
|
||||
MouseClickAction* m_clickAction = nullptr;
|
||||
DelayAction m_delayAction;
|
||||
|
||||
QMetaObject::Connection m_eventConnection;
|
||||
|
||||
bool m_shownMenu = false;
|
||||
};
|
||||
|
||||
public:
|
||||
OpenMenuTest(QMenu* targetMenu)
|
||||
: EditorAutomationTest("Open Menu Test")
|
||||
{
|
||||
AddState(new OpenMenuState(targetMenu));
|
||||
}
|
||||
|
||||
~OpenMenuTest() = default;
|
||||
};
|
||||
|
||||
DefineStateId(WriteToLineEditState);
|
||||
|
||||
class WriteToLineEditState : public StaticIdAutomationState<WriteToLineEditStateId>
|
||||
{
|
||||
public:
|
||||
WriteToLineEditState(QLineEdit* targetEdit, QString targetText)
|
||||
: m_writeToLineEdit(targetEdit, targetText)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
actionRunner.AddAction(&m_writeToLineEdit);
|
||||
}
|
||||
|
||||
private:
|
||||
WriteToLineEditAction m_writeToLineEdit;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationTest to test the general systems. Will write the target string to the target line edit
|
||||
*/
|
||||
class WriteTextToInput
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
WriteTextToInput(QLineEdit* targetEdit, QString targetText)
|
||||
: EditorAutomationTest(QString("Write '%1' To Input").arg(targetText))
|
||||
{
|
||||
AddState(new WriteToLineEditState(targetEdit, targetText));
|
||||
}
|
||||
|
||||
~WriteTextToInput() = default;
|
||||
};
|
||||
}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <qpushbutton.h>
|
||||
|
||||
#include <GraphCanvas/Components/GridBus.h>
|
||||
#include <GraphCanvas/Components/Nodes/Group/NodeGroupBus.h>
|
||||
|
||||
#include <Editor/Source/EditorAutomationTests/GraphCreationTests.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
|
||||
#include <ScriptCanvas/GraphCanvas/MappingBus.h>
|
||||
#include <ScriptCanvas/Core/Node.h>
|
||||
#include <ScriptCanvas/Core/NodeBus.h>
|
||||
#include <ScriptCanvas/Bus/EditorScriptCanvasBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/GraphStates.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
///////////////////////////
|
||||
// CreateGraphHotKeyState
|
||||
///////////////////////////
|
||||
#if !defined(AZ_COMPILER_MSVC)
|
||||
#ifndef VK_CONTROL
|
||||
#define VK_CONTROL 0x11
|
||||
#endif
|
||||
#endif
|
||||
|
||||
CreateGraphTest::CreateGraphHotKeyState::CreateGraphHotKeyState()
|
||||
: m_pressControl(VK_CONTROL)
|
||||
, m_releaseControl(VK_CONTROL)
|
||||
, m_typeN(QChar('n'))
|
||||
, m_longProcessEvents(AZStd::chrono::milliseconds(1000))
|
||||
{
|
||||
}
|
||||
|
||||
void CreateGraphTest::CreateGraphHotKeyState::OnActiveGraphChanged(const AZ::EntityId& graphCanvasId)
|
||||
{
|
||||
m_hotKeyGraphId = graphCanvasId;
|
||||
}
|
||||
|
||||
void CreateGraphTest::CreateGraphHotKeyState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
GraphCanvas::AssetEditorNotificationBus::Handler::BusConnect(ScriptCanvasEditor::AssetEditorId);
|
||||
|
||||
actionRunner.AddAction(&m_pressControl);
|
||||
actionRunner.AddAction(&m_shortProcessEvents);
|
||||
actionRunner.AddAction(&m_typeN);
|
||||
actionRunner.AddAction(&m_longProcessEvents);
|
||||
actionRunner.AddAction(&m_releaseControl);
|
||||
actionRunner.AddAction(&m_shortProcessEvents);
|
||||
|
||||
m_hotKeyGraphId.SetInvalid();
|
||||
}
|
||||
|
||||
void CreateGraphTest::CreateGraphHotKeyState::OnStateActionsComplete()
|
||||
{
|
||||
if (!m_hotKeyGraphId.IsValid())
|
||||
{
|
||||
ReportError("Failed to create graph using hot key");
|
||||
}
|
||||
else
|
||||
{
|
||||
GraphCanvas::GraphId activeGraphCanvasId;
|
||||
ScriptCanvasEditor::GeneralRequestBus::BroadcastResult(activeGraphCanvasId, &ScriptCanvasEditor::GeneralRequests::GetActiveGraphCanvasGraphId);
|
||||
|
||||
if (activeGraphCanvasId != m_hotKeyGraphId)
|
||||
{
|
||||
ReportError("Active graph is not the newly created graph using hotkey.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptCanvas::ScriptCanvasId scriptCanvasId;
|
||||
ScriptCanvasEditor::GeneralRequestBus::BroadcastResult(scriptCanvasId, &ScriptCanvasEditor::GeneralRequests::GetScriptCanvasId, activeGraphCanvasId);
|
||||
|
||||
bool isRuntimeGraph = false;
|
||||
ScriptCanvasEditor::EditorGraphRequestBus::EventResult(isRuntimeGraph, scriptCanvasId, &ScriptCanvasEditor::EditorGraphRequests::IsRuntimeGraph);
|
||||
|
||||
if (!isRuntimeGraph)
|
||||
{
|
||||
ReportError("Failed to create Runtime graph using button");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GraphCanvas::AssetEditorNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// CreateGraphTest
|
||||
////////////////////
|
||||
|
||||
CreateGraphTest::CreateGraphTest()
|
||||
: EditorAutomationTest("Create Graph Test")
|
||||
{
|
||||
SetHasCustomTransitions(true);
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
AddState(new CreateGraphHotKeyState());
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
|
||||
SetInitialStateId<CreateRuntimeGraphStateId>();
|
||||
}
|
||||
|
||||
void CreateGraphTest::OnTestStarting()
|
||||
{
|
||||
m_creationState = CreateRuntimeGraphStateId::StateID();
|
||||
}
|
||||
|
||||
int CreateGraphTest::EvaluateTransition(int stateId)
|
||||
{
|
||||
if (stateId == CreateRuntimeGraphState::StateID()
|
||||
|| stateId == CreateGraphHotKeyState::StateID())
|
||||
{
|
||||
return ForceCloseActiveGraphState::StateID();
|
||||
}
|
||||
else if (stateId == ForceCloseActiveGraphState::StateID())
|
||||
{
|
||||
if (m_creationState == CreateRuntimeGraphStateId::StateID())
|
||||
{
|
||||
m_creationState = CreateGraphHotKeyState::StateID();
|
||||
return m_creationState;
|
||||
}
|
||||
}
|
||||
|
||||
return EditorAutomationState::EXIT_STATE_ID;
|
||||
}
|
||||
|
||||
///////////////////////
|
||||
// CreateFunctionTest
|
||||
///////////////////////
|
||||
|
||||
CreateFunctionTest::CreateFunctionTest()
|
||||
: EditorAutomationTest("Create Function Test")
|
||||
{
|
||||
AddState(new CreateFunctionGraphState());
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QString>
|
||||
#include <QTableView>
|
||||
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/WidgetActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ConnectionActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/CreateElementsActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ElementInteractions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/GraphActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/VariableActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
DefineStateId(CreateGraphTest_CreateGraphHotKeyState);
|
||||
|
||||
/**
|
||||
EditorautomationTest that will test out the ways of creating a runtime graph
|
||||
*/
|
||||
class CreateGraphTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
class CreateGraphHotKeyState
|
||||
: public StaticIdAutomationState<CreateGraphTest_CreateGraphHotKeyStateId>
|
||||
, public GraphCanvas::AssetEditorNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
CreateGraphHotKeyState();
|
||||
~CreateGraphHotKeyState() override = default;
|
||||
|
||||
// AssetEditorNotificationBus
|
||||
void OnActiveGraphChanged(const AZ::EntityId& graphCanvasId) override;
|
||||
////
|
||||
|
||||
protected:
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner);
|
||||
void OnStateActionsComplete();
|
||||
|
||||
private:
|
||||
|
||||
GraphCanvas::GraphId m_hotKeyGraphId;
|
||||
|
||||
KeyPressAction m_pressControl;
|
||||
KeyReleaseAction m_releaseControl;
|
||||
TypeCharAction m_typeN;
|
||||
|
||||
ProcessUserEventsAction m_shortProcessEvents;
|
||||
ProcessUserEventsAction m_longProcessEvents;
|
||||
};
|
||||
|
||||
public:
|
||||
CreateGraphTest();
|
||||
~CreateGraphTest() override = default;
|
||||
|
||||
void OnTestStarting() override;
|
||||
|
||||
protected:
|
||||
|
||||
int EvaluateTransition(int stateId) override;
|
||||
|
||||
private:
|
||||
|
||||
int m_creationState = EditorAutomationState::EXIT_STATE_ID;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will test out the ways of creating a function graph.
|
||||
*/
|
||||
class CreateFunctionTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
CreateFunctionTest();
|
||||
~CreateFunctionTest() override = default;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <qpushbutton.h>
|
||||
|
||||
#include <GraphCanvas/Components/GridBus.h>
|
||||
#include <GraphCanvas/Components/Nodes/Group/NodeGroupBus.h>
|
||||
|
||||
#include <EditorAutomationTests/GroupTests.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
|
||||
#include <ScriptCanvas/GraphCanvas/MappingBus.h>
|
||||
#include <ScriptCanvas/Core/Node.h>
|
||||
#include <ScriptCanvas/Core/NodeBus.h>
|
||||
#include <ScriptCanvas/Bus/EditorScriptCanvasBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ElementInteractions.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/CreateElementsStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/EditorViewStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/GraphStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/UtilityStates.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
////////////////////
|
||||
// CreateGroupTest
|
||||
////////////////////
|
||||
|
||||
CreateGroupTest::CreateGroupTest(CreateGroupAction::CreationType creationType)
|
||||
: EditorAutomationTest(creationType == CreateGroupAction::CreationType::Hotkey ? "Create Group Test" : "Create Group Test With Toolbar")
|
||||
{
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
AddState(new CreateGroupState(ScriptCanvasEditor::AssetEditorId, creationType));
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
// GroupManipulationTest
|
||||
//////////////////////////
|
||||
|
||||
GroupManipulationTest::OffsetPositionByNodeDimension::OffsetPositionByNodeDimension(float horizontalDimension, float verticalDimension, AutomationStateModelId nodeId, AutomationStateModelId positionId)
|
||||
: CustomActionState("OffsetPositionByNodeDimension")
|
||||
, m_horizontalDimension(horizontalDimension)
|
||||
, m_verticalDimension(verticalDimension)
|
||||
, m_nodeId(nodeId)
|
||||
, m_positionId(positionId)
|
||||
{
|
||||
SetStateName(AZStd::string::format("OffsetPosition::%s::ByNodeDimension::%s", m_positionId.c_str(), m_nodeId.c_str()));
|
||||
}
|
||||
|
||||
void GroupManipulationTest::OffsetPositionByNodeDimension::OnCustomAction()
|
||||
{
|
||||
const AZ::EntityId* nodeId = GetStateModel()->GetStateDataAs<AZ::EntityId>(m_nodeId);
|
||||
const AZ::Vector2* position = GetStateModel()->GetStateDataAs<AZ::Vector2>(m_positionId);
|
||||
|
||||
if (nodeId && position)
|
||||
{
|
||||
QGraphicsItem* nodeItem = nullptr;
|
||||
GraphCanvas::VisualRequestBus::EventResult(nodeItem, (*nodeId), &GraphCanvas::VisualRequests::AsGraphicsItem);
|
||||
|
||||
if (nodeItem)
|
||||
{
|
||||
AZ::Vector2 modifiedValue = (*position);
|
||||
|
||||
QRectF sceneBoundingBox = nodeItem->sceneBoundingRect();
|
||||
modifiedValue.SetX(position->GetX() + sceneBoundingBox.width() * m_horizontalDimension);
|
||||
modifiedValue.SetY(position->GetY() + sceneBoundingBox.height() * m_verticalDimension);
|
||||
|
||||
GetStateModel()->SetStateData(m_positionId, modifiedValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nodeId == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid EntityId", m_nodeId.c_str()));
|
||||
}
|
||||
|
||||
if (position == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid Vector2", m_positionId.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GroupManipulationTest::GroupManipulationTest(GraphCanvas::NodePaletteWidget* nodePaletteWidget)
|
||||
: EditorAutomationTest("Group Manipulation Test")
|
||||
{
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId groupId = "GroupId";
|
||||
|
||||
AddState(new CreateGroupState(ScriptCanvasEditor::AssetEditorId, CreateGroupAction::CreationType::Hotkey, groupId));
|
||||
|
||||
AutomationStateModelId groupCenter = "GroupCenter";
|
||||
|
||||
{
|
||||
FindPositionOffsets groupOffsets;
|
||||
groupOffsets.m_horizontalPosition = 0.5f;
|
||||
groupOffsets.m_verticalPosition = 0.5f;
|
||||
|
||||
AddState(new FindGroupPosition(groupId, groupCenter, groupOffsets));
|
||||
}
|
||||
|
||||
AutomationStateModelId buildStringNode = "BuildStringNode";
|
||||
AddState(new CreateNodeFromContextMenuState("Build String", CreateNodeFromContextMenuState::CreationType::ScenePosition, groupCenter, buildStringNode));
|
||||
|
||||
AddState(new CheckIsInGroup(buildStringNode, groupId, true, "CheckGroupStatus::ContextMenuCreation"));
|
||||
|
||||
AutomationStateModelId moveOutSceneDragStart = "MoveOutSceneDragStart";
|
||||
AutomationStateModelId moveOutSceneDragEnd = "MoveOutSceneDragEnd";
|
||||
|
||||
{
|
||||
FindPositionOffsets nodeOffsets;
|
||||
nodeOffsets.m_horizontalPosition = 0.5f;
|
||||
nodeOffsets.m_verticalPosition = 0.0f;
|
||||
nodeOffsets.m_verticalOffset = 10;
|
||||
|
||||
AddState(new FindNodePosition(buildStringNode, moveOutSceneDragStart, nodeOffsets));
|
||||
AddState(new FindNodePosition(buildStringNode, moveOutSceneDragEnd, nodeOffsets));
|
||||
}
|
||||
|
||||
AddState(new OffsetPositionByNodeDimension(1.0f, 0.0f, groupId, moveOutSceneDragEnd));
|
||||
AddState(new OffsetPositionByNodeDimension(1.0f, 0.0f, buildStringNode, moveOutSceneDragEnd));
|
||||
|
||||
AddState(new SceneMouseDragState(moveOutSceneDragStart, moveOutSceneDragEnd));
|
||||
AddState(new CheckIsInGroup(buildStringNode, groupId, false, "CheckGroupStatus::DragOutOfGroup"));
|
||||
|
||||
AutomationStateModelId envelopDragStart = "EnvelopDragStart";
|
||||
AutomationStateModelId envelopDragEnd = "EnvelopDragEnd";
|
||||
|
||||
{
|
||||
FindPositionOffsets groupOffsets;
|
||||
groupOffsets.m_horizontalPosition = 1.0f;
|
||||
groupOffsets.m_horizontalOffset = -5;
|
||||
groupOffsets.m_verticalPosition = 0.5f;
|
||||
|
||||
AddState(new FindGroupPosition(groupId, envelopDragStart, groupOffsets));
|
||||
AddState(new FindGroupPosition(groupId, envelopDragEnd, groupOffsets));
|
||||
}
|
||||
|
||||
AddState(new OffsetPositionByNodeDimension(1.0f, 0.0f, groupId, envelopDragEnd));
|
||||
AddState(new OffsetPositionByNodeDimension(1.0f, 0.0f, buildStringNode, envelopDragEnd));
|
||||
|
||||
AddState(new SceneMouseDragState(envelopDragStart, envelopDragEnd));
|
||||
AddState(new CheckIsInGroup(buildStringNode, groupId, true, "CheckGroupStatus::ResizeToInclude"));
|
||||
|
||||
AddState(new SceneMouseDragState(envelopDragEnd, envelopDragStart));
|
||||
AddState(new CheckIsInGroup(buildStringNode, groupId, false, "CheckGroupStatus::ResizeToExclude"));
|
||||
|
||||
AddState(new SceneMouseDragState(moveOutSceneDragEnd, moveOutSceneDragStart));
|
||||
AddState(new CheckIsInGroup(buildStringNode, groupId, true, "CheckGroupStatus::DragIntoGroup"));
|
||||
|
||||
AutomationStateModelId proposalEndpoint = "ProposalEndpoint";
|
||||
AddState(new FindEndpointOfTypeState(buildStringNode, proposalEndpoint, GraphCanvas::ConnectionType::CT_Output, GraphCanvas::SlotTypes::ExecutionSlot));
|
||||
|
||||
AutomationStateModelId printNode = "PrintNode";
|
||||
AddState(new CreateNodeFromProposalState("Print", proposalEndpoint, envelopDragStart, printNode));
|
||||
|
||||
AddState(new CheckIsInGroup(printNode, groupId, true, "CheckGroupStatus::PoposalCreation"));
|
||||
|
||||
AutomationStateModelId onGraphStartNode = "OnGraphStartNode";
|
||||
AddState(new CreateNodeFromPaletteState(nodePaletteWidget, "On Graph Start", CreateNodeFromPaletteState::CreationType::ScenePosition, groupCenter, onGraphStartNode));
|
||||
|
||||
AddState(new CheckIsInGroup(onGraphStartNode, groupId, true, "CheckGroupStatus::PaletteDrop"));
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QString>
|
||||
#include <QTableView>
|
||||
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/WidgetActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ConnectionActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/CreateElementsActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ElementInteractions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/GraphActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/VariableActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorautomationTest that will test out various methods creating a group
|
||||
*/
|
||||
class CreateGroupTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
CreateGroupTest(CreateGroupAction::CreationType creationType = CreateGroupAction::CreationType::Hotkey);
|
||||
~CreateGroupTest() override = default;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will test out how elements are added/removed from groups in several situations(Addition to group via context menu, drag/drop, connection proposal, or resizing. Removal from group through movement and resizing).
|
||||
*/
|
||||
class GroupManipulationTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
private:
|
||||
|
||||
class OffsetPositionByNodeDimension
|
||||
: public CustomActionState
|
||||
{
|
||||
public:
|
||||
// -1 to 1 will decide how much and which direction we manipulate the specified value by our width/height.
|
||||
OffsetPositionByNodeDimension(float horizontalDimension, float verticalDimension, AutomationStateModelId nodeId, AutomationStateModelId position);
|
||||
~OffsetPositionByNodeDimension() override = default;
|
||||
|
||||
void OnCustomAction() override;
|
||||
|
||||
private:
|
||||
|
||||
float m_horizontalDimension = 0.0f;
|
||||
float m_verticalDimension = 0.0f;
|
||||
|
||||
AutomationStateModelId m_nodeId;
|
||||
AutomationStateModelId m_positionId;
|
||||
};
|
||||
|
||||
public:
|
||||
GroupManipulationTest(GraphCanvas::NodePaletteWidget* nodePaletteWidget);
|
||||
~GroupManipulationTest() override = default;
|
||||
};
|
||||
}
|
||||
+433
@@ -0,0 +1,433 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <qpushbutton.h>
|
||||
|
||||
#include <GraphCanvas/Components/GridBus.h>
|
||||
#include <GraphCanvas/Components/Nodes/Group/NodeGroupBus.h>
|
||||
|
||||
#include <EditorAutomationTests/InteractionTests.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
|
||||
#include <ScriptCanvas/GraphCanvas/MappingBus.h>
|
||||
#include <ScriptCanvas/Core/Node.h>
|
||||
#include <ScriptCanvas/Core/NodeBus.h>
|
||||
#include <ScriptCanvas/Bus/EditorScriptCanvasBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/EditorViewStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/ElementInteractionStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/GraphStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/UtilityStates.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
///////////////////////
|
||||
// AltClickDeleteTest
|
||||
///////////////////////
|
||||
|
||||
AltClickDeleteTest::AltClickDeleteTest()
|
||||
: EditorAutomationTest("Alt Click Deletion Test")
|
||||
{
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId onGraphStartTargetPointId = "OnGraphStartScenePoint";
|
||||
AutomationStateModelId onGraphStartId = "OnGraphStartId";
|
||||
|
||||
AddState(new FindViewCenterState(onGraphStartTargetPointId));
|
||||
AddState(new CreateNodeFromContextMenuState("On Graph Start", CreateNodeFromContextMenuState::CreationType::ScenePosition, onGraphStartTargetPointId, onGraphStartId));
|
||||
|
||||
AutomationStateModelId onGraphStartEndpoint = "OnGraphStart::ExecutionEndpoint";
|
||||
|
||||
AddState(new FindEndpointOfTypeState(onGraphStartId, onGraphStartEndpoint, GraphCanvas::CT_Output, GraphCanvas::SlotTypes::ExecutionSlot));
|
||||
|
||||
AutomationStateModelId buildStringNodeId = "BuildStringId";
|
||||
AddState(new CreateNodeFromProposalState("Build String", onGraphStartEndpoint, "", buildStringNodeId));
|
||||
|
||||
AutomationStateModelId buildStringEndpoint = "BuildString::ExecutionEndpoint";
|
||||
|
||||
AddState(new FindEndpointOfTypeState(buildStringNodeId, buildStringEndpoint, GraphCanvas::CT_Output, GraphCanvas::SlotTypes::ExecutionSlot));
|
||||
|
||||
AutomationStateModelId printNodeId = "PrintNodeId";
|
||||
AddState(new CreateNodeFromProposalState("Print", buildStringEndpoint, "", printNodeId));
|
||||
|
||||
AddState(new AltClickSceneElementState(buildStringNodeId));
|
||||
|
||||
AutomationStateModelId altClickConnectionTarget = "ConnectionTarget";
|
||||
AddState(new GetLastConnection(onGraphStartEndpoint, altClickConnectionTarget));
|
||||
|
||||
AddState(new AltClickSceneElementState(altClickConnectionTarget));
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// CutCopyPasteDuplicateTest
|
||||
//////////////////////////////
|
||||
|
||||
CutCopyPasteDuplicateTest::CheckpointState::CheckpointState(AZStd::string checkPoint)
|
||||
: CustomActionState(checkPoint.c_str())
|
||||
{
|
||||
}
|
||||
|
||||
CutCopyPasteDuplicateTest::CutCopyPasteDuplicateTest(QString nodeName)
|
||||
: EditorAutomationTest(QString("Cut/Copy/Paste/Duplicate %1 Test").arg(nodeName))
|
||||
, m_originalNodeId("OriginalNodeId")
|
||||
{
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId viewCenter = "ViewCenter";
|
||||
AddState(new FindViewCenterState(viewCenter));
|
||||
|
||||
m_createNodeState = new CreateNodeFromContextMenuState(nodeName, CreateNodeFromContextMenuState::CreationType::ScenePosition, viewCenter, m_originalNodeId);
|
||||
AddState(m_createNodeState);
|
||||
|
||||
AddState(new SelectSceneElementState(m_originalNodeId));
|
||||
|
||||
AddState(new TriggerHotKey(QChar('x'), "CutOriginal"));
|
||||
AddState(new TriggerHotKey(QChar('v'), "PasteOriginal"));
|
||||
|
||||
m_cutPasteCheckpoint = new CheckpointState("Confirm Cut/Paste");
|
||||
AddState(m_cutPasteCheckpoint);
|
||||
|
||||
AddState(new TriggerHotKey(QChar('c'), "CopyOriginal"));
|
||||
AddState(new TriggerHotKey(QChar('v'), "PasteCopied"));
|
||||
|
||||
m_copyPasteCheckpoint = new CheckpointState("Confirm Copy/Paste");
|
||||
AddState(m_copyPasteCheckpoint);
|
||||
|
||||
AddState(new TriggerHotKey(QChar('c'), "CopyCopied"));
|
||||
AddState(new TriggerHotKey(QChar('v'), "PasteCopiedCopied"));
|
||||
|
||||
m_copyPasteCopyCheckpoint = new CheckpointState("Confirm Copy/Paste for Copy");
|
||||
AddState(m_copyPasteCopyCheckpoint);
|
||||
|
||||
AddState(new TriggerHotKey(QChar('d'), "Duplicate"));
|
||||
|
||||
m_duplicateCheckpoint = new CheckpointState("Confirm Duplication");
|
||||
AddState(m_duplicateCheckpoint);
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
void CutCopyPasteDuplicateTest::OnNodeAdded(const AZ::EntityId& nodeId, bool)
|
||||
{
|
||||
m_createdSet.insert(nodeId);
|
||||
}
|
||||
|
||||
void CutCopyPasteDuplicateTest::OnNodeRemoved(const AZ::EntityId& nodeId)
|
||||
{
|
||||
if (nodeId == m_removalTarget)
|
||||
{
|
||||
m_removalTarget.SetInvalid();
|
||||
}
|
||||
}
|
||||
|
||||
void CutCopyPasteDuplicateTest::OnStateComplete(int stateId)
|
||||
{
|
||||
if (stateId == CreateRuntimeGraphStateId::StateID())
|
||||
{
|
||||
const GraphCanvas::GraphId* graphId = GetStateDataAs<GraphCanvas::GraphId>(StateModelIds::GraphCanvasId);
|
||||
|
||||
if (graphId)
|
||||
{
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusConnect((*graphId));
|
||||
}
|
||||
}
|
||||
else if (stateId == m_createNodeState->GetStateId())
|
||||
{
|
||||
const GraphCanvas::NodeId* nodeId = GetStateDataAs<GraphCanvas::GraphId>(m_originalNodeId);
|
||||
|
||||
if (nodeId)
|
||||
{
|
||||
m_removalTarget = (*nodeId);
|
||||
m_createdSet.clear();
|
||||
}
|
||||
}
|
||||
else if (stateId == m_cutPasteCheckpoint->GetStateId())
|
||||
{
|
||||
if (m_removalTarget.IsValid())
|
||||
{
|
||||
AddError("Cut failed to remove original element from the scene.");
|
||||
}
|
||||
else if (m_createdSet.empty())
|
||||
{
|
||||
AddError("Paste failed to add element to the scene.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessCreationSet();
|
||||
}
|
||||
}
|
||||
else if (stateId == m_copyPasteCheckpoint->GetStateId()
|
||||
|| stateId == m_copyPasteCopyCheckpoint->GetStateId())
|
||||
{
|
||||
if (m_createdSet.empty())
|
||||
{
|
||||
AddError("Paste failed to add element to the scene.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessCreationSet();
|
||||
}
|
||||
}
|
||||
else if (stateId == stateId == m_duplicateCheckpoint->GetStateId())
|
||||
{
|
||||
if (m_createdSet.empty())
|
||||
{
|
||||
AddError("Duplicate failed to add element to the scene.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessCreationSet();
|
||||
}
|
||||
}
|
||||
else if (stateId == ForceCloseActiveGraphStateId::StateID())
|
||||
{
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void CutCopyPasteDuplicateTest::ProcessCreationSet()
|
||||
{
|
||||
AZ::EntityId testId;
|
||||
|
||||
for (GraphCanvas::NodeId nodeId : m_createdSet)
|
||||
{
|
||||
if (GraphCanvas::GraphUtils::IsNodeWrapped(nodeId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
testId = nodeId;
|
||||
break;
|
||||
}
|
||||
|
||||
m_createdSet.clear();
|
||||
|
||||
bool isSelected = false;
|
||||
GraphCanvas::SceneMemberUIRequestBus::EventResult(isSelected, testId, &GraphCanvas::SceneMemberUIRequests::IsSelected);
|
||||
|
||||
if (!isSelected)
|
||||
{
|
||||
AddError("Pasted node is not selected by default.");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
bool CutCopyPasteDuplicateTest::TransitionToState(int state)
|
||||
{
|
||||
if (state == CutOriginalNode)
|
||||
{
|
||||
delete m_selectElement;
|
||||
m_selectElement = aznew SelectSceneElementAction(m_target);
|
||||
|
||||
m_removalTarget = m_target;
|
||||
|
||||
m_actionRunner.AddAction(m_selectElement);
|
||||
m_actionRunner.AddAction(&m_pressCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_typeX);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_releaseCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
else if (state == PasteOriginalNode)
|
||||
{
|
||||
m_actionRunner.AddAction(&m_pressCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_typeV);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_releaseCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
else if (state == CopyPasteOriginalNodeState)
|
||||
{
|
||||
m_actionRunner.AddAction(&m_pressCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_typeC);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_typeV);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_releaseCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
else if (state == CopyPasteDuplicatedNodeState)
|
||||
{
|
||||
m_actionRunner.AddAction(&m_pressCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_typeC);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_typeV);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_releaseCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
else if (state == DuplicateNodeState)
|
||||
{
|
||||
m_actionRunner.AddAction(&m_pressCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_typeD);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_releaseCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
else if (state == ForceCloseGraphState)
|
||||
{
|
||||
m_actionRunner.AddAction(&m_forceCloseGraphAction);
|
||||
}
|
||||
|
||||
return m_actionRunner.HasActions();
|
||||
}
|
||||
|
||||
void CutCopyPasteDuplicateTest::OnTestComplete()
|
||||
{
|
||||
delete m_createFromContextMenu;
|
||||
m_createFromContextMenu = nullptr;
|
||||
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void CutCopyPasteDuplicateTest::OnStateComplete(int state)
|
||||
{
|
||||
if (state == CreateGraphState)
|
||||
{
|
||||
m_graphId = m_createNewGraphAction.GetGraphId();
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusConnect(m_graphId);
|
||||
}
|
||||
else if (state == CreateNodeState)
|
||||
{
|
||||
m_target = m_createFromContextMenu->GetCreatedNodeId();
|
||||
m_createdSet.clear();
|
||||
}
|
||||
else if (state == CutOriginalNode)
|
||||
{
|
||||
if (m_removalTarget.IsValid())
|
||||
{
|
||||
AddError(QString("Failed to cut %1").arg(m_nodeName).toUtf8().data());
|
||||
}
|
||||
}
|
||||
else if (state == PasteOriginalNode)
|
||||
{
|
||||
if (m_createdSet.empty())
|
||||
{
|
||||
AddError(QString("Failed to cut and paste original %1").arg(m_nodeName).toUtf8().data());
|
||||
}
|
||||
else
|
||||
{
|
||||
for (GraphCanvas::NodeId nodeId : m_createdSet)
|
||||
{
|
||||
if (GraphCanvas::GraphUtils::IsNodeWrapped(nodeId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
m_target = nodeId;
|
||||
break;
|
||||
}
|
||||
|
||||
m_createdSet.clear();
|
||||
|
||||
bool isSelected = false;
|
||||
GraphCanvas::SceneMemberUIRequestBus::EventResult(isSelected, m_target, &GraphCanvas::SceneMemberUIRequests::IsSelected);
|
||||
|
||||
if (!isSelected)
|
||||
{
|
||||
AddError("Pasted node is not selected by default.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (state == CopyPasteOriginalNodeState)
|
||||
{
|
||||
if (m_createdSet.empty())
|
||||
{
|
||||
AddError(QString("Failed to copy and paste original %1").arg(m_nodeName).toUtf8().data());
|
||||
}
|
||||
else
|
||||
{
|
||||
for (GraphCanvas::NodeId nodeId : m_createdSet)
|
||||
{
|
||||
if (GraphCanvas::GraphUtils::IsNodeWrapped(nodeId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
m_target = nodeId;
|
||||
break;
|
||||
}
|
||||
|
||||
m_createdSet.clear();
|
||||
|
||||
bool isSelected = false;
|
||||
GraphCanvas::SceneMemberUIRequestBus::EventResult(isSelected, m_target, &GraphCanvas::SceneMemberUIRequests::IsSelected);
|
||||
|
||||
if (!isSelected)
|
||||
{
|
||||
AddError("Pasted node is not selected by default.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (state == CopyPasteDuplicatedNodeState)
|
||||
{
|
||||
if (m_createdSet.empty())
|
||||
{
|
||||
AddError(QString("Failed to copy and paste duplicated %1").arg(m_nodeName).toUtf8().data());
|
||||
}
|
||||
else
|
||||
{
|
||||
for (GraphCanvas::NodeId nodeId : m_createdSet)
|
||||
{
|
||||
if (GraphCanvas::GraphUtils::IsNodeWrapped(nodeId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
m_target = nodeId;
|
||||
break;
|
||||
}
|
||||
|
||||
m_createdSet.clear();
|
||||
|
||||
bool isSelected = false;
|
||||
GraphCanvas::SceneMemberUIRequestBus::EventResult(isSelected, m_target, &GraphCanvas::SceneMemberUIRequests::IsSelected);
|
||||
|
||||
if (!isSelected)
|
||||
{
|
||||
AddError("Pasted node is not selected by default.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (state == DuplicateNodeState)
|
||||
{
|
||||
if (m_createdSet.empty())
|
||||
{
|
||||
AddError(QString("Failed to duplicate %1").arg(m_nodeName).toUtf8().data());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_createdSet.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CutCopyPasteDuplicateTest::CleanupAfterErrorState()
|
||||
{
|
||||
if (m_createNewGraphAction.GetGraphId().IsValid())
|
||||
{
|
||||
m_actionRunner.AddAction(&m_forceCloseGraphAction);
|
||||
}
|
||||
|
||||
return m_actionRunner.HasActions();
|
||||
}
|
||||
*/
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QString>
|
||||
#include <QTableView>
|
||||
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/CreateElementsStates.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorautomationTest that will test out the AltClick to delete elements functionality for nodes, connected nodes, and connections
|
||||
*/
|
||||
class AltClickDeleteTest
|
||||
: public EditorAutomationTest
|
||||
, public GraphCanvas::SceneNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AltClickDeleteTest();
|
||||
~AltClickDeleteTest() override = default;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will test out the cut/copy/paste functions
|
||||
*/
|
||||
class CutCopyPasteDuplicateTest
|
||||
: public EditorAutomationTest
|
||||
, public GraphCanvas::SceneNotificationBus::Handler
|
||||
{
|
||||
class CheckpointState
|
||||
: public CustomActionState
|
||||
{
|
||||
public:
|
||||
CheckpointState(AZStd::string checkpoint);
|
||||
~CheckpointState() override = default;
|
||||
|
||||
void OnCustomAction() override {}
|
||||
};
|
||||
|
||||
public:
|
||||
CutCopyPasteDuplicateTest(QString nodeName);
|
||||
~CutCopyPasteDuplicateTest() override = default;
|
||||
|
||||
// SceneNotificationBus
|
||||
void OnNodeAdded(const AZ::EntityId& nodeId, bool isPaste) override;
|
||||
void OnNodeRemoved(const AZ::EntityId& nodeId) override;
|
||||
///
|
||||
|
||||
// EditorAutomationTests
|
||||
void OnStateComplete(int stateId) override;
|
||||
////
|
||||
|
||||
private:
|
||||
|
||||
void ProcessCreationSet();
|
||||
|
||||
AutomationStateModelId m_originalNodeId;
|
||||
|
||||
GraphCanvas::NodeId m_removalTarget;
|
||||
AZStd::unordered_set< GraphCanvas::NodeId > m_createdSet;
|
||||
|
||||
CreateNodeFromContextMenuState* m_createNodeState = nullptr;
|
||||
|
||||
CheckpointState* m_cutPasteCheckpoint = nullptr;
|
||||
CheckpointState* m_copyPasteCheckpoint = nullptr;
|
||||
CheckpointState* m_copyPasteCopyCheckpoint = nullptr;
|
||||
CheckpointState* m_duplicateCheckpoint = nullptr;
|
||||
};
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <qpushbutton.h>
|
||||
|
||||
#include <GraphCanvas/Components/GridBus.h>
|
||||
#include <GraphCanvas/Components/Nodes/Group/NodeGroupBus.h>
|
||||
|
||||
#include <EditorAutomationTests/NodeCreationTests.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
|
||||
#include <ScriptCanvas/GraphCanvas/MappingBus.h>
|
||||
#include <ScriptCanvas/Core/Node.h>
|
||||
#include <ScriptCanvas/Core/NodeBus.h>
|
||||
#include <ScriptCanvas/Bus/EditorScriptCanvasBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ElementInteractions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
///////////////////////
|
||||
// CreateCategoryTest
|
||||
///////////////////////
|
||||
|
||||
CreateCategoryTest::CreateCategoryTest(AZStd::string categoryString, GraphCanvas::NodePaletteWidget* nodePaletteWidget)
|
||||
: EditorAutomationTest(QString("Create %1 Category from Palette").arg(categoryString.c_str()))
|
||||
{
|
||||
AutomationStateModelId categoryId = "CategoryId";
|
||||
SetStateData(categoryId, categoryString);
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId viewCenterId = "ViewCenterId";
|
||||
AddState(new FindViewCenterState(viewCenterId));
|
||||
|
||||
AddState(new CreateCategoryFromNodePaletteState(nodePaletteWidget, categoryId, viewCenterId));
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
// CreateExecutionSplicedNodeTest
|
||||
///////////////////////////////////
|
||||
|
||||
CreateExecutionSplicedNodeTest::CreateExecutionSplicedNodeTest(QString nodeName)
|
||||
: EditorAutomationTest(QString("Create %1 via Connection Splice").arg(nodeName))
|
||||
{
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId onGraphStartTargetPointId = "OnGraphStartScenePoint";
|
||||
AutomationStateModelId onGraphStartId = "OnGraphStartId";
|
||||
|
||||
AddState(new FindViewCenterState(onGraphStartTargetPointId));
|
||||
AddState(new CreateNodeFromContextMenuState("On Graph Start", CreateNodeFromContextMenuState::CreationType::ScenePosition, onGraphStartTargetPointId, onGraphStartId));
|
||||
|
||||
AutomationStateModelId onGraphStartEndpoint = "OnGraphStart::ExecutionEndpoint";
|
||||
|
||||
AddState(new FindEndpointOfTypeState(onGraphStartId, onGraphStartEndpoint, GraphCanvas::CT_Output, GraphCanvas::SlotTypes::ExecutionSlot));
|
||||
|
||||
AutomationStateModelId printNodeId = "PrintId";
|
||||
AutomationStateModelId spliceTargetId = "SpliceTargetId";
|
||||
AddState(new CreateNodeFromProposalState("Print", onGraphStartEndpoint, "", printNodeId, spliceTargetId));
|
||||
|
||||
AddState(new CreateNodeFromContextMenuState(nodeName, CreateNodeFromContextMenuState::CreationType::Splice, spliceTargetId));
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
// CreateExecutionSplicedNodeTest
|
||||
///////////////////////////////////
|
||||
|
||||
CreateDragDropExecutionSpliceNodeTest::CreateDragDropExecutionSpliceNodeTest(GraphCanvas::NodePaletteWidget* nodePaletteWidget, QString nodeName)
|
||||
: EditorAutomationTest(QString("Create %1 via Dropped Connection Splice").arg(nodeName))
|
||||
{
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId onGraphStartTargetPointId = "OnGraphStartScenePoint";
|
||||
AutomationStateModelId onGraphStartId = "OnGraphStartId";
|
||||
|
||||
AddState(new FindViewCenterState(onGraphStartTargetPointId));
|
||||
AddState(new CreateNodeFromContextMenuState("On Graph Start", CreateNodeFromContextMenuState::CreationType::ScenePosition, onGraphStartTargetPointId, onGraphStartId));
|
||||
|
||||
AutomationStateModelId onGraphStartEndpoint = "OnGraphStart::ExecutionEndpoint";
|
||||
|
||||
AddState(new FindEndpointOfTypeState(onGraphStartId, onGraphStartEndpoint, GraphCanvas::CT_Output, GraphCanvas::SlotTypes::ExecutionSlot));
|
||||
|
||||
AutomationStateModelId printNodeId = "PrintId";
|
||||
AutomationStateModelId spliceTargetId = "SpliceTargetId";
|
||||
AddState(new CreateNodeFromProposalState("Print", onGraphStartEndpoint, "", printNodeId, spliceTargetId));
|
||||
|
||||
AddState(new CreateNodeFromPaletteState(nodePaletteWidget, nodeName, CreateNodeFromPaletteState::CreationType::Splice, spliceTargetId));
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
}
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QString>
|
||||
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/ConnectionStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/CreateElementsStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/EditorViewStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/ElementInteractionStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/GraphStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/UtilityStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/VariableStates.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorautomationTest that creates a node from the node palette using drag/drop
|
||||
*/
|
||||
class CreateNodeFromPaletteTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
|
||||
CreateNodeFromPaletteTest(const AZStd::string& nodeName, GraphCanvas::NodePaletteWidget* paletteWidget)
|
||||
: EditorAutomationTest(AZStd::string::format("Create %s from Node Palette", nodeName.c_str()).c_str())
|
||||
{
|
||||
AutomationStateModelId viewCenterModelId = "ViewCenter";
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
AddState(new FindViewCenterState(viewCenterModelId));
|
||||
AddState(new CreateNodeFromPaletteState(paletteWidget, nodeName.c_str(), CreateNodeFromPaletteState::CreationType::ScenePosition, viewCenterModelId));
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that creates a node from the context menu
|
||||
*/
|
||||
class CreateNodeFromContextMenuTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
|
||||
CreateNodeFromContextMenuTest(const AZStd::string& nodeName)
|
||||
: EditorAutomationTest(AZStd::string::format("Create %s from Context Menu", nodeName.c_str()).c_str())
|
||||
{
|
||||
AutomationStateModelId viewCenterModelId = "ViewCenter";
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
AddState(new FindViewCenterState(viewCenterModelId));
|
||||
AddState(new CreateNodeFromContextMenuState(nodeName.c_str(), CreateNodeFromContextMenuState::CreationType::ScenePosition, viewCenterModelId));
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that creates a simple graph from the node palette and coupling.
|
||||
*/
|
||||
class CreateHelloWorldFromPalette
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
|
||||
CreateHelloWorldFromPalette(GraphCanvas::NodePaletteWidget* paletteWidget)
|
||||
: EditorAutomationTest("Create Hello World From Palette")
|
||||
{
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId onGraphStartTargetPointId = "OnGraphStartScenePoint";
|
||||
AutomationStateModelId onGraphStartId = "OnGraphStartId";
|
||||
|
||||
AddState(new FindViewCenterState(onGraphStartTargetPointId));
|
||||
AddState(new CreateNodeFromPaletteState(paletteWidget, "On Graph Start", CreateNodeFromPaletteState::CreationType::ScenePosition, onGraphStartTargetPointId, onGraphStartId));
|
||||
|
||||
AutomationStateModelId printTargetPoint = "PrintScenePoint";
|
||||
AutomationStateModelId printId = "PrintId";
|
||||
|
||||
FindPositionOffsets offsets;
|
||||
offsets.m_horizontalPosition = 1;
|
||||
offsets.m_horizontalOffset = 50;
|
||||
|
||||
AddState(new FindNodePosition(onGraphStartId, printTargetPoint, offsets));
|
||||
AddState(new CreateNodeFromPaletteState(paletteWidget, "Print", CreateNodeFromPaletteState::CreationType::ScenePosition, printTargetPoint, printId));
|
||||
|
||||
AddState(new CoupleNodesState(onGraphStartId, GraphCanvas::ConnectionType::CT_Output, printId));
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that creates a simple graph from the context menu and coupling.
|
||||
*/
|
||||
class CreateHelloWorldFromContextMenu
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
|
||||
CreateHelloWorldFromContextMenu()
|
||||
: EditorAutomationTest("Create Hello World From Context Menu")
|
||||
{
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId onGraphStartTargetPointId = "OnGraphStartScenePoint";
|
||||
AutomationStateModelId onGraphStartId = "OnGraphStartId";
|
||||
|
||||
AddState(new FindViewCenterState(onGraphStartTargetPointId));
|
||||
AddState(new CreateNodeFromContextMenuState("On Graph Start", CreateNodeFromContextMenuState::CreationType::ScenePosition, onGraphStartTargetPointId, onGraphStartId));
|
||||
|
||||
AutomationStateModelId printTargetPoint = "PrintScenePoint";
|
||||
AutomationStateModelId printId = "PrintId";
|
||||
|
||||
FindPositionOffsets offsets;
|
||||
offsets.m_horizontalPosition = 1;
|
||||
offsets.m_horizontalOffset = 50;
|
||||
|
||||
AddState(new FindNodePosition(onGraphStartId, printTargetPoint, offsets));
|
||||
AddState(new CreateNodeFromContextMenuState("Print", CreateNodeFromContextMenuState::CreationType::ScenePosition, printTargetPoint, printId));
|
||||
|
||||
AddState(new CoupleNodesState(onGraphStartId, GraphCanvas::ConnectionType::CT_Output, printId));
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that creates all of the nodes under the specified category
|
||||
*/
|
||||
class CreateCategoryTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
CreateCategoryTest(AZStd::string categoryString, GraphCanvas::NodePaletteWidget* nodePaletteWidget);
|
||||
~CreateCategoryTest() override = default;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will splice the specified node onto a simple graph using execution connections and the context menu
|
||||
*/
|
||||
class CreateExecutionSplicedNodeTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
CreateExecutionSplicedNodeTest(QString nodeName);
|
||||
~CreateExecutionSplicedNodeTest() override = default;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will splice the specified node onto a simple graph using execution connections and dragging/dropping
|
||||
*/
|
||||
class CreateDragDropExecutionSpliceNodeTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
CreateDragDropExecutionSpliceNodeTest(GraphCanvas::NodePaletteWidget* nodePaletteWidget, QString nodeName);
|
||||
~CreateDragDropExecutionSpliceNodeTest() override = default;
|
||||
};
|
||||
}
|
||||
+886
@@ -0,0 +1,886 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <qpushbutton.h>
|
||||
|
||||
#include <GraphCanvas/Components/GridBus.h>
|
||||
#include <GraphCanvas/Components/Nodes/Group/NodeGroupBus.h>
|
||||
|
||||
#include <EditorAutomationTests/VariableTests.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
|
||||
#include <ScriptCanvas/GraphCanvas/MappingBus.h>
|
||||
#include <ScriptCanvas/Core/Node.h>
|
||||
#include <ScriptCanvas/Core/NodeBus.h>
|
||||
#include <ScriptCanvas/Bus/EditorScriptCanvasBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ElementInteractions.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/EditorViewStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/ElementInteractionStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/GraphStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/UtilityStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/VariableStates.h>
|
||||
|
||||
#if !defined(AZ_COMPILER_MSVC)
|
||||
#ifndef VK_RETURN
|
||||
#define VK_RETURN 0x0D
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
///////////////////////////////
|
||||
// ManuallyCreateVariableTest
|
||||
///////////////////////////////
|
||||
|
||||
AZStd::string GetModifierDescription(CreateVariableAction::CreationType creationType)
|
||||
{
|
||||
AZStd::string modifierDescription;
|
||||
|
||||
switch (creationType)
|
||||
{
|
||||
case CreateVariableAction::CreationType::AutoComplete:
|
||||
break;
|
||||
case CreateVariableAction::CreationType::Palette:
|
||||
modifierDescription = "From Palette";
|
||||
break;
|
||||
case CreateVariableAction::CreationType::Programmatic:
|
||||
modifierDescription = "Programmatically";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return modifierDescription;
|
||||
}
|
||||
|
||||
ManuallyCreateVariableTest::ManuallyCreateVariableTest(ScriptCanvas::Data::Type dataType, CreateVariableAction::CreationType creationType, AZStd::string variableName)
|
||||
: EditorAutomationTest(QString("Create %1 %2").arg(ScriptCanvas::Data::GetName(dataType).c_str()).arg(GetModifierDescription(creationType).c_str()))
|
||||
{
|
||||
AutomationStateModelId variableTypeId = "VariableDataType";
|
||||
SetStateData(variableTypeId, dataType);
|
||||
|
||||
AutomationStateModelId variableNameId = "VariableName";
|
||||
SetStateData(variableNameId, variableName);
|
||||
|
||||
constexpr bool errorOnNameMismatch = true;
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
AddState(new CreateVariableState(variableTypeId, variableNameId, errorOnNameMismatch, creationType));
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
// CreateNamedVariableTest
|
||||
////////////////////////////
|
||||
|
||||
CreateNamedVariableTest::CreateNamedVariableTest(ScriptCanvas::Data::Type dataType, AZStd::string name, CreateVariableAction::CreationType creationType)
|
||||
: ManuallyCreateVariableTest(dataType, creationType, name)
|
||||
{
|
||||
SetTestName(AZStd::string::format("Create %s with name %s", ScriptCanvas::Data::GetName(dataType).c_str(), name.c_str()).c_str());
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// DuplicateVariableNameTest
|
||||
//////////////////////////////
|
||||
|
||||
DuplicateVariableNameTest::CheckVariableForNameMismatchState::CheckVariableForNameMismatchState(AutomationStateModelId nameId, AutomationStateModelId variableId)
|
||||
: CustomActionState("CheckVariableForNameMismatchState")
|
||||
, m_nameId(nameId)
|
||||
, m_variableId(variableId)
|
||||
{
|
||||
SetStateName("CheckVariableForNameMismatchState");
|
||||
}
|
||||
|
||||
void DuplicateVariableNameTest::CheckVariableForNameMismatchState::OnCustomAction()
|
||||
{
|
||||
const ScriptCanvas::ScriptCanvasId* scriptCanvasId = GetStateModel()->GetStateDataAs<ScriptCanvas::ScriptCanvasId>(StateModelIds::ScriptCanvasId);
|
||||
const ScriptCanvas::VariableId* variableId = GetStateModel()->GetStateDataAs<ScriptCanvas::VariableId>(m_variableId);
|
||||
const AZStd::string* variableName = GetStateModel()->GetStateDataAs<AZStd::string>(m_nameId);
|
||||
|
||||
if (variableId && scriptCanvasId && variableName)
|
||||
{
|
||||
ScriptCanvas::GraphVariable* graphVariable = nullptr;
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(graphVariable, (*scriptCanvasId), &ScriptCanvas::GraphVariableManagerRequests::FindVariableById, (*variableId));
|
||||
|
||||
QString testName = QString(variableName->c_str());
|
||||
|
||||
if (testName.compare(graphVariable->GetVariableName().data(), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
ReportError(AZStd::string::format("Second Variable has duplicate name %s", testName.toUtf8().data()).c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (variableId == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid VariableId", m_variableId.c_str()));
|
||||
}
|
||||
|
||||
if (variableName == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid string", m_nameId.c_str()));
|
||||
}
|
||||
|
||||
if (scriptCanvasId == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid ScriptCanvas::ScriptCanvasId", StateModelIds::ScriptCanvasId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DuplicateVariableNameTest::DuplicateVariableNameTest(ScriptCanvas::Data::Type firstType, ScriptCanvas::Data::Type secondType, AZStd::string variableName)
|
||||
: EditorAutomationTest(QString("Duplicate Variable name %1 Test").arg(variableName.c_str()))
|
||||
{
|
||||
AutomationStateModelId firstVariableTypeId = "VariableDataType::1";
|
||||
SetStateData(firstVariableTypeId, firstType);
|
||||
|
||||
AutomationStateModelId secondVariableTypeId = "VariableDataType::2";
|
||||
SetStateData(secondVariableTypeId, secondType);
|
||||
|
||||
AutomationStateModelId variableNameId = "VariableName";
|
||||
SetStateData(variableNameId, variableName);
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
constexpr bool errorOnNameMismatch = true;
|
||||
|
||||
AutomationStateModelId firstVariableId = "VariableId::1";
|
||||
AddState(new CreateVariableState(firstVariableTypeId, variableNameId, errorOnNameMismatch, CreateVariableAction::CreationType::AutoComplete, firstVariableId));
|
||||
|
||||
AutomationStateModelId secondVariableId = "VariableId::2";
|
||||
AddState(new CreateVariableState(secondVariableTypeId, variableNameId, !errorOnNameMismatch, CreateVariableAction::CreationType::AutoComplete, secondVariableId));
|
||||
|
||||
AddState(new CheckVariableForNameMismatchState(variableNameId, secondVariableId));
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
namespace EditStringLike
|
||||
{
|
||||
VariableInPaletteState::VariableInPaletteState(AZStd::string value, AutomationStateModelId variableId, VariablePaletteValidator validator)
|
||||
: NamedAutomationState("EditStringLikeVariableInPaletteState")
|
||||
, m_stringValue(value)
|
||||
, m_variableId(variableId)
|
||||
, m_validator(validator)
|
||||
, m_clickAction(Qt::MouseButton::LeftButton)
|
||||
, m_typeStringAction(value.c_str())
|
||||
, m_typeReturnAction(VK_RETURN)
|
||||
{
|
||||
}
|
||||
|
||||
void VariableInPaletteState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
QTableView* graphPalette = nullptr;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(graphPalette, &ScriptCanvasEditor::VariableAutomationRequests::GetGraphPaletteTableView);
|
||||
|
||||
if (graphPalette)
|
||||
{
|
||||
// 0 is the row, we've only created the single variable in this test, so we can assume that.
|
||||
// 2 is the column, this is just the column we need to click on in order to enter the editing mode.
|
||||
QModelIndex tableIndex = graphPalette->model()->index(0, 2);
|
||||
|
||||
QRectF visualRect = graphPalette->visualRect(tableIndex);
|
||||
QPoint targetPoint = graphPalette->mapToGlobal(visualRect.center().toPoint());
|
||||
|
||||
m_moveToTableRow = aznew MouseMoveAction(targetPoint);
|
||||
|
||||
actionRunner.AddAction(m_moveToTableRow);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
actionRunner.AddAction(&m_clickAction);
|
||||
actionRunner.AddAction(&m_clickAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
actionRunner.AddAction(&m_typeStringAction);
|
||||
actionRunner.AddAction(&m_typeReturnAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError("GraphPalette cannot be found in EditNumberInPaletteState");
|
||||
}
|
||||
}
|
||||
|
||||
void VariableInPaletteState::OnStateActionsComplete()
|
||||
{
|
||||
const ScriptCanvas::ScriptCanvasId* scriptCanvasId = GetStateModel()->GetStateDataAs<ScriptCanvas::ScriptCanvasId>(StateModelIds::ScriptCanvasId);
|
||||
const ScriptCanvas::VariableId* variableId = GetStateModel()->GetStateDataAs<ScriptCanvas::VariableId>(m_variableId);
|
||||
|
||||
if (scriptCanvasId)
|
||||
{
|
||||
ScriptCanvas::GraphVariable* graphVariable = nullptr;
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(graphVariable, (*scriptCanvasId), &ScriptCanvas::GraphVariableManagerRequests::FindVariableById, (*variableId));
|
||||
|
||||
if (graphVariable)
|
||||
{
|
||||
AZ::Outcome<void, AZStd::string> validationResult = m_validator(graphVariable);
|
||||
|
||||
if (!validationResult)
|
||||
{
|
||||
ReportError(validationResult.GetError());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError("Failed to find Created Variable");
|
||||
}
|
||||
}
|
||||
|
||||
if (m_moveToTableRow)
|
||||
{
|
||||
delete m_moveToTableRow;
|
||||
m_moveToTableRow = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
ValueInNodeState::ValueInNodeState(AZStd::string value, AutomationStateModelId endpointId, DatumValidator datumValidator)
|
||||
: NamedAutomationState("EditNumberInNodeState")
|
||||
, m_stringValue(value)
|
||||
, m_endpointId(endpointId)
|
||||
, m_datumValidator(datumValidator)
|
||||
, m_clickAction(Qt::MouseButton::LeftButton)
|
||||
, m_typeStringAction(value.c_str())
|
||||
, m_typeReturnAction(VK_RETURN)
|
||||
{
|
||||
}
|
||||
|
||||
void ValueInNodeState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
const GraphCanvas::Endpoint* targetEndpoint = GetStateModel()->GetStateDataAs<GraphCanvas::Endpoint>(m_endpointId);
|
||||
|
||||
if (targetEndpoint)
|
||||
{
|
||||
m_moveToPropertyAction = aznew MouseToNodePropertyEditorAction(targetEndpoint->GetSlotId());
|
||||
|
||||
actionRunner.AddAction(m_moveToPropertyAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
actionRunner.AddAction(&m_clickAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
actionRunner.AddAction(&m_typeStringAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
actionRunner.AddAction(&m_typeReturnAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid GraphCanvas::Endpoint", m_endpointId.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
void ValueInNodeState::OnStateActionsComplete()
|
||||
{
|
||||
const GraphCanvas::Endpoint* targetEndpoint = GetStateModel()->GetStateDataAs<GraphCanvas::Endpoint>(m_endpointId);
|
||||
const ScriptCanvas::ScriptCanvasId* scriptCanvasId = GetStateModel()->GetStateDataAs<ScriptCanvas::ScriptCanvasId>(StateModelIds::ScriptCanvasId);
|
||||
|
||||
if (targetEndpoint && scriptCanvasId)
|
||||
{
|
||||
ScriptCanvas::Endpoint scriptCanvasEndpoint;
|
||||
ScriptCanvasEditor::EditorGraphRequestBus::EventResult(scriptCanvasEndpoint, (*scriptCanvasId), &ScriptCanvasEditor::EditorGraphRequests::ConvertToScriptCanvasEndpoint, (*targetEndpoint));
|
||||
|
||||
if (scriptCanvasEndpoint.IsValid())
|
||||
{
|
||||
const ScriptCanvas::Datum* datum = nullptr;
|
||||
ScriptCanvas::NodeRequestBus::EventResult(datum, scriptCanvasEndpoint.GetNodeId(), &ScriptCanvas::NodeRequests::FindDatum, scriptCanvasEndpoint.GetSlotId());
|
||||
|
||||
AZ::Outcome<void, AZStd::string> datumValidation = m_datumValidator(datum);
|
||||
|
||||
if (!datumValidation)
|
||||
{
|
||||
ReportError(datumValidation.GetError());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError("Failed to convert Graph Canvas endpoint to Script Canvas endpoint");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
// ModifyNumericInputTest
|
||||
///////////////////////////
|
||||
|
||||
ModifyNumericInputTest::ModifyNumericInputTest(double value)
|
||||
: EditorAutomationTest("Numeric Input Test")
|
||||
{
|
||||
auto paletteDataValidator = [value](const ScriptCanvas::GraphVariable* graphVariable) -> AZ::Outcome<void, AZStd::string>
|
||||
{
|
||||
const ScriptCanvas::Datum* datum = graphVariable->GetDatum();
|
||||
|
||||
if (datum && datum->GetType() == ScriptCanvas::Data::Type::Number())
|
||||
{
|
||||
double currentValue = (*datum->GetAs<ScriptCanvas::Data::NumberType>());
|
||||
|
||||
if (!AZ::IsClose(currentValue, value, DBL_EPSILON))
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Expected value %f found %f", value, currentValue));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Datum is missing or incorrect type.");
|
||||
}
|
||||
|
||||
return AZ::Success();
|
||||
};
|
||||
|
||||
auto datumValidator = [value](const ScriptCanvas::Datum* datum) -> AZ::Outcome<void, AZStd::string>
|
||||
{
|
||||
if (datum && datum->GetType() == ScriptCanvas::Data::Type::Number())
|
||||
{
|
||||
const ScriptCanvas::Data::NumberType* numberType = datum->GetAs<ScriptCanvas::Data::NumberType>();
|
||||
|
||||
if (numberType)
|
||||
{
|
||||
if (!AZ::IsClose(value, (*numberType), DBL_EPSILON))
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Expected datum value to be %f, got %f", value, (*numberType)));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Datum is missing or incorrect type.");
|
||||
}
|
||||
|
||||
return AZ::Success();
|
||||
};
|
||||
|
||||
AZStd::string inputString = AZStd::string::format("%f", value);
|
||||
|
||||
AutomationStateModelId firstVariableTypeId = "VariableDataType";
|
||||
SetStateData(firstVariableTypeId, ScriptCanvas::Data::Type::Number());
|
||||
|
||||
AutomationStateModelId variableNameId = "VariableName";
|
||||
SetStateData(variableNameId, AZStd::string("Numeric"));
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId variableId = "VariableId";
|
||||
AddState(new CreateVariableState(firstVariableTypeId, variableNameId, false, CreateVariableAction::CreationType::AutoComplete, variableId));
|
||||
|
||||
AddState(new EditStringLike::VariableInPaletteState(inputString, variableId, paletteDataValidator));
|
||||
|
||||
AutomationStateModelId viewCenter = "ViewCenter";
|
||||
AddState(new FindViewCenterState(viewCenter));
|
||||
|
||||
AutomationStateModelId variableNodeId = "VariableNodeId";
|
||||
AddState(new CreateVariableNodeFromGraphPaletteState(variableNameId, viewCenter, Qt::KeyboardModifier::AltModifier, variableNodeId));
|
||||
|
||||
AutomationStateModelId dataSlotId = "DataSlotId";
|
||||
AddState(new FindEndpointOfTypeState(variableNodeId, dataSlotId, GraphCanvas::ConnectionType::CT_Input, GraphCanvas::SlotTypes::DataSlot));
|
||||
|
||||
AddState(new EditStringLike::ValueInNodeState(inputString, dataSlotId, datumValidator));
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
// ModifyStringInputTest
|
||||
//////////////////////////
|
||||
|
||||
ModifyStringInputTest::ModifyStringInputTest(AZStd::string value)
|
||||
: EditorAutomationTest("String Input Test")
|
||||
{
|
||||
auto paletteDataValidator = [value](const ScriptCanvas::GraphVariable* graphVariable) -> AZ::Outcome<void, AZStd::string>
|
||||
{
|
||||
const ScriptCanvas::Datum* datum = graphVariable->GetDatum();
|
||||
|
||||
if (datum && datum->GetType() == ScriptCanvas::Data::Type::String())
|
||||
{
|
||||
AZStd::string currentValue = (*datum->GetAs<ScriptCanvas::Data::StringType>());
|
||||
|
||||
if (currentValue.compare(value) != 0)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Expected value %s found %s", value.c_str(), currentValue.c_str()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Datum is missing or incorrect type.");
|
||||
}
|
||||
|
||||
return AZ::Success();
|
||||
};
|
||||
|
||||
auto datumValidator = [value](const ScriptCanvas::Datum* datum) -> AZ::Outcome<void, AZStd::string>
|
||||
{
|
||||
if (datum && datum->GetType() == ScriptCanvas::Data::Type::String())
|
||||
{
|
||||
const ScriptCanvas::Data::StringType* stringType = datum->GetAs<ScriptCanvas::Data::StringType>();
|
||||
|
||||
if (stringType)
|
||||
{
|
||||
if (value.compare(stringType->c_str()) != 0)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Expected datum value to be %s, got %s", value.c_str(), (*stringType).c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Datum is missing or incorrect type.");
|
||||
}
|
||||
|
||||
return AZ::Success();
|
||||
};
|
||||
|
||||
AutomationStateModelId firstVariableTypeId = "VariableDataType";
|
||||
SetStateData(firstVariableTypeId, ScriptCanvas::Data::Type::String());
|
||||
|
||||
AutomationStateModelId variableNameId = "VariableName";
|
||||
SetStateData(variableNameId, AZStd::string("String"));
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId variableId = "VariableId";
|
||||
AddState(new CreateVariableState(firstVariableTypeId, variableNameId, false, CreateVariableAction::CreationType::AutoComplete, variableId));
|
||||
|
||||
AddState(new EditStringLike::VariableInPaletteState(value, variableId, paletteDataValidator));
|
||||
|
||||
AutomationStateModelId viewCenter = "ViewCenter";
|
||||
AddState(new FindViewCenterState(viewCenter));
|
||||
|
||||
AutomationStateModelId variableNodeId = "VariableNodeId";
|
||||
AddState(new CreateVariableNodeFromGraphPaletteState(variableNameId, viewCenter, Qt::KeyboardModifier::AltModifier, variableNodeId));
|
||||
|
||||
AutomationStateModelId dataSlotId = "DataSlotId";
|
||||
AddState(new FindEndpointOfTypeState(variableNodeId, dataSlotId, GraphCanvas::ConnectionType::CT_Input, GraphCanvas::SlotTypes::DataSlot));
|
||||
|
||||
AddState(new EditStringLike::ValueInNodeState(value, dataSlotId, datumValidator));
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
// ToggleBoolInputTest
|
||||
////////////////////////
|
||||
|
||||
ToggleBoolInputTest::ToggleBoolInPaletteState::ToggleBoolInPaletteState(AutomationStateModelId variableId)
|
||||
: NamedAutomationState("ToggleBoolInPaletteState")
|
||||
, m_variableId(variableId)
|
||||
{
|
||||
SetStateName(AZStd::string::format("ToggleBoolInPaletteState::%s", m_variableId.c_str()));
|
||||
}
|
||||
|
||||
void ToggleBoolInputTest::ToggleBoolInPaletteState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
const ScriptCanvas::VariableId* variableId = GetStateModel()->GetStateDataAs<ScriptCanvas::VariableId>(m_variableId);
|
||||
const ScriptCanvas::ScriptCanvasId* scriptCanvasId = GetStateModel()->GetStateDataAs<ScriptCanvas::ScriptCanvasId>(StateModelIds::ScriptCanvasId);
|
||||
|
||||
if (variableId && scriptCanvasId)
|
||||
{
|
||||
ScriptCanvas::GraphVariable* graphVariable = nullptr;
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(graphVariable, (*scriptCanvasId), &ScriptCanvas::GraphVariableManagerRequests::FindVariableById, (*variableId));
|
||||
|
||||
if (graphVariable)
|
||||
{
|
||||
const ScriptCanvas::Datum* datum = graphVariable->GetDatum();
|
||||
|
||||
if (datum && datum->GetType() == ScriptCanvas::Data::Type::Boolean())
|
||||
{
|
||||
m_originalValue = (*datum->GetAs<ScriptCanvas::Data::BooleanType>());
|
||||
}
|
||||
|
||||
QTableView* graphPalette = nullptr;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(graphPalette, &ScriptCanvasEditor::VariableAutomationRequests::GetGraphPaletteTableView);
|
||||
|
||||
if (graphPalette)
|
||||
{
|
||||
// Assume that the variable will be the only element created in this state. So we can just use row 0.
|
||||
QModelIndex tableIndex = graphPalette->model()->index(0, 2);
|
||||
|
||||
QRectF visualRect = graphPalette->visualRect(tableIndex);
|
||||
QPointF clickPoint = visualRect.center();
|
||||
clickPoint.setX(visualRect.left() + 15);
|
||||
|
||||
QPoint targetPoint = graphPalette->mapToGlobal(clickPoint.toPoint());
|
||||
|
||||
m_interactWithTableAction = aznew MouseClickAction(Qt::MouseButton::LeftButton, targetPoint);
|
||||
|
||||
actionRunner.AddAction(m_interactWithTableAction);
|
||||
}
|
||||
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError("Failed to find Created Variable");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (variableId == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid ScriptCanvas::VariableId", m_variableId.c_str()));
|
||||
}
|
||||
|
||||
if (scriptCanvasId == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid ScriptCanvasId", StateModelIds::ScriptCanvasId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ToggleBoolInputTest::ToggleBoolInPaletteState::OnStateActionsComplete()
|
||||
{
|
||||
const ScriptCanvas::VariableId* variableId = GetStateModel()->GetStateDataAs<ScriptCanvas::VariableId>(m_variableId);
|
||||
const ScriptCanvas::ScriptCanvasId* scriptCanvasId = GetStateModel()->GetStateDataAs<ScriptCanvas::ScriptCanvasId>(StateModelIds::ScriptCanvasId);
|
||||
|
||||
if (variableId && scriptCanvasId)
|
||||
{
|
||||
ScriptCanvas::GraphVariable* graphVariable = nullptr;
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(graphVariable, (*scriptCanvasId), &ScriptCanvas::GraphVariableManagerRequests::FindVariableById, (*variableId));
|
||||
|
||||
if (graphVariable)
|
||||
{
|
||||
const ScriptCanvas::Datum* datum = graphVariable->GetDatum();
|
||||
|
||||
if (datum && datum->GetType() == ScriptCanvas::Data::Type::Boolean())
|
||||
{
|
||||
bool currentValue = (*datum->GetAs<ScriptCanvas::Data::BooleanType>());
|
||||
|
||||
if (currentValue == m_originalValue)
|
||||
{
|
||||
ReportError("Failed to toggle Boolean value");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ToggleBoolInputTest::ToggleBoolInNodeState::ToggleBoolInNodeState(AutomationStateModelId endpointId)
|
||||
: NamedAutomationState("ToggleBoolInNodeState")
|
||||
, m_endpointId(endpointId)
|
||||
, m_clickAction(Qt::MouseButton::LeftButton)
|
||||
{
|
||||
SetStateName(AZStd::string::format("ToggleBoolInNodeState::%s", endpointId.c_str()));
|
||||
}
|
||||
|
||||
void ToggleBoolInputTest::ToggleBoolInNodeState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
m_scriptCanvasEndpoint = ScriptCanvas::Endpoint();
|
||||
|
||||
const GraphCanvas::Endpoint* gcEndpoint = GetStateModel()->GetStateDataAs<GraphCanvas::Endpoint>(m_endpointId);
|
||||
const ScriptCanvas::ScriptCanvasId* scriptCanvasId = GetStateModel()->GetStateDataAs<ScriptCanvas::ScriptCanvasId>(StateModelIds::ScriptCanvasId);
|
||||
|
||||
if (gcEndpoint && scriptCanvasId)
|
||||
{
|
||||
ScriptCanvasEditor::EditorGraphRequestBus::EventResult(m_scriptCanvasEndpoint, (*scriptCanvasId), &ScriptCanvasEditor::EditorGraphRequests::ConvertToScriptCanvasEndpoint, (*gcEndpoint));
|
||||
|
||||
if (m_scriptCanvasEndpoint.IsValid())
|
||||
{
|
||||
const ScriptCanvas::Datum* datum = nullptr;
|
||||
ScriptCanvas::NodeRequestBus::EventResult(datum, m_scriptCanvasEndpoint.GetNodeId(), &ScriptCanvas::NodeRequests::FindDatum, m_scriptCanvasEndpoint.GetSlotId());
|
||||
|
||||
if (datum && datum->GetType() == ScriptCanvas::Data::Type::Boolean())
|
||||
{
|
||||
const ScriptCanvas::Data::BooleanType* booleanType = datum->GetAs<ScriptCanvas::Data::BooleanType>();
|
||||
|
||||
if (booleanType)
|
||||
{
|
||||
m_originalValue = (*booleanType);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError("Datum is missing or incorrect type.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError("Failed to convert Graph Canvas endpoint to Script Canvas endpoint");
|
||||
}
|
||||
|
||||
m_mouseToNodePropertyEditorAction = aznew MouseToNodePropertyEditorAction(gcEndpoint->GetSlotId());
|
||||
|
||||
actionRunner.AddAction(m_mouseToNodePropertyEditorAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
actionRunner.AddAction(&m_clickAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
}
|
||||
|
||||
void ToggleBoolInputTest::ToggleBoolInNodeState::OnStateActionsComplete()
|
||||
{
|
||||
if (m_scriptCanvasEndpoint.IsValid())
|
||||
{
|
||||
const ScriptCanvas::Datum* datum = nullptr;
|
||||
ScriptCanvas::NodeRequestBus::EventResult(datum, m_scriptCanvasEndpoint.GetNodeId(), &ScriptCanvas::NodeRequests::FindDatum, m_scriptCanvasEndpoint.GetSlotId());
|
||||
|
||||
if (datum && datum->GetType() == ScriptCanvas::Data::Type::Boolean())
|
||||
{
|
||||
const ScriptCanvas::Data::BooleanType* booleanType = datum->GetAs<ScriptCanvas::Data::BooleanType>();
|
||||
|
||||
if (booleanType)
|
||||
{
|
||||
if ((*booleanType) == m_originalValue)
|
||||
{
|
||||
ReportError("Boolean datum did not toggle after interaction");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError("Datum is missing or incorrect type.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ToggleBoolInputTest::ToggleBoolInputTest()
|
||||
: EditorAutomationTest("Bool Input Test")
|
||||
{
|
||||
AutomationStateModelId firstVariableTypeId = "VariableDataType";
|
||||
SetStateData(firstVariableTypeId, ScriptCanvas::Data::Type::Boolean());
|
||||
|
||||
AutomationStateModelId variableNameId = "VariableName";
|
||||
SetStateData(variableNameId, AZStd::string("Boolean"));
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId variableId = "VariableId";
|
||||
AddState(new CreateVariableState(firstVariableTypeId, variableNameId, false, CreateVariableAction::CreationType::AutoComplete, variableId));
|
||||
|
||||
AddState(new ToggleBoolInPaletteState(variableId));
|
||||
|
||||
AutomationStateModelId viewCenter = "ViewCenter";
|
||||
AddState(new FindViewCenterState(viewCenter));
|
||||
|
||||
AutomationStateModelId variableNodeId = "VariableNodeId";
|
||||
AddState(new CreateVariableNodeFromGraphPaletteState(variableNameId, viewCenter, Qt::KeyboardModifier::AltModifier, variableNodeId));
|
||||
|
||||
AutomationStateModelId dataSlotId = "DataSlotId";
|
||||
AddState(new FindEndpointOfTypeState(variableNodeId, dataSlotId, GraphCanvas::ConnectionType::CT_Input, GraphCanvas::SlotTypes::DataSlot));
|
||||
|
||||
AddState(new ToggleBoolInNodeState(dataSlotId));
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
// VariableLifeCycleTest
|
||||
//////////////////////////
|
||||
|
||||
VariableLifeCycleTest::VariableLifeCycleTest(AZStd::string name, AZStd::vector<ScriptCanvas::Data::Type> dataTypes, CreateVariableAction::CreationType creationType)
|
||||
: EditorAutomationTest(name.c_str())
|
||||
, m_creationType(creationType)
|
||||
, m_typesToMake(dataTypes)
|
||||
{
|
||||
m_variableTypeId = "ActiveVariableTypeId";
|
||||
m_variableId = "ActiveVariableId";
|
||||
m_viewCenter = "ViewCenter";
|
||||
m_offsetCenter = "OffsetCenter";
|
||||
|
||||
AutomationStateModelId variableNameId = "VariableName";
|
||||
|
||||
AutomationStateModelId setNodeId = "SetNodeId";
|
||||
AutomationStateModelId getNodeId = "GetNodeId";
|
||||
|
||||
SetStateData(variableNameId, AZStd::string("LifeCycle"));
|
||||
|
||||
SetHasCustomTransitions(true);
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
m_findViewCenterState = new FindViewCenterState(m_viewCenter);
|
||||
AddState(m_findViewCenterState);
|
||||
|
||||
m_createVariableState = new CreateVariableState(m_variableTypeId, variableNameId, false, creationType, m_variableId);
|
||||
|
||||
AddState(m_createVariableState);
|
||||
|
||||
m_dragCreateGetNode = new CreateVariableNodeFromGraphPaletteState(variableNameId, m_viewCenter, Qt::KeyboardModifier::ShiftModifier, getNodeId);
|
||||
m_dragCreateSetNode = new CreateVariableNodeFromGraphPaletteState(variableNameId, m_offsetCenter, Qt::KeyboardModifier::AltModifier, setNodeId);
|
||||
|
||||
AddState(m_dragCreateSetNode);
|
||||
AddState(m_dragCreateGetNode);
|
||||
|
||||
m_createGetNode = new CreateNodeFromContextMenuState("Get LifeCycle", CreateNodeFromContextMenuState::CreationType::ScenePosition, m_viewCenter, getNodeId);
|
||||
m_createSetNode = new CreateNodeFromContextMenuState("Set LifeCycle", CreateNodeFromContextMenuState::CreationType::ScenePosition, m_offsetCenter, setNodeId);
|
||||
|
||||
AddState(m_createGetNode);
|
||||
AddState(m_createSetNode);
|
||||
|
||||
m_destroyGetNode = new AltClickSceneElementState(getNodeId);
|
||||
m_destroySetNode = new AltClickSceneElementState(setNodeId);
|
||||
|
||||
AddState(m_destroyGetNode);
|
||||
AddState(m_destroySetNode);
|
||||
|
||||
m_deleteVariableRowState = new DeleteVariableRowFromPaletteState(0);
|
||||
AddState(m_deleteVariableRowState);
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
|
||||
SetInitialStateId<CreateRuntimeGraphStateId>();
|
||||
}
|
||||
|
||||
void VariableLifeCycleTest::OnTestStarting()
|
||||
{
|
||||
m_activeIndex = -1;
|
||||
}
|
||||
|
||||
int VariableLifeCycleTest::EvaluateTransition(int stateId)
|
||||
{
|
||||
if (stateId == ForceCloseActiveGraphStateId::StateID())
|
||||
{
|
||||
return EditorAutomationState::EXIT_STATE_ID;
|
||||
}
|
||||
else if (stateId == CreateRuntimeGraphStateId::StateID())
|
||||
{
|
||||
return m_findViewCenterState->GetStateId();
|
||||
}
|
||||
else if (stateId == m_findViewCenterState->GetStateId())
|
||||
{
|
||||
const AZ::Vector2* viewCenter = GetStateDataAs<AZ::Vector2>(m_viewCenter);
|
||||
|
||||
if (viewCenter)
|
||||
{
|
||||
AZ::Vector2 offsetCenter = (*viewCenter);
|
||||
|
||||
const AZ::Vector2* minorStep = GetStateDataAs<AZ::Vector2>(StateModelIds::MinorStep);
|
||||
|
||||
if (minorStep)
|
||||
{
|
||||
offsetCenter -= (*minorStep);
|
||||
}
|
||||
|
||||
SetStateData(m_offsetCenter, offsetCenter);
|
||||
}
|
||||
|
||||
return SetupNextVariable();
|
||||
}
|
||||
else if (stateId == m_createVariableState->GetStateId())
|
||||
{
|
||||
if (m_createVariablesNodesViaContextMenu)
|
||||
{
|
||||
return m_createGetNode->GetStateId();
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_dragCreateGetNode->GetStateId();
|
||||
}
|
||||
}
|
||||
else if (stateId == m_createGetNode->GetStateId())
|
||||
{
|
||||
return m_createSetNode->GetStateId();
|
||||
}
|
||||
else if (stateId == m_dragCreateGetNode->GetStateId())
|
||||
{
|
||||
return m_dragCreateSetNode->GetStateId();
|
||||
}
|
||||
else if (stateId == m_createSetNode->GetStateId()
|
||||
|| stateId == m_dragCreateSetNode->GetStateId())
|
||||
{
|
||||
return m_destroySetNode->GetStateId();
|
||||
}
|
||||
else if (stateId == m_destroySetNode->GetStateId())
|
||||
{
|
||||
return m_destroyGetNode->GetStateId();
|
||||
}
|
||||
else if (stateId == m_destroyGetNode->GetStateId())
|
||||
{
|
||||
return m_deleteVariableRowState->GetStateId();
|
||||
}
|
||||
else if (stateId == m_deleteVariableRowState->GetStateId())
|
||||
{
|
||||
return SetupNextVariable();
|
||||
}
|
||||
|
||||
return EditorAutomationState::EXIT_STATE_ID;
|
||||
|
||||
}
|
||||
|
||||
int VariableLifeCycleTest::SetupNextVariable()
|
||||
{
|
||||
++m_activeIndex;
|
||||
|
||||
if (m_activeIndex < m_typesToMake.size())
|
||||
{
|
||||
SetStateData(m_variableTypeId, m_typesToMake[m_activeIndex]);
|
||||
SetStateData(m_variableId, ScriptCanvas::VariableId());
|
||||
|
||||
return m_createVariableState->GetStateId();
|
||||
}
|
||||
|
||||
return ForceCloseActiveGraphStateId::StateID();
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// RapidVariableCreationDeletionTest
|
||||
//////////////////////////////////////
|
||||
|
||||
RapidVariableCreationDeletionTest::RapidVariableCreationDeletionTest()
|
||||
: EditorAutomationTest("Mass Create/Destroy Variable Test")
|
||||
, m_variableType("Variable Type")
|
||||
{
|
||||
SetHasCustomTransitions(true);
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
m_createVariableState = new CreateVariableState(m_variableType, "", false, CreateVariableAction::CreationType::Programmatic);
|
||||
AddState(m_createVariableState);
|
||||
|
||||
m_deleteVariableRowState = new DeleteVariableRowFromPaletteState(0);
|
||||
AddState(m_deleteVariableRowState);
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
|
||||
SetInitialStateId<CreateRuntimeGraphStateId>();
|
||||
}
|
||||
|
||||
void RapidVariableCreationDeletionTest::OnTestStarting()
|
||||
{
|
||||
m_activeIndex = 0;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(m_variableTypes, &ScriptCanvasEditor::VariableAutomationRequests::GetVariableTypes);
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(m_graphPalette, &ScriptCanvasEditor::VariableAutomationRequests::GetGraphPaletteTableView);
|
||||
}
|
||||
|
||||
int RapidVariableCreationDeletionTest::EvaluateTransition(int stateId)
|
||||
{
|
||||
if (stateId == CreateRuntimeGraphStateId::StateID()
|
||||
|| stateId == m_createVariableState->GetStateId())
|
||||
{
|
||||
return SetupNextVariable();
|
||||
}
|
||||
else if (stateId == m_deleteVariableRowState->GetStateId())
|
||||
{
|
||||
if (m_graphPalette->model()->rowCount() > 0)
|
||||
{
|
||||
return m_deleteVariableRowState->GetStateId();
|
||||
}
|
||||
else
|
||||
{
|
||||
return ForceCloseActiveGraphStateId::StateID();
|
||||
}
|
||||
}
|
||||
|
||||
return EditorAutomationState::EXIT_STATE_ID;
|
||||
}
|
||||
|
||||
int RapidVariableCreationDeletionTest::SetupNextVariable()
|
||||
{
|
||||
if (m_activeIndex >= m_variableTypes.size())
|
||||
{
|
||||
m_graphPalette->scrollToTop();
|
||||
return m_deleteVariableRowState->GetStateId();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetStateData(m_variableType, m_variableTypes[m_activeIndex]);
|
||||
++m_activeIndex;
|
||||
return m_createVariableState->GetStateId();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,333 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QString>
|
||||
#include <QTableView>
|
||||
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/WidgetActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ConnectionActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/CreateElementsActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ElementInteractions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/GraphActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/VariableActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/CreateElementsStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/EditorViewStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/ElementInteractionStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/VariableStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/UtilityStates.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorAutmationTest that will create a variable of the specified type using the specified creation type, and optionally give it a name
|
||||
*/
|
||||
class ManuallyCreateVariableTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
ManuallyCreateVariableTest(ScriptCanvas::Data::Type dataType, CreateVariableAction::CreationType creationType, AZStd::string variableName = AZStd::string());
|
||||
~ManuallyCreateVariableTest() override = default;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will provide a nicer name for the test.
|
||||
*/
|
||||
class CreateNamedVariableTest
|
||||
: public ManuallyCreateVariableTest
|
||||
{
|
||||
public:
|
||||
CreateNamedVariableTest(ScriptCanvas::Data::Type dataType, AZStd::string name, CreateVariableAction::CreationType creationType = CreateVariableAction::CreationType::AutoComplete);
|
||||
~CreateNamedVariableTest() override = default;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will create a two variables with a duplicated name
|
||||
*/
|
||||
class DuplicateVariableNameTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
class CheckVariableForNameMismatchState
|
||||
: public CustomActionState
|
||||
{
|
||||
public:
|
||||
CheckVariableForNameMismatchState(AutomationStateModelId nameId, AutomationStateModelId variableId);
|
||||
~CheckVariableForNameMismatchState() override = default;
|
||||
|
||||
void OnCustomAction() override;
|
||||
|
||||
private:
|
||||
|
||||
AutomationStateModelId m_nameId;
|
||||
AutomationStateModelId m_variableId;
|
||||
};
|
||||
|
||||
public:
|
||||
DuplicateVariableNameTest(ScriptCanvas::Data::Type firstType, ScriptCanvas::Data::Type secondType, AZStd::string variableName);
|
||||
~DuplicateVariableNameTest() override = default;
|
||||
};
|
||||
|
||||
// General Helper States for the tests in this file.
|
||||
namespace EditStringLike
|
||||
{
|
||||
class VariableInPaletteState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
typedef std::function< AZ::Outcome<void, AZStd::string>(const ScriptCanvas::GraphVariable*)> VariablePaletteValidator;
|
||||
|
||||
VariableInPaletteState(AZStd::string value, AutomationStateModelId variableId, VariablePaletteValidator validator);
|
||||
~VariableInPaletteState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
AZStd::string m_stringValue;
|
||||
AutomationStateModelId m_variableId;
|
||||
|
||||
VariablePaletteValidator m_validator;
|
||||
|
||||
MouseMoveAction* m_moveToTableRow = nullptr;
|
||||
MouseClickAction m_clickAction;
|
||||
|
||||
ProcessUserEventsAction m_processEvents;
|
||||
|
||||
TypeStringAction m_typeStringAction;
|
||||
TypeCharAction m_typeReturnAction;
|
||||
};
|
||||
|
||||
class ValueInNodeState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
typedef std::function< AZ::Outcome<void, AZStd::string>(const ScriptCanvas::Datum*)> DatumValidator;
|
||||
|
||||
ValueInNodeState(AZStd::string value, AutomationStateModelId endpointId, DatumValidator datumValidator);
|
||||
~ValueInNodeState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
AZStd::string m_stringValue;
|
||||
AutomationStateModelId m_endpointId;
|
||||
|
||||
DatumValidator m_datumValidator;
|
||||
|
||||
MouseClickAction m_clickAction;
|
||||
|
||||
ProcessUserEventsAction m_processEvents;
|
||||
|
||||
TypeStringAction m_typeStringAction;
|
||||
TypeCharAction m_typeReturnAction;
|
||||
|
||||
MouseToNodePropertyEditorAction* m_moveToPropertyAction = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
EditorautomationTest that will test out a couple of ways of editing a number[GraphPalette modification, and on-node editing]
|
||||
*/
|
||||
class ModifyNumericInputTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
ModifyNumericInputTest(double value);
|
||||
~ModifyNumericInputTest() override = default;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will test out a couple of ways of editing a string[GraphPalette modification, an on-node editing]
|
||||
*/
|
||||
class ModifyStringInputTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
ModifyStringInputTest(AZStd::string value);
|
||||
~ModifyStringInputTest() override = default;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will test out a couple of ways of editing a bool[GraphPalette modification, an on-node editing]
|
||||
*/
|
||||
class ToggleBoolInputTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
enum State
|
||||
{
|
||||
CreateGraph,
|
||||
CreateVariable,
|
||||
ToggleBoolInPalette,
|
||||
CreateSetNode,
|
||||
ToggleBoolInNode,
|
||||
|
||||
CloseGraph
|
||||
};
|
||||
|
||||
class ToggleBoolInPaletteState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
ToggleBoolInPaletteState(AutomationStateModelId variableId);
|
||||
~ToggleBoolInPaletteState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
bool m_originalValue = false;
|
||||
|
||||
AutomationStateModelId m_variableId;
|
||||
|
||||
MouseClickAction* m_interactWithTableAction = nullptr;
|
||||
ProcessUserEventsAction m_processEvents;
|
||||
};
|
||||
|
||||
class ToggleBoolInNodeState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
ToggleBoolInNodeState(AutomationStateModelId endpointId);
|
||||
~ToggleBoolInNodeState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
ScriptCanvas::Endpoint m_scriptCanvasEndpoint;
|
||||
bool m_originalValue = false;
|
||||
|
||||
AutomationStateModelId m_endpointId;
|
||||
|
||||
MouseToNodePropertyEditorAction* m_mouseToNodePropertyEditorAction = nullptr;
|
||||
|
||||
ProcessUserEventsAction m_processEvents;
|
||||
MouseClickAction m_clickAction;
|
||||
};
|
||||
|
||||
public:
|
||||
ToggleBoolInputTest();
|
||||
~ToggleBoolInputTest() override = default;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that takes in a set of variable types to create. For each type it will then create the variable, create a get and set node for that variable. Then clean-up the nodes and delete the variable.
|
||||
*/
|
||||
class VariableLifeCycleTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
VariableLifeCycleTest(AZStd::string name, AZStd::vector<ScriptCanvas::Data::Type> dataTypes, CreateVariableAction::CreationType creationType = CreateVariableAction::CreationType::AutoComplete);
|
||||
~VariableLifeCycleTest() override = default;
|
||||
|
||||
void OnTestStarting() override;
|
||||
|
||||
protected:
|
||||
|
||||
// Custom Transition
|
||||
int EvaluateTransition(int stateId) override;
|
||||
////
|
||||
|
||||
private:
|
||||
|
||||
int SetupNextVariable();
|
||||
|
||||
CreateVariableAction::CreationType m_creationType = CreateVariableAction::CreationType::AutoComplete;
|
||||
|
||||
ScriptCanvas::VariableId m_activeVariableId;
|
||||
AZStd::vector<CreateVariableAction*> m_createVariables;
|
||||
AZStd::vector<ScriptCanvas::Data::Type> m_typesToMake;
|
||||
|
||||
bool m_createVariablesNodesViaContextMenu = true;
|
||||
bool m_closedGraph = false;
|
||||
int m_activeIndex = 0;
|
||||
|
||||
GraphCanvas::ViewId m_viewId;
|
||||
GraphCanvas::GraphId m_graphId;
|
||||
ScriptCanvas::ScriptCanvasId m_scriptCanvasId;
|
||||
|
||||
AutomationStateModelId m_variableTypeId;
|
||||
AutomationStateModelId m_variableId;
|
||||
AutomationStateModelId m_viewCenter;
|
||||
AutomationStateModelId m_offsetCenter;
|
||||
|
||||
FindViewCenterState* m_findViewCenterState;
|
||||
|
||||
CreateVariableState* m_createVariableState;
|
||||
|
||||
CreateVariableNodeFromGraphPaletteState* m_dragCreateGetNode = nullptr;
|
||||
CreateVariableNodeFromGraphPaletteState* m_dragCreateSetNode = nullptr;
|
||||
|
||||
CreateNodeFromContextMenuState* m_createGetNode = nullptr;
|
||||
CreateNodeFromContextMenuState* m_createSetNode = nullptr;
|
||||
|
||||
AltClickSceneElementState* m_destroyGetNode = nullptr;
|
||||
AltClickSceneElementState* m_destroySetNode = nullptr;
|
||||
|
||||
DeleteVariableRowFromPaletteState* m_deleteVariableRowState = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will create every variable type(including all variations of containers) and then delete them all.
|
||||
*/
|
||||
class RapidVariableCreationDeletionTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
|
||||
RapidVariableCreationDeletionTest();
|
||||
~RapidVariableCreationDeletionTest() override = default;
|
||||
|
||||
void OnTestStarting() override;
|
||||
|
||||
// Custom Transition
|
||||
int EvaluateTransition(int stateId) override;
|
||||
////
|
||||
|
||||
private:
|
||||
|
||||
int SetupNextVariable();
|
||||
|
||||
private:
|
||||
|
||||
QTableView* m_graphPalette = nullptr;
|
||||
|
||||
int m_activeIndex = 0;
|
||||
AZStd::vector< ScriptCanvas::Data::Type > m_variableTypes;
|
||||
|
||||
AutomationStateModelId m_variableType;
|
||||
|
||||
CreateVariableState* m_createVariableState = nullptr;
|
||||
DeleteVariableRowFromPaletteState* m_deleteVariableRowState = nullptr;
|
||||
|
||||
ShowGraphVariablesAction m_showGraphVariableAction;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user