Pane_HappyPath_OpenCloseSuccessfully.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. # fmt: off
  7. class Tests():
  8. default_visible = ("All the panes visible by default", "One or more panes do not visible by default")
  9. open_panes = ("All the Panes opened successfully", "Failed to open one or more panes")
  10. close_pane = ("All the Panes closed successfully", "Failed to close one or more panes")
  11. # fmt: on
  12. def Pane_HappyPath_OpenCloseSuccessfully():
  13. """
  14. Summary:
  15. The Script Canvas window is opened to verify if Script Canvas panes can be opened and closed.
  16. Expected Behavior:
  17. The panes open and close successfully.
  18. Test Steps:
  19. 1) Open Script Canvas window (Tools > Script Canvas)
  20. 2) Restore default layout
  21. 3) Verify if panes were opened by default
  22. 4) Close the opened panes
  23. 5) Open Script Canvas panes (Tools > <pane>)
  24. 6) Restore default layout
  25. 7) Close Script Canvas window
  26. Note:
  27. - This test file must be called from the Open 3D Engine Editor command terminal
  28. - Any passed and failed tests are written to the Editor.log file.
  29. Parsing the file or running a log_monitor are required to observe the test results.
  30. :return: None
  31. """
  32. from editor_python_test_tools.utils import Report
  33. from editor_python_test_tools.utils import TestHelper as helper
  34. import pyside_utils
  35. # Open 3D Engine Imports
  36. import azlmbr.legacy.general as general
  37. # Pyside imports
  38. from PySide2 import QtWidgets
  39. PANE_WIDGETS = ("NodePalette", "VariableManager")
  40. def click_menu_option(window, option_text):
  41. action = pyside_utils.find_child_by_pattern(window, {"text": option_text, "type": QtWidgets.QAction})
  42. action.trigger()
  43. def find_pane(window, pane_name):
  44. return window.findChild(QtWidgets.QDockWidget, pane_name)
  45. def is_pane_visible(window, pane_name):
  46. pane = find_pane(window, pane_name)
  47. return pane.isVisible()
  48. # Test starts here
  49. general.idle_enable(True)
  50. # 1) Open Script Canvas window (Tools > Script Canvas)
  51. general.open_pane("Script Canvas")
  52. helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0)
  53. # 2) Restore default layout
  54. editor_window = pyside_utils.get_editor_main_window()
  55. sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas")
  56. click_menu_option(sc, "Restore Default Layout")
  57. # 3) Verify if panes were opened by default
  58. PANES_VISIBLE = all(is_pane_visible(sc, pane) for pane in PANE_WIDGETS)
  59. Report.critical_result(Tests.default_visible, PANES_VISIBLE)
  60. # 4) Close the opened panes
  61. for item in PANE_WIDGETS:
  62. pane = sc.findChild(QtWidgets.QDockWidget, item)
  63. pane.close()
  64. if pane.isVisible():
  65. Report.info(f"Failed to close pane : {item}")
  66. PANES_VISIBLE = any(is_pane_visible(sc, pane) for pane in PANE_WIDGETS)
  67. Report.result(Tests.close_pane, not PANES_VISIBLE)
  68. # 5) Open Script Canvas panes (Tools > <pane>)
  69. click_menu_option(sc, "Node Palette")
  70. click_menu_option(sc, "Variable Manager")
  71. PANES_VISIBLE = helper.wait_for_condition(lambda: all(is_pane_visible(sc, pane) for pane in PANE_WIDGETS), 2.0)
  72. Report.result(Tests.open_panes, PANES_VISIBLE)
  73. # 6) Restore default layout
  74. # Needed this step to restore to default in case of test failure
  75. click_menu_option(sc, "Restore Default Layout")
  76. # 7) Close Script Canvas window
  77. sc.close()
  78. if __name__ == "__main__":
  79. import ImportPathHelper as imports
  80. imports.init()
  81. from editor_python_test_tools.utils import Report
  82. Report.start_test(Pane_HappyPath_OpenCloseSuccessfully)