CommandRunnerFixture.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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/UI/CommandRunnerFixture.h>
  9. namespace EMotionFX
  10. {
  11. void CommandRunnerFixtureBase::TearDown()
  12. {
  13. m_results.clear();
  14. m_results.shrink_to_fit();
  15. UIFixture::TearDown();
  16. }
  17. void CommandRunnerFixtureBase::ExecuteCommands(std::vector<std::string> commands)
  18. {
  19. AZStd::string result;
  20. for (const auto& commandStr : commands)
  21. {
  22. if (commandStr == "UNDO")
  23. {
  24. EXPECT_TRUE(CommandSystem::GetCommandManager()->Undo(result)) << "Undo: " << result.c_str();
  25. }
  26. else if (commandStr == "REDO")
  27. {
  28. EXPECT_TRUE(CommandSystem::GetCommandManager()->Redo(result)) << "Redo: " << result.c_str();
  29. }
  30. else
  31. {
  32. EXPECT_TRUE(CommandSystem::GetCommandManager()->ExecuteCommand(commandStr.c_str(), result)) << commandStr.c_str() << ": " << result.c_str();
  33. }
  34. m_results.emplace_back(result);
  35. }
  36. }
  37. const AZStd::vector<AZStd::string>& CommandRunnerFixtureBase::GetResults()
  38. {
  39. return m_results;
  40. }
  41. TEST_P(CommandRunnerFixture, ExecuteCommands)
  42. {
  43. ExecuteCommands(GetParam());
  44. }
  45. } // end namespace EMotionFX