2
0

Entity_HappyPath_AddScriptCanvasComponent.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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", "Failed to create new level")
  9. entity_created = ("Test Entity created", "Failed to create test entity")
  10. add_sc_component = ("Script Canvas component added to entity", "Failed to add SC component to entity")
  11. no_errors_found = ("Tracer found no errors", "One or more errors found by Tracer")
  12. no_warnings_found = ("Tracer found no warnings", "One or more warnings found by Tracer")
  13. # fmt: on
  14. def Entity_HappyPath_AddScriptCanvasComponent():
  15. """
  16. Summary:
  17. Script Canvas Component can be added to an entity
  18. Expected Behavior:
  19. Script Canvas Component is added to the entity successfully without issue
  20. Test Steps:
  21. 1) Open the base level
  22. 2) Create test entity
  23. 3) Start Tracer
  24. 4) Add Script Canvas component to test entity and check for errors
  25. Note:
  26. - This test file must be called from the Open 3D Engine Editor command terminal
  27. - Any passed and failed tests are written to the Editor.log file.
  28. Parsing the file or running a log_monitor are required to observe the test results.
  29. :return: None
  30. """
  31. from utils import TestHelper as helper
  32. from utils import Tracer
  33. from editor_python_test_tools.editor_entity_utils import EditorEntity
  34. import azlmbr.legacy.general as general
  35. import azlmbr.math as math
  36. from scripting_utils.scripting_constants import (SCRIPT_CANVAS_UI)
  37. TEST_ENTITY_NAME = "test_entity"
  38. general.idle_enable(True)
  39. # 1) Open the base level
  40. helper.open_level("", "Base")
  41. general.close_pane("Error Report")
  42. # 2) Create new entity
  43. position = math.Vector3(512.0, 512.0, 32.0)
  44. editor_entity = EditorEntity.create_editor_entity_at(position, TEST_ENTITY_NAME)
  45. Report.result(Tests.entity_created, editor_entity.id.IsValid())
  46. # 3) Start Tracer
  47. with Tracer() as section_tracer:
  48. # 4) Add Script Canvas component to test entity and check for errors
  49. editor_entity.add_component(SCRIPT_CANVAS_UI)
  50. Report.result(Tests.add_sc_component, editor_entity.has_component(SCRIPT_CANVAS_UI))
  51. if __name__ == "__main__":
  52. import ImportPathHelper as imports
  53. imports.init()
  54. from utils import Report
  55. Report.start_test(Entity_HappyPath_AddScriptCanvasComponent)