Debugger_HappyPath_TargetMultipleEntities.py 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. level_created = ("New level created", "New level not created")
  9. entities_found = ("Entities are found in Logging window", "Entities are not found in Logging window")
  10. select_multiple_targets = ("Multiple targets are selected", "Multiple targets are not selected")
  11. # fmt: on
  12. GENERAL_WAIT = 0.5 # seconds
  13. def Debugger_HappyPath_TargetMultipleEntities():
  14. """
  15. Summary:
  16. Multiple Entities can be targeted in the Debugger tool
  17. Expected Behavior:
  18. Multiple selected files can be checked for logging.
  19. Upon checking, checkboxes of the parent folders change to either full or partial check.
  20. Test Steps:
  21. 1) Create temp level
  22. 2) Create two entities with scriptcanvas components
  23. 3) Set values for scriptcanvas
  24. 4) Open Script Canvas window and get sc object
  25. 5) Open Debugging(Logging) window
  26. 6) Click on Entities tab in logging window
  27. 7) Verify if the scriptcanvas exist under entities
  28. 8) Verify if the entities can be selected
  29. 9) Close Debugging window and Script Canvas window
  30. Note:
  31. - This test file must be called from the Open 3D Engine Editor command terminal
  32. - Any passed and failed tests are written to the Editor.log file.
  33. Parsing the file or running a log_monitor are required to observe the test results.
  34. :return: None
  35. """
  36. from PySide2 import QtWidgets
  37. from PySide2.QtCore import Qt
  38. import azlmbr.legacy.general as general
  39. import azlmbr.math as math
  40. import azlmbr.asset as asset
  41. import azlmbr.bus as bus
  42. import os
  43. import pyside_utils
  44. import hydra_editor_utils as hydra
  45. from utils import TestHelper as helper
  46. from utils import Report
  47. TEMPLATE_NAME ="lvl_template_name"
  48. LEVEL_NAME = "tmp_level"
  49. ASSET_NAME_1 = "ScriptCanvas_TwoComponents0.scriptcanvas"
  50. ASSET_NAME_2 = "ScriptCanvas_TwoComponents1.scriptcanvas"
  51. ASSET_1 = os.path.join("scriptcanvas", ASSET_NAME_1)
  52. ASSET_2 = os.path.join("scriptcanvas", ASSET_NAME_2)
  53. WAIT_TIME = 3.0
  54. def get_asset(asset_path):
  55. return asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", asset_path, math.Uuid(), False)
  56. # 1) Create temp level
  57. general.idle_enable(True)
  58. result = general.create_level_no_prompt(TEMPLATE_NAME, LEVEL_NAME, 128, 1, 512, True)
  59. Report.critical_result(Tests.level_created, result == 0)
  60. helper.wait_for_condition(lambda: general.get_current_level_name() == LEVEL_NAME, WAIT_TIME)
  61. general.close_pane("Error Report")
  62. # 2) Create two entities with scriptcanvas components
  63. position = math.Vector3(512.0, 512.0, 32.0)
  64. test_entity_1 = hydra.Entity("test_entity_1")
  65. test_entity_1.create_entity(position, ["Script Canvas"])
  66. test_entity_2 = hydra.Entity("test_entity_2")
  67. test_entity_2.create_entity(position, ["Script Canvas"])
  68. # 3) Set values for scriptcanvas
  69. test_entity_1.get_set_test(0, "Script Canvas Asset|Script Canvas Asset", get_asset(ASSET_1))
  70. test_entity_2.get_set_test(0, "Script Canvas Asset|Script Canvas Asset", get_asset(ASSET_2))
  71. # 4) Open Script Canvas window and get sc opbject
  72. general.open_pane("Script Canvas")
  73. editor_window = pyside_utils.get_editor_main_window()
  74. sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas")
  75. # 5) Open Debugging(Logging) window
  76. if (
  77. sc.findChild(QtWidgets.QDockWidget, "LoggingWindow") is None
  78. or not sc.findChild(QtWidgets.QDockWidget, "LoggingWindow").isVisible()
  79. ):
  80. action = pyside_utils.find_child_by_pattern(sc, {"text": "Debugging", "type": QtWidgets.QAction})
  81. action.trigger()
  82. logging_window = sc.findChild(QtWidgets.QDockWidget, "LoggingWindow")
  83. # 6) Click on Entities tab in logging window
  84. button = pyside_utils.find_child_by_pattern(logging_window, {"type": QtWidgets.QPushButton, "text": "Entities"})
  85. button.click()
  86. # 7) Verify if the scriptcanvas exist under entities
  87. entities = logging_window.findChild(QtWidgets.QWidget, "entitiesPage")
  88. tree = entities.findChild(QtWidgets.QTreeView, "pivotTreeView")
  89. asset_1_mi = pyside_utils.find_child_by_pattern(tree, ASSET_NAME_1.lower())
  90. asset_2_mi = pyside_utils.find_child_by_pattern(tree, ASSET_NAME_2.lower())
  91. result = asset_1_mi is not None and asset_2_mi is not None
  92. Report.critical_result(Tests.entities_found, result)
  93. # 8) Verify if the entities can be selected
  94. tree.expandAll()
  95. tree.model().setData(asset_1_mi, 2, Qt.CheckStateRole)
  96. tree.model().setData(asset_2_mi, 2, Qt.CheckStateRole)
  97. checklist = [asset_1_mi, asset_1_mi.parent(), asset_2_mi, asset_2_mi.parent()]
  98. result = all([index.data(Qt.CheckStateRole) == 2 for index in checklist])
  99. Report.critical_result(Tests.select_multiple_targets, result)
  100. # 9) Close Debugging window and Script Canvas window
  101. logging_window.close()
  102. general.close_pane("Script Canvas")
  103. if __name__ == "__main__":
  104. import ImportPathHelper as imports
  105. imports.init()
  106. from utils import Report
  107. Report.start_test(Debugger_HappyPath_TargetMultipleEntities)