You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Gems/EMotionFX/Code/Tests/ProvidesUI/AnimGraph/ParameterWindowTests.cpp

56 lines
2.7 KiB
C++

/*
* 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 <gtest/gtest.h>
#include <EMotionFX/CommandSystem/Source/AnimGraphCommands.h>
#include <EMotionFX/CommandSystem/Source/AnimGraphParameterCommands.h>
#include <EMotionFX/CommandSystem/Source/CommandManager.h>
#include <EMotionFX/Source/AnimGraphInstance.h>
#include <EMotionFX/Source/Parameter/FloatSliderParameter.h>
#include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/AnimGraphPlugin.h>
#include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/ParameterWindow.h>
#include <QApplication>
#include <QtTest>
#include "qtestsystem.h"
#include <Tests/ProvidesUI/AnimGraph/SimpleAnimGraphUIFixture.h>
namespace EMotionFX
{
TEST_F(SimpleAnimGraphUIFixture, RemoveParametersTests)
{
// Check the parameters window
EMStudio::ParameterWindow* parameterWindow = m_animGraphPlugin->GetParameterWindow();
EXPECT_EQ(parameterWindow->GetTopLevelItemCount(), m_animGraph->GetNumParameters()) << "Number of parameters displayed in the parameters window should be the same in the animgraph.";
AZStd::string paramName;
const AZ::u32 numIterations = 100;
size_t numParams = m_animGraph->GetNumParameters();
for (AZ::u32 i = 0; i < numIterations; ++i)
{
paramName = AZStd::string::format("testFloat%d", i);
FloatParameter* floatParam = aznew FloatSliderParameter(paramName);
floatParam->SetDefaultValue(0.0f);
m_animGraph->AddParameter(floatParam);
}
numParams += numIterations;
EXPECT_TRUE(m_animGraph->GetNumParameters() == numParams) << "The number of parameters should increase by 100 after adding 100 new float parameters to the anim graph.";
parameterWindow->ClearParameters(false);
AZStd::string result;
EXPECT_EQ(m_animGraph->GetNumParameters(), 0) << "There should be no parameters after clear parameters.";
EXPECT_TRUE(CommandSystem::GetCommandManager()->Undo(result)) << result.c_str();
EXPECT_EQ(m_animGraph->GetNumParameters(), numParams) << "The number of parameters should recover to before clearing parameters.";
EXPECT_EQ(parameterWindow->GetTopLevelItemCount(), m_animGraph->GetNumParameters()) << "Number of parameters displayed in the parameters window should be the same in the animgraph.";
EXPECT_TRUE(CommandSystem::GetCommandManager()->Redo(result)) << result.c_str();
EXPECT_EQ(m_animGraph->GetNumParameters(), 0) << "The number of parameters should zero after redo.";
}
} // namespace EMotionFX