Resizing_Pane.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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: C1702829
  10. Test Case Title: Resizing pane
  11. URLs of the test case: https://testrail.agscollab.com/index.php?/cases/view/1702829
  12. """
  13. # fmt: off
  14. class Tests():
  15. open_sc_window = ("Script Canvas window is opened", "Failed to open Script Canvas window")
  16. open_pane = ("Pane opened successfully", "Failed to open pane")
  17. resize_pane = ("Pane window resized successfully", "Failed to resize pane window")
  18. # fmt: on
  19. def Resizing_Pane():
  20. """
  21. Summary:
  22. The Script Canvas window is opened to verify if Script canvas panes can be resized and scaled
  23. Expected Behavior:
  24. The pane is resized and scaled appropriately.
  25. Test Steps:
  26. 1) Open Script Canvas window (Tools > Script Canvas)
  27. 2) Restore default layout
  28. 3) Make sure pane is opened
  29. 4) Resize pane
  30. 5) Restore default layout
  31. 6) Close Script Canvas window
  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. # Helper imports
  39. import ImportPathHelper as imports
  40. imports.init()
  41. from utils import Report
  42. from utils import TestHelper as helper
  43. import pyside_utils
  44. # Lumberyard imports
  45. import azlmbr.legacy.general as general
  46. # Pyside imports
  47. from PySide2 import QtWidgets
  48. PANE_WIDGET = "NodePalette"
  49. SCALE_INT = 10
  50. def click_menu_option(window, option_text):
  51. action = pyside_utils.find_child_by_pattern(window, {"text": option_text, "type": QtWidgets.QAction})
  52. action.trigger()
  53. def find_pane(window, pane_name):
  54. return window.findChild(QtWidgets.QDockWidget, pane_name)
  55. # Test starts here
  56. general.idle_enable(True)
  57. # 1) Open Script Canvas window (Tools > Script Canvas)
  58. general.open_pane("Script Canvas")
  59. is_sc_visible = helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0)
  60. Report.result(Tests.open_sc_window, is_sc_visible)
  61. # 2) Restore default layout
  62. editor_window = pyside_utils.get_editor_main_window()
  63. sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas")
  64. click_menu_option(sc, "Restore Default Layout")
  65. # 3) Make sure pane is opened
  66. editor_window = pyside_utils.get_editor_main_window()
  67. sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas")
  68. pane = find_pane(sc, PANE_WIDGET)
  69. if not pane.isVisible():
  70. click_menu_option(sc, "Node Palette")
  71. pane = find_pane(sc, PANE_WIDGET) # New reference
  72. Report.result(Tests.open_pane, pane.isVisible())
  73. # 4) Resize pane
  74. initial_size = pane.frameSize()
  75. pane.resize(initial_size.width() + SCALE_INT, initial_size.height() + SCALE_INT)
  76. new_size = pane.frameSize()
  77. test_success = (
  78. abs(initial_size.width() - new_size.width()) == abs(initial_size.height() - new_size.height()) == SCALE_INT
  79. )
  80. Report.result(Tests.resize_pane, test_success)
  81. # 5) Restore default layout
  82. # Needed this step to restore to default in case of test failure
  83. click_menu_option(sc, "Restore Default Layout")
  84. # 6) Close Script Canvas window
  85. sc.close()
  86. if __name__ == "__main__":
  87. import ImportPathHelper as imports
  88. imports.init()
  89. from utils import Report
  90. Report.start_test(Resizing_Pane)