3
0

MotionEventCommandTests.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 <Tests/SystemComponentFixture.h>
  9. #include <MCore/Source/CommandGroup.h>
  10. #include <EMotionFX/Source/MotionEventTable.h>
  11. #include <EMotionFX/Source/Motion.h>
  12. #include <EMotionFX/CommandSystem/Source/CommandManager.h>
  13. #include <EMotionFX/CommandSystem/Source/MotionEventCommands.h>
  14. namespace EMotionFX
  15. {
  16. using MotionEventCommandTests = SystemComponentFixture;
  17. TEST_F(MotionEventCommandTests, RemoveMotionEventTrackCommandTest)
  18. {
  19. AZStd::string result;
  20. CommandSystem::CommandManager commandManager;
  21. MCore::CommandGroup commandGroup;
  22. Motion* motion = aznew Motion("SkeletalMotion1");
  23. MotionEventTable* eventTable = motion->GetEventTable();
  24. // Some of the motion event related commands automatically create sync tracks.
  25. // This would make data verification harder, so we just manually create it upfront.
  26. eventTable->AutoCreateSyncTrack(motion);
  27. const char* eventTrackName = "EventTrack1";
  28. MotionEventTrack* eventTrack = aznew MotionEventTrack(eventTrackName, motion);
  29. eventTable->AddTrack(eventTrack);
  30. EXPECT_EQ(eventTable->GetNumTracks(), 2);
  31. CommandSystem::CommandRemoveEventTrack(motion, 0);
  32. EXPECT_EQ(eventTable->GetNumTracks(), 1);
  33. EXPECT_TRUE(commandManager.Undo(result)) << result.c_str();
  34. EXPECT_EQ(eventTable->GetNumTracks(), 2);
  35. EXPECT_EQ(eventTable->GetTrack(1)->GetNameString(), eventTrackName);
  36. EXPECT_TRUE(commandManager.Redo(result)) << result.c_str();
  37. EXPECT_EQ(eventTable->GetNumTracks(), 1);
  38. motion->Destroy();
  39. }
  40. } // namespace EMotionFX