12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- /*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
- #include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/AnimGraphPlugin.h>
- #include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/AnimGraphActionManager.h>
- #include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/BlendGraphWidget.h>
- #include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/NodeGraph.h>
- #include <EMotionStudio/EMStudioSDK/Source/EMStudioManager.h>
- #include <EMotionFX/Source/AnimGraphManager.h>
- #include <EMotionFX/Source/AnimGraphStateMachine.h>
- #include <Tests/UI/CommandRunnerFixture.h>
- namespace EMotionFX
- {
- class CanDeleteAnimGraphNode
- : public CommandRunnerFixture
- {
- };
- TEST_P(CanDeleteAnimGraphNode, CanDeleteAnimGraphNode_AnimGraphModelUpdates)
- {
- ExecuteCommands(GetParam());
- const AZStd::vector<AZStd::string>& results = GetResults();
- const AnimGraphConnectionId connectionId = AnimGraphConnectionId::CreateFromString(results.back());
- // Pre checks
- const AnimGraph* animGraph = GetAnimGraphManager().FindAnimGraphByID(100);
- ASSERT_TRUE(animGraph) << "Anim Graph not created";
- AnimGraphNode* motionNode0 = animGraph->GetRootStateMachine()->FindChildNode("Motion0");
- ASSERT_TRUE(motionNode0) << "Motion0 node not created";
- AnimGraphNode* motionNode1 = animGraph->GetRootStateMachine()->FindChildNode("Motion1");
- ASSERT_TRUE(motionNode1) << "Motion1 node not created";
- AnimGraphStateTransition* connection = animGraph->RecursiveFindTransitionById(connectionId);
- ASSERT_TRUE(connection) << "Connection between motion nodes not created";
- EMStudio::AnimGraphPlugin* animGraphPlugin = static_cast<EMStudio::AnimGraphPlugin*>(EMStudio::GetPluginManager()->FindActivePlugin(EMStudio::AnimGraphPlugin::CLASS_ID));
- ASSERT_TRUE(animGraphPlugin) << "Anim Graph plugin did not load";
- EMStudio::AnimGraphModel& model = animGraphPlugin->GetAnimGraphModel();
- ASSERT_TRUE(model.FindFirstModelIndex(motionNode0).isValid()) << "Model index for motionNode0 is invalid";
- ASSERT_TRUE(model.FindFirstModelIndex(motionNode1).isValid()) << "Model index for motionNode1 is invalid";
- ASSERT_TRUE(model.FindFirstModelIndex(connection).isValid()) << "Model index for connection is invalid";
- // Select and delete the nodes and connections
- animGraphPlugin->GetGraphWidget()->GetActiveGraph()->SelectNodesInRect(QRect(-10, -10, 1000, 1000));
- animGraphPlugin->GetActionManager().DeleteSelectedNodes();
- // Post checks
- motionNode0 = animGraph->GetRootStateMachine()->FindChildNode("Motion0");
- ASSERT_FALSE(motionNode0) << "Motion0 node not deleted";
- motionNode1 = animGraph->GetRootStateMachine()->FindChildNode("Motion1");
- ASSERT_FALSE(motionNode1) << "Motion1 node not deleted";
- connection = animGraph->RecursiveFindTransitionById(connectionId);
- ASSERT_FALSE(connection) << "Connection between motion nodes not deleted";
- ASSERT_FALSE(model.FindFirstModelIndex(motionNode0).isValid()) << "Model index for motionNode0 is still valid";
- ASSERT_FALSE(model.FindFirstModelIndex(motionNode1).isValid()) << "Model index for motionNode1 is still valid";
- ASSERT_FALSE(model.FindFirstModelIndex(connection).isValid()) << "Model index for connection is still valid";
- }
- INSTANTIATE_TEST_CASE_P(CanDeleteAnimGraphNode_AnimGraphModelUpdates, CanDeleteAnimGraphNode,
- ::testing::Values(std::vector<std::string> {
- R"str(CreateAnimGraph -animGraphID 100)str",
- R"str(Select -animGraphID 100)str",
- R"str(AnimGraphCreateNode -animGraphID 100 -type {B8B8AAE6-E532-4BF8-898F-3D40AA41BC82} -parentName Root -xPos 0 -yPos 0 -name Motion0)str",
- R"str(AnimGraphCreateNode -animGraphID 100 -type {B8B8AAE6-E532-4BF8-898F-3D40AA41BC82} -parentName Root -xPos 50 -yPos 0 -name Motion1)str",
- R"str(AnimGraphCreateConnection -animGraphID 100 -sourceNode Motion0 -targetNode Motion1 -sourcePort 0 -targetPort 0 -startOffsetX 98 -startOffsetY 17 -endOffsetX 4 -endOffsetY 17 -transitionType {E69C8C6E-7066-43DD-B1BF-0D2FFBDDF457})str",
- // Don't add more commands here, the result of the CreateConnection command is used to find a pointer to that connection after the commands have been executed
- }
- ));
- } // end namespace EMotionFX
|