Menus_FileMenuOptions.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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_FileMenuOptions_Work():
  7. """
  8. Summary:
  9. Interact with File Menu options and verify if all the options are working.
  10. Expected Behavior:
  11. The File menu functions normally.
  12. Test Steps:
  13. 1) Open level
  14. 2) Interact with File 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. file_menu_options = [
  26. ("New Level",),
  27. ("Open Level",),
  28. ("Open Recent",),
  29. ("Save",),
  30. ("Save As",),
  31. ("Save Level Statistics",),
  32. ("Edit Project Settings",),
  33. ("Edit Platform Settings",),
  34. ("New Project",),
  35. ("Open Project",),
  36. # Disabling "Show Log File" for CI testing as it launches an external app. Uncomment as needed for local testing
  37. # ("Show Log File",),
  38. ]
  39. # 1) Open an existing simple level
  40. hydra.open_base_level()
  41. # The action manager doesn't register the menus until the next system tick, so need to wait
  42. # until the menu bar has been populated
  43. general.idle_enable(True)
  44. general.idle_wait_frames(1)
  45. # 2) Interact with File Menu options
  46. editor_window = pyside_utils.get_editor_main_window()
  47. for option in file_menu_options:
  48. try:
  49. action = pyside_utils.get_action_for_menu_path(editor_window, "File", *option)
  50. Report.info(f"Triggering {action.iconText()}")
  51. action.trigger()
  52. action_triggered = True
  53. except Exception as e:
  54. action_triggered = False
  55. print(e)
  56. menu_action_triggered = (
  57. f"{action.iconText()} action triggered successfully",
  58. f"Failed to trigger {action.iconText()} action"
  59. )
  60. Report.result(menu_action_triggered, action_triggered)
  61. if __name__ == "__main__":
  62. from editor_python_test_tools.utils import Report
  63. Report.start_test(Menus_FileMenuOptions_Work)