Menus_ViewMenuOptions.py 2.2 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_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 editor_python_test_tools.hydra_editor_utils as hydra
  22. import pyside_utils
  23. from editor_python_test_tools.utils import Report
  24. view_menu_options = [
  25. ("Center on Selection",),
  26. ("Show Quick Access Bar",),
  27. ("Layouts", "Component Entity Layout",),
  28. ("Layouts", "Save Layout",),
  29. ("Viewport", "Go to Position"),
  30. ("Viewport", "Center on Selection"),
  31. ("Viewport", "Go to Location"),
  32. ("Viewport", "Remember Location"),
  33. ("Viewport", "Switch Camera"),
  34. ("Viewport", "Show Helpers"),
  35. ("Viewport", "Show Icons"),
  36. ("Refresh Style",),
  37. ]
  38. # 1) Open an existing simple level
  39. hydra.open_base_level()
  40. # 2) Interact with View Menu options
  41. editor_window = pyside_utils.get_editor_main_window()
  42. for option in view_menu_options:
  43. try:
  44. action = pyside_utils.get_action_for_menu_path(editor_window, "View", *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_ViewMenuOptions_Work)