AnimGraphActionTests.cpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <EMotionFX/CommandSystem/Source/AnimGraphTriggerActionCommands.h>
  9. #include <EMotionFX/CommandSystem/Source/CommandManager.h>
  10. #include <EMotionFX/Source/AnimGraphBindPoseNode.h>
  11. #include <EMotionFX/Source/AnimGraphSimpleStateAction.h>
  12. #include <EMotionFX/Source/AnimGraphSymbolicFollowerParameterAction.h>
  13. #include <EMotionFX/Source/AnimGraphStateMachine.h>
  14. #include <EMotionFX/Source/AnimGraphStateTransition.h>
  15. #include <LmbrCentral/Scripting/SimpleStateComponentBus.h>
  16. #include <Tests/AnimGraphFixture.h>
  17. namespace EMotionFX
  18. {
  19. class AnimGraphActionFixture
  20. : public AnimGraphFixture
  21. {
  22. public:
  23. void ConstructGraph() override
  24. {
  25. AnimGraphFixture::ConstructGraph();
  26. AnimGraphNode* stateA = aznew AnimGraphBindPoseNode();
  27. m_rootStateMachine->AddChildNode(stateA);
  28. m_rootStateMachine->SetEntryState(stateA);
  29. AnimGraphNode* stateB = aznew AnimGraphBindPoseNode();
  30. m_rootStateMachine->AddChildNode(stateB);
  31. m_transition = AddTransitionWithTimeCondition(stateA, stateB, /*blendTime=*/1.0f, /*countDownTime=*/1.0f);
  32. }
  33. AnimGraphStateTransition* m_transition = nullptr;
  34. };
  35. TEST_F(AnimGraphActionFixture, AnimGraphSymbolicFollowerParameterAction_TriggerWithEmptyParameterName)
  36. {
  37. CommandSystem::CommandManager commandManager;
  38. CommandSystem::AddTransitionAction(m_transition, azrtti_typeid<AnimGraphSymbolicFollowerParameterAction>());
  39. EXPECT_EQ(m_transition->GetTriggerActionSetup().GetNumActions(), 1)
  40. << "There should be exactly one transition action.";
  41. AnimGraphSymbolicFollowerParameterAction* action = azdynamic_cast<AnimGraphSymbolicFollowerParameterAction*>(m_transition->GetTriggerActionSetup().GetAction(0));
  42. ASSERT_NE(action, nullptr) << "Action not a valid symbolic follower parameter action.";
  43. GetEMotionFX().Update(1.0f);
  44. }
  45. TEST_F(AnimGraphActionFixture, AnimGraphSimpleStateAction_BasicTests)
  46. {
  47. CommandSystem::CommandManager commandManager;
  48. CommandSystem::AddTransitionAction(m_transition, azrtti_typeid<AnimGraphSimpleStateAction>());
  49. EXPECT_EQ(m_transition->GetTriggerActionSetup().GetNumActions(), 1) << "There should be exactly one transition action.";
  50. // Setup the simple state action
  51. AnimGraphSimpleStateAction* action =
  52. azdynamic_cast<AnimGraphSimpleStateAction*>(m_transition->GetTriggerActionSetup().GetAction(0));
  53. ASSERT_NE(action, nullptr) << "Action not a valid simple state action.";
  54. GetEMotionFX().Update(1.0f);
  55. }
  56. } // namespace EMotionFX