Menus_FileMenuOptions.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 editor_python_test_tools.hydra_editor_utils as hydra
  22. import pyside_utils
  23. from editor_python_test_tools.utils import Report
  24. file_menu_options = [
  25. ("New Level",),
  26. ("Open Level",),
  27. ("Import",),
  28. ("Save",),
  29. ("Save As",),
  30. ("Save Level Statistics",),
  31. ("Edit Project Settings",),
  32. ("Edit Platform Settings",),
  33. ("New Project",),
  34. ("Open Project",),
  35. ("Show Log File",),
  36. ("Exit",),
  37. ]
  38. # 1) Open an existing simple level
  39. hydra.open_base_level()
  40. # 2) Interact with File Menu options
  41. editor_window = pyside_utils.get_editor_main_window()
  42. for option in file_menu_options:
  43. try:
  44. action = pyside_utils.get_action_for_menu_path(editor_window, "File", *option)
  45. Report.info(f"Triggering {action.iconText()}")
  46. action.trigger()
  47. action_triggered = True
  48. except Exception as e:
  49. action_triggered = False
  50. print(e)
  51. menu_action_triggered = (
  52. f"{action.iconText()} action triggered successfully",
  53. f"Failed to trigger {action.iconText()} action"
  54. )
  55. Report.result(menu_action_triggered, action_triggered)
  56. if __name__ == "__main__":
  57. from editor_python_test_tools.utils import Report
  58. Report.start_test(Menus_FileMenuOptions_Work)