Opening_Closing_Pane.py 4.4 KB

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