MenuUIFixture.cpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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/UIFixture.h>
  9. #include <Tests/UI/MenuUIFixture.h>
  10. #include <Integration/System/SystemCommon.h>
  11. #include <EMotionFX/Source/AnimGraphManager.h>
  12. #include <EMotionFX/Source/AnimGraphObject.h>
  13. #include <EMotionStudio/EMStudioSDK/Source/EMStudioManager.h>
  14. #include <EMotionStudio/EMStudioSDK/Source/PluginManager.h>
  15. #include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/BlendGraphViewWidget.h>
  16. #include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/BlendGraphWidget.h>
  17. #include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/AnimGraphPlugin.h>
  18. #include <AzToolsFramework/API/ToolsApplicationAPI.h>
  19. #include <AzQtComponents/Components/StyleManager.h>
  20. #include <AzQtComponents/Utilities/QtPluginPaths.h>
  21. #include <EMotionFX/Source/AnimGraphReferenceNode.h>
  22. #include <EMotionFX/Source/AnimGraphObjectFactory.h>
  23. #include <EMotionStudio/EMStudioSDK/Source/EMStudioManager.h>
  24. #include <QApplication>
  25. #include <QWidget>
  26. namespace EMotionFX
  27. {
  28. QMenu *MenuUIFixture::FindMainMenuWithName(const QString& menuName)
  29. {
  30. const QList<QMenu*> menus = EMStudio::GetMainWindow()->findChildren<QMenu*>();
  31. for (QMenu* menu : menus)
  32. {
  33. if (menu->objectName() == menuName)
  34. {
  35. return menu;
  36. }
  37. }
  38. return nullptr;
  39. }
  40. QMenu* MenuUIFixture::FindMenuWithName(const QObject* parent, const QString& objectName)
  41. {
  42. const QList<QMenu*> menus = parent->findChildren<QMenu*>();
  43. for (QMenu* menu : menus)
  44. {
  45. if (menu->objectName() == objectName)
  46. {
  47. return menu;
  48. }
  49. }
  50. return nullptr;
  51. }
  52. QAction* MenuUIFixture::FindMenuAction(const QMenu* menu, const QString itemName, const QString& parentName)
  53. {
  54. const QList<QAction*> actions = menu->findChildren<QAction*>();
  55. for (QAction* action : actions)
  56. {
  57. if (action->text() == itemName && action->parent()->objectName() == parentName)
  58. {
  59. return action;
  60. }
  61. }
  62. return nullptr;
  63. }
  64. QAction* MenuUIFixture::FindMenuActionWithObjectName(const QMenu* menu, const QString& itemName, const QString& parentName)
  65. {
  66. const QList<QAction*> actions = menu->findChildren<QAction*>();
  67. for (QAction* action : actions)
  68. {
  69. if (action->objectName() == itemName && action->parent()->objectName() == parentName)
  70. {
  71. return action;
  72. }
  73. }
  74. return nullptr;
  75. }
  76. } // namespace EMotionFX