Rename to final folder name

This commit is contained in:
AMZN-AlexOteiza
2021-09-10 14:29:17 +02:00
parent ddd662f6b9
commit 5441ab4bac
160 changed files with 0 additions and 0 deletions
@@ -0,0 +1,92 @@
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
Test case ID : C19578021
Test Case Title : Verify that a shape collider component may be added to an entity along with one or more PhysX collider components
"""
# fmt: off
class Tests():
create_collider_entity = ("Created Collider Entity", "Failed to create Collider Entity")
add_physx_shape_collider = ("PhysX Shape Collider added", "Failed to add PhysX Shape Collider")
add_box_shape = ("Box Shape added", "Failed to add Box Shape")
add_physx_collider = ("PhysX Collider added", "Failed to add PhysX Collider")
no_warnings_found = ("Trace found no warnings", "One or more components has been removed")
# fmt: on
def ShapeCollider_CanBeAddedWitNoWarnings():
"""
Summary:
Adding a PhysX Collider component when a PhysX Shape Collider and Box Shape components are already present
Expected Behavior:
When adding the PhysX Collider, there should be no warnings in the entity outliner
Test Steps:
1) Load the empty level
2) Create an entity
3) Add the PhysX Shape Collider and a Box Shape components
4) Start the Tracer to catch any warnings while adding the PhysX Collider
5) Add the PhysX Collider component
6) Verify there are no warnings in the entity outliner
Note:
- This test file must be called from the Open 3D Engine Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
:return: None
"""
# Helper Files
from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
from editor_python_test_tools.utils import Tracer
# Open 3D Engine Imports
import azlmbr.legacy.general as general
helper.init_idle()
# 1) Load the empty level
helper.open_level("Physics", "Base")
# 2) Create an entity
collider_entity = Entity.create_editor_entity("Collider")
Report.result(Tests.create_collider_entity, collider_entity.id.IsValid())
# 3) Add the PhysX Shape Collider and a Box Shape components
collider_entity.add_component("PhysX Shape Collider")
Report.result(Tests.add_physx_shape_collider, collider_entity.has_component("PhysX Shape Collider"))
collider_entity.add_component("Box Shape")
Report.result(Tests.add_box_shape, collider_entity.has_component("Box Shape"))
# 4) Start the Tracer to catch any warnings while adding the PhysX Collider
with Tracer() as section_tracer:
# 5) Add the PhysX Collider component
collider_entity.add_component("PhysX Collider")
Report.result(Tests.add_physx_collider, collider_entity.has_component("PhysX Collider"))
# 6) Verify there are no warnings in the entity outliner
success_condition = not section_tracer.has_warnings and not section_tracer.has_errors
Report.result(Tests.no_warnings_found, success_condition)
if not success_condition:
exception_str = ""
if section_tracer.has_warnings:
exception_str += f"Warnings found: {section_tracer.warnings}\n"
if section_tracer.has_errors:
exception_str += f"Errors found: {section_tracer.errors}"
Report.failure(exception_str)
if __name__ == "__main__":
from editor_python_test_tools.utils import Report
Report.start_test(ShapeCollider_CanBeAddedWitNoWarnings)
@@ -0,0 +1,136 @@
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
# Test case ID : C24308873
# Test Case Title : Check that cylinder shape collider collides with terrain
# A cylinder is suspended slightly over PhysX Terrain to check that it collides when dropped
# fmt: off
class Tests():
enter_game_mode = ("Entered game mode", "Failed to enter game mode")
find_cylinder = ("Cylinder entity found", "Cylinder entity not found")
create_terrain = ("Terrain entity created successfully", "Failed to create Terrain Entity")
find_terrain = ("Terrain entity found", "Terrain entity not found")
add_physx_shape_collider = ("Added PhysX Shape Collider", "Failed to add PhysX Shape Collider")
add_box_shape = ("Added Box Shape", "Failed to add Box Shape")
cylinder_above_terrain = ("Cylinder position above ground", "Cylinder is not above the ground")
time_out = ("No time out occurred", "A time out occurred, please validate level setup")
touched_ground = ("Touched ground before time out", "Did not touch ground before time out")
exit_game_mode = ("Exited game mode", "Couldn't exit game mode")
# fmt: on
def ShapeCollider_CylinderShapeCollides():
"""
Summary:
Runs a test to make sure that a PhysX Rigid Body and Cylinder Shape Collider can successfully collide with a PhysX Terrain entity.
Level Description:
A cylinder with rigid body and collider is positioned above a PhysX terrain.
Expected Outcome:
Once game mode is entered, the cylinder should fall toward and collide with the terrain.
Steps:
1) Open level and create terrain Entity.
2) Enter Game Mode.
3) Retrieve entities and positions
4) Wait for cylinder to collide with terrain OR time out
5) Exit game mode
6) Close the editor
:return:
"""
import os
import sys
from editor_python_test_tools.editor_entity_utils import EditorEntity
import azlmbr.legacy.general as general
import azlmbr.bus
import azlmbr.math as math
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
# Global time out
TIME_OUT = 1.0
# 1) Open level
helper.init_idle()
helper.open_level("Physics", "ShapeCollider_CylinderShapeCollides")
# Create terrain entity
terrain = EditorEntity.create_editor_entity_at([30.0, 30.0, 33.96], "Terrain")
Report.result(Tests.create_terrain, terrain.id.IsValid())
terrain.add_component("PhysX Shape Collider")
Report.result(Tests.add_physx_shape_collider, terrain.has_component("PhysX Shape Collider"))
box_shape_component = terrain.add_component("Box Shape")
Report.result(Tests.add_box_shape, terrain.has_component("Box Shape"))
box_shape_component.set_component_property_value("Box Shape|Box Configuration|Dimensions",
math.Vector3(1024.0, 1024.0, 0.01))
# 2)Enter game mode
helper.enter_game_mode(Tests.enter_game_mode)
# 3) Retrieve entities and positions
cylinder_id = general.find_game_entity("PhysX_Cylinder")
Report.critical_result(Tests.find_cylinder, cylinder_id.IsValid())
terrain_id = general.find_game_entity("Terrain")
Report.critical_result(Tests.find_terrain, terrain_id.IsValid())
cylinder_pos = azlmbr.components.TransformBus(azlmbr.bus.Event, "GetWorldTranslation", cylinder_id)
#Cylinder position is 64,84,35
terrain_pos = azlmbr.components.TransformBus(azlmbr.bus.Event, "GetWorldTranslation", terrain_id)
Report.info_vector3(cylinder_pos, "Cylinder:")
Report.info_vector3(terrain_pos, "Terrain:")
Report.critical_result(
Tests.cylinder_above_terrain,
(cylinder_pos.z - terrain_pos.z) > 0.5,
"Please make sure the cylinder entity is set above the terrain",
)
# Enable gravity (just in case it is not enabled)
if not azlmbr.physics.RigidBodyRequestBus(azlmbr.bus.Event, "IsGravityEnabled", cylinder_id):
azlmbr.physics.RigidBodyRequestBus(azlmbr.bus.Event, "SetGravityEnabled", cylinder_id, True)
class TouchGround:
value = False
# Collision event handler
def on_collision_begin(args):
other_id = args[0]
if other_id.Equal(terrain_id):
Report.info("Touched ground")
TouchGround.value = True
# Assign event handler to cylinder
handler = azlmbr.physics.CollisionNotificationBusHandler()
handler.connect(cylinder_id)
handler.add_callback("OnCollisionBegin", on_collision_begin)
# 4) Wait for the cylinder to hit the ground OR time out
test_completed = helper.wait_for_condition((lambda: TouchGround.value), TIME_OUT)
Report.critical_result(Tests.time_out, test_completed)
Report.result(Tests.touched_ground, TouchGround.value)
# 5) Exit game mode
helper.exit_game_mode(Tests.exit_game_mode)
if __name__ == "__main__":
from editor_python_test_tools.utils import Report
Report.start_test(ShapeCollider_CylinderShapeCollides)
@@ -0,0 +1,94 @@
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
Test case ID : C19578018
Test Case Title : Verify that a shape collider component with no shape component indicates a missing service
"""
# fmt: off
class Tests():
create_collider_entity = ("Created Collider Entity", "Failed to create Collider Entity")
add_physx_shape_collider = ("PhysX Shape Collider added", "Failed to add PhysX Shape Collider")
collider_component_inactive = ("Collider component is Inactive", "Collider component is Active")
add_shape_component = ("Shape component added", "Failed to add Shape component")
collider_component_active = ("Collider component is active", "Collider component is inactive")
# fmt: on
def ShapeCollider_InactiveWhenNoShapeComponent():
"""
Summary:
Create an Entity with PhysX Shape Collider component and verify that PhysX Shape Collider Component
is inactive without shape component.
Expected Behavior:
The PhysX Shape Collider component should be inactive.
Verify that after a shape component is added, the warning goes away.
Test Steps:
1) Load the level
2) Add an entity with a PhysX Shape Collider component.
3) Validate Collider Entity
4) Validate PhysX Shape Collider component is inactive.
5) Add Shape component to Entity
6) Validate PhysX Shape Collider component is Active.
7) Close the editor
Note:
- This test file must be called from the Open 3D Engine Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
:return: None
"""
# Built-in Imports
# Helper Imports
from editor_python_test_tools.utils import Report
from editor_python_test_tools.editor_entity_utils import EditorEntity
from editor_python_test_tools.utils import TestHelper as helper
# Open 3D Engine Imports
import azlmbr.bus as bus
import azlmbr.editor as editor
def is_component_active(component_id) -> bool:
"""
Used to check if component is Active
:return: boolean, True if component is active, else False
"""
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", component_id)
helper.init_idle()
# 1) Load the level
helper.open_level("Physics", "Base")
# 2) Add an entity with a PhysX Shape Collider component.
collider = EditorEntity.create_editor_entity("Collider")
physx_component = collider.add_component("PhysX Shape Collider")
# 3) Validate Collider Entity
Report.result(Tests.create_collider_entity, collider.id.IsValid())
# 4) Validate PhysX Shape Collider component is inactive.
Report.result(Tests.add_physx_shape_collider, collider.has_component("PhysX Shape Collider"))
Report.result(Tests.collider_component_inactive, not is_component_active(physx_component.id))
# 5) Add Shape component to Entity
collider.add_component("Box Shape")
Report.result(Tests.add_shape_component, collider.has_component("Box Shape"))
# 6) Validate PhysX Shape Collider component is Active.
Report.result(Tests.collider_component_active, is_component_active(physx_component.id))
if __name__ == "__main__":
from editor_python_test_tools.utils import Report
Report.start_test(ShapeCollider_InactiveWhenNoShapeComponent)
@@ -0,0 +1,98 @@
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
Test case ID : C19723164
Test Case Title : Verify that if we had 512 shape colliders in the level, the level does not crash
"""
# fmt: off
class Tests():
all_entities_created = ("All 512 entities have been created", "Failed to create all 512 entities")
game_mode_entered = ("Entered Game Mode", "Failed to enter Game Mode")
game_mode_exited = ("Exited Game Mode", "Failed to exit Game Mode")
# fmt: on
def ShapeCollider_LargeNumberOfShapeCollidersWontCrashEditor():
"""
Summary:
Create 512 entities with shape colliders and verify stability
Expected Behavior:
After 512 Shape Collider entities exist, the editor should not crash or dip in FPS
Test Steps:
1) Load the empty level
2) Create 512 entities with PhysX Shape Collider and Sphere Shape components
3) Enter/Exit game mode and wait to see if editor crashes
4) Close the editor
Note:
- This test file must be called from the Open 3D Engine Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
:return: None
"""
# Helper Files
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity
# Open 3D Engine Imports
import azlmbr.legacy.general as general
def idle_editor_for_check():
"""
This will be used to verify that the editor has not crashed by increasing the duration the editor is kept open
"""
# Enter game mode
helper.enter_game_mode(Tests.game_mode_entered)
# Wait 60 frames
general.idle_wait_frames(60)
# Exit game mode
helper.exit_game_mode(Tests.game_mode_exited)
# Wait 60 frames more
general.idle_wait_frames(60)
helper.init_idle()
# 1) Load the empty level
helper.open_level("Physics", "Base")
# 2) Create 512 entities with PhysX Shape Collider and Sphere Shape components
entity_failure = False
for i in range(1, 513):
# Create Entity
entity = Entity.create_editor_entity(f"Entity_{i}")
# Add components
entity.add_component("PhysX Shape Collider")
if i % 3 == 0:
shape_component_name = "Capsule Shape"
elif i % 2 == 0:
shape_component_name = "Box Shape"
else:
shape_component_name = "Sphere Shape"
entity.add_component(shape_component_name)
# Verify the entity contains the components
components_added = entity.has_component("PhysX Shape Collider") and entity.has_component(shape_component_name)
if not components_added:
entity_failure = True
Report.info(f"Entity_{i} failed to add either PhysX Shape Collider or {shape_component_name}")
Report.result(Tests.all_entities_created, not entity_failure)
# 3) Enter/Exit game mode and wait to see if editor crashes
idle_editor_for_check()
if __name__ == "__main__":
from editor_python_test_tools.utils import Report
Report.start_test(ShapeCollider_LargeNumberOfShapeCollidersWontCrashEditor)