Menus_EditMenuOptions.py 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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_EditMenuOptions_Work():
  7. """
  8. Summary:
  9. Interact with Edit Menu options and verify if all the options are working.
  10. Expected Behavior:
  11. The Edit menu functions normally.
  12. Test Steps:
  13. 1) Open an existing level
  14. 2) Interact with Edit 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. from editor_python_test_tools.editor_entity_utils import EditorEntity
  26. edit_menu_options = [
  27. ("Undo",),
  28. ("Redo",),
  29. ("Duplicate",),
  30. ("Delete",),
  31. ("Select All",),
  32. ("Invert Selection",),
  33. ("Toggle Pivot Location",),
  34. ("Reset Entity Transform",),
  35. ("Reset Manipulator",),
  36. ("Hide Selection",),
  37. ("Show All",),
  38. ("Lock Selection",),
  39. ("Unlock All Entities",),
  40. ("Modify", "Snap", "Angle snapping"),
  41. ("Modify", "Snap", "Grid snapping"),
  42. ("Modify", "Transform Mode", "Move"),
  43. ("Modify", "Transform Mode", "Rotate"),
  44. ("Modify", "Transform Mode", "Scale"),
  45. ("Editor Settings", "Global Preferences"),
  46. ("Editor Settings", "Editor Settings Manager"),
  47. # The following menu options are temporarily disabled due to https://github.com/o3de/o3de/issues/6746
  48. #("Editor Settings", "Keyboard Customization", "Export Keyboard Settings"),
  49. #("Editor Settings", "Keyboard Customization", "Import Keyboard Settings"),
  50. ]
  51. # 1) Open an existing simple level
  52. hydra.open_base_level()
  53. # The action manager doesn't register the menus until the next system tick, so need to wait
  54. # until the menu bar has been populated
  55. general.idle_enable(True)
  56. general.idle_wait_frames(1)
  57. # 2) Some menu items will not display when no entity is selected (For example, Delete or Duplicate)
  58. # We create an entity as it's the quickest way to have a selection (new entities are selected by default).
  59. EditorEntity.create_editor_entity()
  60. general.idle_wait_frames(1)
  61. # 3) Interact with Edit Menu options
  62. editor_window = pyside_utils.get_editor_main_window()
  63. for option in edit_menu_options:
  64. try:
  65. action = pyside_utils.get_action_for_menu_path(editor_window, "Edit", *option)
  66. Report.info(f"Triggering {action.iconText()}")
  67. action.trigger()
  68. action_triggered = True
  69. except Exception as e:
  70. action_triggered = False
  71. print(e)
  72. menu_action_triggered = (
  73. f"{action.iconText()} action triggered successfully",
  74. f"Failed to trigger {action.iconText()} action"
  75. )
  76. Report.result(menu_action_triggered, action_triggered)
  77. if __name__ == "__main__":
  78. from editor_python_test_tools.utils import Report
  79. Report.start_test(Menus_EditMenuOptions_Work)