Menus_ViewMenuOptions.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. """
  6. def Menus_ViewMenuOptions_Work():
  7. """
  8. Summary:
  9. Interact with View Menu options and verify if all the options are working.
  10. Expected Behavior:
  11. The View menu functions normally.
  12. Test Steps:
  13. 1) Open an existing level
  14. 2) Interact with View Menu options
  15. Note:
  16. - This test file must be called from the O3DE Editor command terminal
  17. - Any passed and failed tests are written to the Editor.log file.
  18. Parsing the file or running a log_monitor are required to observe the test results.
  19. :return: None
  20. """
  21. import azlmbr.legacy.general as general
  22. import editor_python_test_tools.hydra_editor_utils as hydra
  23. import pyside_utils
  24. from editor_python_test_tools.utils import Report
  25. view_menu_options = [
  26. ("Viewport", "Go to Position"),
  27. ("Viewport", "Find Selected Entities in Viewport"),
  28. ("Viewport", "Go to Location"),
  29. ("Viewport", "Viewport Helpers", "Show Icons"),
  30. ("Viewport", "Viewport Helpers", "Show Helpers for all entities"),
  31. ("Viewport", "Viewport Helpers", "Show Helpers for selected entities"),
  32. ("Viewport", "Viewport Helpers", "Hide Helpers"),
  33. ("Refresh Style",)
  34. ]
  35. # 1) Open an existing simple level
  36. hydra.open_base_level()
  37. # The action manager doesn't register the menus until the next system tick, so need to wait
  38. # until the menu bar has been populated
  39. general.idle_enable(True)
  40. general.idle_wait_frames(1)
  41. # 2) Interact with View Menu options
  42. editor_window = pyside_utils.get_editor_main_window()
  43. for option in view_menu_options:
  44. try:
  45. action = pyside_utils.get_action_for_menu_path(editor_window, "View", *option)
  46. Report.info(f"Triggering {action.iconText()}")
  47. action.trigger()
  48. action_triggered = True
  49. except Exception as e:
  50. action_triggered = False
  51. print(e)
  52. menu_action_triggered = (
  53. f"{action.iconText()} action triggered successfully",
  54. f"Failed to trigger {action.iconText()} action"
  55. )
  56. Report.result(menu_action_triggered, action_triggered)
  57. if __name__ == "__main__":
  58. from editor_python_test_tools.utils import Report
  59. Report.start_test(Menus_ViewMenuOptions_Work)