Menus_FileMenuOptions.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. C24064528: The File menu options function normally
  12. C16780778: The File menu options function normally-New view interaction Model enabled
  13. """
  14. import os
  15. import sys
  16. import azlmbr.paths
  17. sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
  18. from automatedtesting_shared.editor_test_helper import EditorTestHelper
  19. import automatedtesting_shared.pyside_utils as pyside_utils
  20. class TestFileMenuOptions(EditorTestHelper):
  21. def __init__(self):
  22. EditorTestHelper.__init__(self, log_prefix="file_menu_options: ", args=["level"])
  23. def run_test(self):
  24. """
  25. Summary:
  26. Interact with File Menu options and verify if all the options are working.
  27. Expected Behavior:
  28. The File menu functions normally.
  29. Test Steps:
  30. 1) Open level
  31. 2) Interact with File Menu options
  32. Note:
  33. - This test file must be called from the Lumberyard Editor command terminal
  34. - Any passed and failed tests are written to the Editor.log file.
  35. Parsing the file or running a log_monitor are required to observe the test results.
  36. :return: None
  37. """
  38. file_menu_options = [
  39. ("New Level",),
  40. ("Open Level",),
  41. ("Import",),
  42. ("Save",),
  43. ("Save As",),
  44. ("Save Level Statistics",),
  45. ("Project Settings", "Project Settings Tool"),
  46. ("Show Log File",),
  47. ("Resave All Slices",),
  48. ("Exit",),
  49. ]
  50. # 1) Open level
  51. self.test_success = self.create_level(
  52. self.args["level"],
  53. heightmap_resolution=1024,
  54. heightmap_meters_per_pixel=1,
  55. terrain_texture_resolution=4096,
  56. use_terrain=False,
  57. )
  58. def on_action_triggered(action_name):
  59. print(f"{action_name} Action triggered")
  60. # 2) Interact with File Menu options
  61. try:
  62. editor_window = pyside_utils.get_editor_main_window()
  63. for option in file_menu_options:
  64. action = pyside_utils.get_action_for_menu_path(editor_window, "File", *option)
  65. trig_func = lambda: on_action_triggered(action.iconText())
  66. action.triggered.connect(trig_func)
  67. action.trigger()
  68. action.triggered.disconnect(trig_func)
  69. except Exception as e:
  70. self.test_success = False
  71. print(e)
  72. test = TestFileMenuOptions()
  73. test.run()