ShapeCollider_CanBeAddedWitNoWarnings.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. Test case ID : C19578021
  6. Test Case Title : Verify that a shape collider component may be added to an entity along with one or more PhysX collider components
  7. """
  8. # fmt: off
  9. class Tests():
  10. create_collider_entity = ("Created Collider Entity", "Failed to create Collider Entity")
  11. add_physx_shape_collider = ("PhysX Shape Collider added", "Failed to add PhysX Shape Collider")
  12. add_box_shape = ("Box Shape added", "Failed to add Box Shape")
  13. add_physx_primitive_collider = ("PhysX Primitive Collider added", "Failed to add PhysX Primitive Collider")
  14. add_physx_mesh_collider = ("PhysX Mesh Collider added", "Failed to add PhysX Mesh Collider")
  15. no_warnings_found = ("Trace found no warnings", "One or more components has been removed")
  16. # fmt: on
  17. def ShapeCollider_CanBeAddedWitNoWarnings():
  18. """
  19. Summary:
  20. Adding a PhysX Primitive Collider and PhysX Mesh Collider components when a PhysX Shape Collider and Box Shape components are already present
  21. Expected Behavior:
  22. When adding the PhysX Primitive Collider and PhysX Mesh Collider, there should be no warnings in the entity outliner
  23. Test Steps:
  24. 1) Load the empty level
  25. 2) Create an entity
  26. 3) Add the PhysX Shape Collider and a Box Shape components
  27. 4) Start the Tracer to catch any warnings
  28. 5) Add the PhysX Primitive Collider component
  29. 6) Add the PhysX Mesh Collider component
  30. 7) Verify there are no warnings in the entity outliner
  31. Note:
  32. - This test file must be called from the Open 3D Engine Editor command terminal
  33. - Any passed and failed tests are written to the Editor.log file.
  34. Parsing the file or running a log_monitor are required to observe the test results.
  35. :return: None
  36. """
  37. # Helper Files
  38. from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity
  39. from editor_python_test_tools.utils import Report
  40. from editor_python_test_tools.utils import TestHelper as helper
  41. from editor_python_test_tools.utils import Tracer
  42. from consts.physics import PHYSX_PRIMITIVE_COLLIDER
  43. from consts.physics import PHYSX_SHAPE_COLLIDER
  44. from consts.physics import PHYSX_MESH_COLLIDER
  45. import editor_python_test_tools.hydra_editor_utils as hydra
  46. # Open 3D Engine Imports
  47. import azlmbr.legacy.general as general
  48. # 1) Load the empty level
  49. hydra.open_base_level()
  50. # 2) Create an entity
  51. collider_entity = Entity.create_editor_entity("Collider")
  52. collider_entity.add_component("PhysX Static Rigid Body")
  53. Report.result(Tests.create_collider_entity, collider_entity.id.IsValid())
  54. # 3) Add the PhysX Shape Collider and a Box Shape components
  55. collider_entity.add_component(PHYSX_SHAPE_COLLIDER)
  56. Report.result(Tests.add_physx_shape_collider, collider_entity.has_component(PHYSX_SHAPE_COLLIDER))
  57. collider_entity.add_component("Box Shape")
  58. Report.result(Tests.add_box_shape, collider_entity.has_component("Box Shape"))
  59. # 4) Start the Tracer to catch any warnings while adding the PhysX Collider
  60. with Tracer() as section_tracer:
  61. # 5) Add the PhysX Primitive Collider component
  62. collider_entity.add_component(PHYSX_PRIMITIVE_COLLIDER)
  63. Report.result(Tests.add_physx_primitive_collider, collider_entity.has_component(PHYSX_PRIMITIVE_COLLIDER))
  64. # 6) Add the PhysX Mesh Collider component
  65. collider_entity.add_component(PHYSX_MESH_COLLIDER)
  66. Report.result(Tests.add_physx_mesh_collider, collider_entity.has_component(PHYSX_MESH_COLLIDER))
  67. # 7) Verify there are no warnings in the entity outliner
  68. success_condition = not section_tracer.has_warnings and not section_tracer.has_errors
  69. Report.result(Tests.no_warnings_found, success_condition)
  70. if not success_condition:
  71. exception_str = ""
  72. if section_tracer.has_warnings:
  73. exception_str += f"Warnings found: {section_tracer.warnings}\n"
  74. if section_tracer.has_errors:
  75. exception_str += f"Errors found: {section_tracer.errors}"
  76. Report.failure(exception_str)
  77. if __name__ == "__main__":
  78. from editor_python_test_tools.utils import Report
  79. Report.start_test(ShapeCollider_CanBeAddedWitNoWarnings)