3
0

Debugger_HappyPath_TargetMultipleEntities.py 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. LEVEL_NAME = "tmp_level"
  48. ASSET_NAME_1 = "ScriptCanvas_TwoComponents0.scriptcanvas"
  49. ASSET_NAME_2 = "ScriptCanvas_TwoComponents1.scriptcanvas"
  50. ASSET_1 = os.path.join("scriptcanvas", ASSET_NAME_1)
  51. ASSET_2 = os.path.join("scriptcanvas", ASSET_NAME_2)
  52. WAIT_TIME = 3.0
  53. def get_asset(asset_path):
  54. return asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", asset_path, math.Uuid(), False)
  55. # 1) Create temp level
  56. general.idle_enable(True)
  57. result = general.create_level_no_prompt(LEVEL_NAME, 128, 1, 512, True)
  58. Report.critical_result(Tests.level_created, result == 0)
  59. helper.wait_for_condition(lambda: general.get_current_level_name() == LEVEL_NAME, WAIT_TIME)
  60. general.close_pane("Error Report")
  61. # 2) Create two entities with scriptcanvas components
  62. position = math.Vector3(512.0, 512.0, 32.0)
  63. test_entity_1 = hydra.Entity("test_entity_1")
  64. test_entity_1.create_entity(position, ["Script Canvas"])
  65. test_entity_2 = hydra.Entity("test_entity_2")
  66. test_entity_2.create_entity(position, ["Script Canvas"])
  67. # 3) Set values for scriptcanvas
  68. test_entity_1.get_set_test(0, "Script Canvas Asset|Script Canvas Asset", get_asset(ASSET_1))
  69. test_entity_2.get_set_test(0, "Script Canvas Asset|Script Canvas Asset", get_asset(ASSET_2))
  70. # 4) Open Script Canvas window and get sc opbject
  71. general.open_pane("Script Canvas")
  72. editor_window = pyside_utils.get_editor_main_window()
  73. sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas")
  74. # 5) Open Debugging(Logging) window
  75. if (
  76. sc.findChild(QtWidgets.QDockWidget, "LoggingWindow") is None
  77. or not sc.findChild(QtWidgets.QDockWidget, "LoggingWindow").isVisible()
  78. ):
  79. action = pyside_utils.find_child_by_pattern(sc, {"text": "Debugging", "type": QtWidgets.QAction})
  80. action.trigger()
  81. logging_window = sc.findChild(QtWidgets.QDockWidget, "LoggingWindow")
  82. # 6) Click on Entities tab in logging window
  83. button = pyside_utils.find_child_by_pattern(logging_window, {"type": QtWidgets.QPushButton, "text": "Entities"})
  84. button.click()
  85. # 7) Verify if the scriptcanvas exist under entities
  86. entities = logging_window.findChild(QtWidgets.QWidget, "entitiesPage")
  87. tree = entities.findChild(QtWidgets.QTreeView, "pivotTreeView")
  88. asset_1_mi = pyside_utils.find_child_by_pattern(tree, ASSET_NAME_1.lower())
  89. asset_2_mi = pyside_utils.find_child_by_pattern(tree, ASSET_NAME_2.lower())
  90. result = asset_1_mi is not None and asset_2_mi is not None
  91. Report.critical_result(Tests.entities_found, result)
  92. # 8) Verify if the entities can be selected
  93. tree.expandAll()
  94. tree.model().setData(asset_1_mi, 2, Qt.CheckStateRole)
  95. tree.model().setData(asset_2_mi, 2, Qt.CheckStateRole)
  96. checklist = [asset_1_mi, asset_1_mi.parent(), asset_2_mi, asset_2_mi.parent()]
  97. result = all([index.data(Qt.CheckStateRole) == 2 for index in checklist])
  98. Report.critical_result(Tests.select_multiple_targets, result)
  99. # 9) Close Debugging window and Script Canvas window
  100. logging_window.close()
  101. general.close_pane("Script Canvas")
  102. if __name__ == "__main__":
  103. import ImportPathHelper as imports
  104. imports.init()
  105. from utils import Report
  106. Report.start_test(Debugger_HappyPath_TargetMultipleEntities)