ShapeCollider_LargeNumberOfShapeCollidersWontCrashEditor.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 : C19723164
  6. Test Case Title : Verify that if we had 512 shape colliders in the level, the level does not crash
  7. """
  8. # fmt: off
  9. class Tests():
  10. all_entities_created = ("All 512 entities have been created", "Failed to create all 512 entities")
  11. game_mode_entered = ("Entered Game Mode", "Failed to enter Game Mode")
  12. game_mode_exited = ("Exited Game Mode", "Failed to exit Game Mode")
  13. # fmt: on
  14. def ShapeCollider_LargeNumberOfShapeCollidersWontCrashEditor():
  15. """
  16. Summary:
  17. Create 512 entities with shape colliders and verify stability
  18. Expected Behavior:
  19. After 512 Shape Collider entities exist, the editor should not crash or dip in FPS
  20. Test Steps:
  21. 1) Load the empty level
  22. 2) Create 512 entities with PhysX Shape Collider and Sphere Shape components
  23. 3) Enter/Exit game mode and wait to see if editor crashes
  24. 4) Close the editor
  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. # Helper Files
  32. from editor_python_test_tools.utils import Report
  33. from editor_python_test_tools.utils import TestHelper as helper
  34. from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity
  35. from consts.physics import PHYSX_SHAPE_COLLIDER
  36. import editor_python_test_tools.hydra_editor_utils as hydra
  37. # Open 3D Engine Imports
  38. import azlmbr.legacy.general as general
  39. def idle_editor_for_check():
  40. """
  41. This will be used to verify that the editor has not crashed by increasing the duration the editor is kept open
  42. """
  43. # Enter game mode
  44. helper.enter_game_mode(Tests.game_mode_entered)
  45. # Wait 60 frames
  46. general.idle_wait_frames(60)
  47. # Exit game mode
  48. helper.exit_game_mode(Tests.game_mode_exited)
  49. # Wait 60 frames more
  50. general.idle_wait_frames(60)
  51. # 1) Load the empty level
  52. hydra.open_base_level()
  53. # 2) Create 512 entities with PhysX Shape Collider and Sphere Shape components
  54. entity_failure = False
  55. for i in range(1, 513):
  56. # Create Entity
  57. entity = Entity.create_editor_entity(f"Entity_{i}")
  58. entity.add_component("PhysX Static Rigid Body")
  59. # Add components
  60. entity.add_component(PHYSX_SHAPE_COLLIDER)
  61. if i % 3 == 0:
  62. shape_component_name = "Capsule Shape"
  63. elif i % 2 == 0:
  64. shape_component_name = "Box Shape"
  65. else:
  66. shape_component_name = "Sphere Shape"
  67. entity.add_component(shape_component_name)
  68. # Verify the entity contains the components
  69. components_added = entity.has_component(PHYSX_SHAPE_COLLIDER) and entity.has_component(shape_component_name)
  70. if not components_added:
  71. entity_failure = True
  72. Report.info(f"Entity_{i} failed to add either PhysX Shape Collider or {shape_component_name}")
  73. Report.result(Tests.all_entities_created, not entity_failure)
  74. # 3) Enter/Exit game mode and wait to see if editor crashes
  75. idle_editor_for_check()
  76. if __name__ == "__main__":
  77. from editor_python_test_tools.utils import Report
  78. Report.start_test(ShapeCollider_LargeNumberOfShapeCollidersWontCrashEditor)