Integrating latest 47acbe8
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
"""
|
||||
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
its licensors.
|
||||
|
||||
For complete copyright and license terms please see the LICENSE at the root of this
|
||||
distribution (the "License"). All use of this software is governed by the License,
|
||||
or, if provided, by the license below or the license accompanying this file. Do not
|
||||
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
"""
|
||||
|
||||
|
||||
# Test case ID : C14976307
|
||||
# Test Case Title : Check that Set Gravity Enabled works on an entity with gravity that starts as disabled
|
||||
# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/14976307
|
||||
|
||||
|
||||
# fmt: off
|
||||
class Tests():
|
||||
enter_game_mode = ("Entered game mode", "Failed to enter game mode")
|
||||
find_entities = ("Entities are found", "Entities are not found")
|
||||
gravity_initially_disabled = ("Gravity was initially disabled", "Gravity was initially enabled")
|
||||
gravity_enabled = ("Enabled gravity successfully", "Failed to enable gravity")
|
||||
collision_occured = ("Sphere collided with terrain", "Sphere did not collide with terrain")
|
||||
exit_game_mode = ("Exited game mode", "Couldn't exit game mode")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def C14976307_Gravity_SetGravityWorks():
|
||||
|
||||
"""
|
||||
Summary:
|
||||
Check that Set Gravity Enabled works on an entity with gravity that starts as disabled
|
||||
|
||||
Level Description:
|
||||
Terrain (entity) - Terrain entity is created in the level
|
||||
Sphere (entity) - Entity with PhysX rigid body, mesh and collider with gravity disabled placed above
|
||||
the terrain
|
||||
|
||||
Expected Behavior:
|
||||
After 5 seconds, when SetGravity is called, the entity falls to the ground
|
||||
We are checking if entities are valid and enabling the gravity after 5 seconds in game mode to check if ball
|
||||
falls on the terrain.
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Enter game mode
|
||||
3) Retrieve and validate entities
|
||||
4) Gravity check for entity
|
||||
5) Enabling gravity after 5 seconds
|
||||
6) Adding collision handlers for terrain
|
||||
7) Checking if the object collides with terrain
|
||||
8) Exit game mode
|
||||
9) Close the editor
|
||||
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Lumberyard 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
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import ImportPathHelper as imports
|
||||
|
||||
imports.init()
|
||||
|
||||
|
||||
from utils import Report
|
||||
from utils import TestHelper as helper
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.bus
|
||||
|
||||
# Constants
|
||||
TIME_OUT = 3.0
|
||||
WAIT_TIME = 5.0
|
||||
|
||||
helper.init_idle()
|
||||
|
||||
# 1) Open level
|
||||
helper.open_level("Physics", "C14976307_Gravity_SetGravityWorks")
|
||||
|
||||
# 2) Enter game mode
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
|
||||
# 3) Retrieve and validate entities
|
||||
terrain_id = general.find_game_entity("Terrain")
|
||||
sphere_id = general.find_game_entity("Sphere")
|
||||
Report.critical_result(Tests.find_entities, terrain_id.IsValid() and sphere_id.IsValid())
|
||||
|
||||
sphere_gravity_enabled = False
|
||||
class Sphere:
|
||||
sphere_collision_occured = False
|
||||
|
||||
# 4) Gravity check for entities
|
||||
sphere_gravity_enabled = azlmbr.physics.RigidBodyRequestBus(azlmbr.bus.Event, "IsGravityEnabled", sphere_id)
|
||||
Report.result(Tests.gravity_initially_disabled, not sphere_gravity_enabled)
|
||||
|
||||
# 5) Adding collision handlers for terrain
|
||||
def on_collision_begin(args):
|
||||
other_id = args[0]
|
||||
if other_id.Equal(sphere_id):
|
||||
Report.info("Sphere collided with the terrain")
|
||||
Sphere.sphere_collision_occured = True
|
||||
|
||||
handler = azlmbr.physics.CollisionNotificationBusHandler()
|
||||
handler.connect(terrain_id)
|
||||
handler.add_callback("OnCollisionBegin", on_collision_begin)
|
||||
|
||||
# 6) Enabling gravity after 5 seconds
|
||||
general.idle_wait(WAIT_TIME)
|
||||
azlmbr.physics.RigidBodyRequestBus(azlmbr.bus.Event, "SetGravityEnabled", sphere_id, True)
|
||||
sphere_gravity_enabled = azlmbr.physics.RigidBodyRequestBus(azlmbr.bus.Event, "IsGravityEnabled", sphere_id)
|
||||
Report.result(Tests.gravity_enabled, sphere_gravity_enabled)
|
||||
|
||||
# 7) Checking if the object collides with terrain
|
||||
helper.wait_for_condition(lambda: Sphere.sphere_collision_occured, TIME_OUT)
|
||||
Report.result(Tests.collision_occured, Sphere.sphere_collision_occured)
|
||||
|
||||
# 8) Exit game mode
|
||||
helper.exit_game_mode(Tests.exit_game_mode)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import ImportPathHelper as imports
|
||||
imports.init()
|
||||
|
||||
from utils import Report
|
||||
Report.start_test(C14976307_Gravity_SetGravityWorks)
|
||||
Reference in New Issue
Block a user