3
0

ParameterWindowTests.cpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 <gtest/gtest.h>
  9. #include <EMotionFX/CommandSystem/Source/AnimGraphCommands.h>
  10. #include <EMotionFX/CommandSystem/Source/AnimGraphParameterCommands.h>
  11. #include <EMotionFX/CommandSystem/Source/CommandManager.h>
  12. #include <EMotionFX/Source/AnimGraphInstance.h>
  13. #include <EMotionFX/Source/Parameter/FloatSliderParameter.h>
  14. #include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/AnimGraphPlugin.h>
  15. #include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/ParameterWindow.h>
  16. #include <QApplication>
  17. #include <QtTest>
  18. #include "qtestsystem.h"
  19. #include <Tests/ProvidesUI/AnimGraph/SimpleAnimGraphUIFixture.h>
  20. namespace EMotionFX
  21. {
  22. TEST_F(SimpleAnimGraphUIFixture, RemoveParametersTests)
  23. {
  24. // Check the parameters window
  25. EMStudio::ParameterWindow* parameterWindow = m_animGraphPlugin->GetParameterWindow();
  26. EXPECT_EQ(parameterWindow->GetTopLevelItemCount(), m_animGraph->GetNumParameters()) << "Number of parameters displayed in the parameters window should be the same in the animgraph.";
  27. AZStd::string paramName;
  28. const AZ::u32 numIterations = 100;
  29. size_t numParams = m_animGraph->GetNumParameters();
  30. for (AZ::u32 i = 0; i < numIterations; ++i)
  31. {
  32. paramName = AZStd::string::format("testFloat%d", i);
  33. FloatParameter* floatParam = aznew FloatSliderParameter(paramName);
  34. floatParam->SetDefaultValue(0.0f);
  35. m_animGraph->AddParameter(floatParam);
  36. }
  37. numParams += numIterations;
  38. EXPECT_TRUE(m_animGraph->GetNumParameters() == numParams) << "The number of parameters should increase by 100 after adding 100 new float parameters to the anim graph.";
  39. parameterWindow->ClearParameters(false);
  40. AZStd::string result;
  41. EXPECT_EQ(m_animGraph->GetNumParameters(), 0) << "There should be no parameters after clear parameters.";
  42. EXPECT_TRUE(CommandSystem::GetCommandManager()->Undo(result)) << result.c_str();
  43. EXPECT_EQ(m_animGraph->GetNumParameters(), numParams) << "The number of parameters should recover to before clearing parameters.";
  44. EXPECT_EQ(parameterWindow->GetTopLevelItemCount(), m_animGraph->GetNumParameters()) << "Number of parameters displayed in the parameters window should be the same in the animgraph.";
  45. EXPECT_TRUE(CommandSystem::GetCommandManager()->Redo(result)) << result.c_str();
  46. EXPECT_EQ(m_animGraph->GetNumParameters(), 0) << "The number of parameters should zero after redo.";
  47. }
  48. } // namespace EMotionFX