Menus_ViewMenuOptions.py 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. """
  2. All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
  3. its licensors.
  4. For complete copyright and license terms please see the LICENSE at the root of this
  5. distribution (the "License"). All use of this software is governed by the License,
  6. or, if provided, by the license below or the license accompanying this file. Do not
  7. remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. """
  10. """
  11. C24064534: The View menu options function normally
  12. """
  13. import os
  14. import sys
  15. import azlmbr.paths
  16. sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
  17. from automatedtesting_shared.editor_test_helper import EditorTestHelper
  18. import automatedtesting_shared.pyside_utils as pyside_utils
  19. class TestViewMenuOptions(EditorTestHelper):
  20. def __init__(self):
  21. EditorTestHelper.__init__(self, log_prefix="Menus_EditMenuOptions", args=["level"])
  22. def run_test(self):
  23. """
  24. Summary:
  25. Interact with View Menu options and verify if all the options are working.
  26. Expected Behavior:
  27. The View menu functions normally.
  28. Test Steps:
  29. 1) Create a temp level
  30. 2) Interact with View Menu options
  31. Note:
  32. - This test file must be called from the Lumberyard Editor command terminal
  33. - Any passed and failed tests are written to the Editor.log file.
  34. Parsing the file or running a log_monitor are required to observe the test results.
  35. :return: None
  36. """
  37. view_menu_options = [
  38. ("Center on Selection",),
  39. ("Show Quick Access Bar",),
  40. ("Viewport", "Wireframe"),
  41. ("Viewport", "Grid Settings"),
  42. ("Viewport", "Go to Position"),
  43. ("Viewport", "Center on Selection"),
  44. ("Viewport", "Go to Location"),
  45. ("Viewport", "Remember Location"),
  46. ("Viewport", "Change Move Speed"),
  47. ("Viewport", "Switch Camera"),
  48. ("Viewport", "Show/Hide Helpers"),
  49. ("Refresh Style",),
  50. ]
  51. # 1) Create and open the temp level
  52. self.test_success = self.create_level(
  53. self.args["level"],
  54. heightmap_resolution=1024,
  55. heightmap_meters_per_pixel=1,
  56. terrain_texture_resolution=4096,
  57. use_terrain=False,
  58. )
  59. def on_action_triggered(action_name):
  60. print(f"{action_name} Action triggered")
  61. # 2) Interact with View Menu options
  62. try:
  63. editor_window = pyside_utils.get_editor_main_window()
  64. for option in view_menu_options:
  65. action = pyside_utils.get_action_for_menu_path(editor_window, "View", *option)
  66. trig_func = lambda: on_action_triggered(action.iconText())
  67. action.triggered.connect(trig_func)
  68. action.trigger()
  69. action.triggered.disconnect(trig_func)
  70. except Exception as e:
  71. self.test_success = False
  72. print(e)
  73. test = TestViewMenuOptions()
  74. test.run()