Pane_HappyPath_ResizesProperly.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. open_pane = ("Pane opened successfully", "Failed to open pane")
  9. resize_pane = ("Pane window resized successfully", "Failed to resize pane window")
  10. # fmt: on
  11. def Pane_HappyPath_ResizesProperly():
  12. """
  13. Summary:
  14. The Script Canvas window is opened to verify if Script Canvas panes can be resized and scaled
  15. Expected Behavior:
  16. The pane is resized and scaled appropriately.
  17. Test Steps:
  18. 1) Open Script Canvas window (Tools > Script Canvas)
  19. 2) Restore default layout
  20. 3) Make sure pane is opened
  21. 4) Resize pane and verify change
  22. 5) Restore default layout
  23. 6) Close Script Canvas window
  24. Note:
  25. - This test file must be called from the Open 3D Engine Editor command terminal
  26. - Any passed and failed tests are written to the Editor.log file.
  27. Parsing the file or running a log_monitor are required to observe the test results.
  28. :return: None
  29. """
  30. from PySide2 import QtWidgets
  31. from editor_python_test_tools.utils import Report
  32. from editor_python_test_tools.utils import TestHelper as helper
  33. import pyside_utils
  34. # Open 3D Engine imports
  35. import azlmbr.legacy.general as general
  36. PANE_WIDGET = "NodePalette"
  37. SCALE_INT = 10
  38. def click_menu_option(window, option_text):
  39. action = pyside_utils.find_child_by_pattern(window, {"text": option_text, "type": QtWidgets.QAction})
  40. action.trigger()
  41. def find_pane(window, pane_name):
  42. return window.findChild(QtWidgets.QDockWidget, pane_name)
  43. # Test starts here
  44. general.idle_enable(True)
  45. # 1) Open Script Canvas window (Tools > Script Canvas)
  46. general.open_pane("Script Canvas")
  47. helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0)
  48. # 2) Restore default layout
  49. editor_window = pyside_utils.get_editor_main_window()
  50. sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas")
  51. click_menu_option(sc, "Restore Default Layout")
  52. # 3) Make sure pane is opened
  53. editor_window = pyside_utils.get_editor_main_window()
  54. sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas")
  55. pane = find_pane(sc, PANE_WIDGET)
  56. if not pane.isVisible():
  57. click_menu_option(sc, "Node Palette")
  58. pane = find_pane(sc, PANE_WIDGET) # New reference
  59. Report.result(Tests.open_pane, pane.isVisible())
  60. # 4) Resize pane and verify change
  61. initial_size = pane.frameSize()
  62. pane.resize(initial_size.width() + SCALE_INT, initial_size.height() + SCALE_INT)
  63. new_size = pane.frameSize()
  64. test_success = (
  65. abs(initial_size.width() - new_size.width()) == abs(initial_size.height() - new_size.height()) == SCALE_INT
  66. )
  67. Report.result(Tests.resize_pane, test_success)
  68. # 5) Restore default layout
  69. # Needed this step to restore to default in case of test failure
  70. click_menu_option(sc, "Restore Default Layout")
  71. # 6) Close Script Canvas window
  72. sc.close()
  73. if __name__ == "__main__":
  74. import ImportPathHelper as imports
  75. imports.init()
  76. from editor_python_test_tools.utils import Report
  77. Report.start_test(Pane_HappyPath_ResizesProperly)