3
0

SimpleAnimGraphUIFixture.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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/AnimGraphCommands.h>
  9. #include <EMotionFX/Source/AnimGraphManager.h>
  10. #include <EMotionFX/Source/AnimGraphMotionNode.h>
  11. #include <EMotionFX/Source/Parameter/BoolParameter.h>
  12. #include <EMotionFX/Source/Parameter/FloatSliderParameter.h>
  13. #include <EMotionFX/Source/Parameter/Vector2Parameter.h>
  14. #include <QApplication>
  15. #include <Tests/ProvidesUI/AnimGraph/SimpleAnimGraphUIFixture.h>
  16. namespace EMotionFX
  17. {
  18. void SimpleAnimGraphUIFixture::SetUp()
  19. {
  20. UIFixture::SetUp();
  21. AZStd::string commandResult;
  22. MCore::CommandGroup group;
  23. // Create empty anim graph, add a motion node and a blend tree.
  24. group.AddCommandString(AZStd::string::format("CreateAnimGraph -animGraphID %d", m_animGraphId));
  25. group.AddCommandString(AZStd::string::format("AnimGraphCreateNode -animGraphID %d -type %s -parentName Root -xPos 100 -yPos 100 -name testMotion",
  26. m_animGraphId, azrtti_typeid<AnimGraphMotionNode>().ToString<AZStd::string>().c_str()));
  27. group.AddCommandString(AZStd::string::format("AnimGraphCreateNode -animGraphID %d -type %s -parentName Root -xPos 200 -yPos 100 -name testBlendTree",
  28. m_animGraphId, azrtti_typeid<BlendTree>().ToString<AZStd::string>().c_str()));
  29. group.AddCommandString(AZStd::string::format("AnimGraphCreateConnection -animGraphID %d -transitionType %s -sourceNode testMotion -targetNode testBlendTree",
  30. m_animGraphId, azrtti_typeid<AnimGraphStateTransition>().ToString<AZStd::string>().c_str()));
  31. // Create some paramters
  32. group.AddCommandString(AZStd::string::format("AnimGraphCreateParameter -animGraphID %i -type \"%s\" -name bool_param",
  33. m_animGraphId, azrtti_typeid<BoolParameter>().ToString<AZStd::string>().c_str()));
  34. group.AddCommandString(AZStd::string::format("AnimGraphCreateParameter -animGraphID %i -type \"%s\" -name float_param",
  35. m_animGraphId, azrtti_typeid<FloatSliderParameter>().ToString<AZStd::string>().c_str()));
  36. group.AddCommandString(AZStd::string::format("AnimGraphCreateParameter -animGraphID %i -type \"%s\" -name vec2_param",
  37. m_animGraphId, azrtti_typeid<Vector2Parameter>().ToString<AZStd::string>().c_str()));
  38. EXPECT_TRUE(CommandSystem::GetCommandManager()->ExecuteCommandGroup(group, commandResult)) << commandResult.c_str();
  39. m_animGraph = GetAnimGraphManager().FindAnimGraphByID(m_animGraphId);
  40. EXPECT_NE(m_animGraph, nullptr) << "Cannot find newly created anim graph.";
  41. // Cache some local poitners.
  42. m_animGraphPlugin = static_cast<EMStudio::AnimGraphPlugin*>(EMStudio::GetPluginManager()->FindActivePlugin(EMStudio::AnimGraphPlugin::CLASS_ID));
  43. ASSERT_NE(m_animGraphPlugin, nullptr) << "Anim graph plugin not found.";
  44. }
  45. void SimpleAnimGraphUIFixture::TearDown()
  46. {
  47. QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
  48. delete m_animGraph;
  49. UIFixture::TearDown();
  50. }
  51. } // namespace EMotionFX