3
0

CanAddMotionToMotionSet.cpp 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 <QPushButton>
  10. #include <QAction>
  11. #include <QtTest>
  12. #include <Tests/UI/AnimGraphUIFixture.h>
  13. #include <EMotionFX/Source/AnimGraphReferenceNode.h>
  14. #include <EMotionFX/Source/AnimGraphManager.h>
  15. #include <EMotionFX/Source/AnimGraphObject.h>
  16. #include <EMotionFX/Source/AnimGraphObjectFactory.h>
  17. #include <EMotionStudio/Plugins/StandardPlugins/Source/MotionSetsWindow/MotionSetsWindowPlugin.h>
  18. #include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/AnimGraphPlugin.h>
  19. #include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/BlendGraphViewWidget.h>
  20. #include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/BlendGraphWidget.h>
  21. namespace EMotionFX
  22. {
  23. TEST_F(UIFixture, CanAddMotionToMotionSet)
  24. {
  25. RecordProperty("test_case_id", "C1559110");
  26. auto motionSetPlugin = static_cast<EMStudio::MotionSetsWindowPlugin*>(EMStudio::GetPluginManager()->FindActivePlugin(EMStudio::MotionSetsWindowPlugin::CLASS_ID));
  27. ASSERT_TRUE(motionSetPlugin) << "No motion sets plugin found";
  28. EMStudio::MotionSetManagementWindow* managementWindow = motionSetPlugin->GetManagementWindow();
  29. ASSERT_TRUE(managementWindow) << "No motion sets management window found";
  30. EMStudio::MotionSetWindow* motionSetWindow = motionSetPlugin->GetMotionSetWindow();
  31. ASSERT_TRUE(motionSetWindow) << "No motion set window found";
  32. // Check there is now a motion set.
  33. size_t numMotionSetsAfterCreate = EMotionFX::GetMotionManager().GetNumMotionSets();
  34. ASSERT_EQ(numMotionSetsAfterCreate, 1);
  35. EMotionFX::MotionSet* motionSet = EMotionFX::GetMotionManager().GetMotionSet(0);
  36. // Ensure new motion set is selected.
  37. motionSetPlugin->SetSelectedSet(motionSet);
  38. // It should be empty at the moment.
  39. size_t numMotions = motionSet->GetNumMotionEntries();
  40. EXPECT_EQ(numMotions, 0);
  41. // Find the action to add a motion to the set and press it.
  42. QWidget* addMotionButton = GetWidgetWithNameFromNamedToolbar(motionSetWindow, "MotionSetWindow.ToolBar", "MotionSetWindow.ToolBar.AddANewEntry");
  43. ASSERT_TRUE(addMotionButton);
  44. QTest::mouseClick(addMotionButton, Qt::LeftButton);
  45. // There should now be a motion.
  46. size_t numMotionsAfterCreate = motionSet->GetNumMotionEntries();
  47. ASSERT_EQ(numMotionsAfterCreate, 1);
  48. AZStd::unordered_map<AZStd::string, MotionSet::MotionEntry*> motions = motionSet->GetMotionEntries();
  49. // The newly created motion should be called "<undefined>".
  50. MotionSet::MotionEntry* motion = motions["<undefined>"];
  51. ASSERT_TRUE(motion) << "no \"<undefined>\" motion found";
  52. QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
  53. }
  54. } // namespace EMotionFX