Fixed all nits and took out the general module and its usage
This commit is contained in:
@@ -129,11 +129,10 @@ endif()
|
||||
NAME AutomatedTesting::PrefabTests
|
||||
TEST_SUITE main
|
||||
TEST_SERIAL
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/prefab/TestSuite_Active.py
|
||||
TIMEOUT 3600
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/prefab/TestSuite_Main.py
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
Legacy::CryRenderNULL
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
)
|
||||
|
||||
@@ -9,22 +9,19 @@ remove or modify any license notices. This file is distributed on an "AS IS" BAS
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
"""
|
||||
|
||||
|
||||
# fmt:off
|
||||
class Tests ():
|
||||
class Tests():
|
||||
find_empty_entity = ("Entity: 'EmptyEntity' found", "Entity: 'EmptyEntity' *not* found in level")
|
||||
empty_entity_pos = (
|
||||
"'EmptyEntity' position is at the expected position", "'EmptyEntity' position is *not* at the expected position")
|
||||
empty_entity_pos = ("'EmptyEntity' position is at the expected position", "'EmptyEntity' position is *not* at the expected position")
|
||||
find_pxentity = ("Entity: 'EntityWithPxCollider' found", "Entity: 'EntityWithPxCollider' *not* found in level")
|
||||
pxentity_component = (
|
||||
"Entity: 'EntityWithPxCollider' has a Physx Collider", "Entity: 'EntityWithPxCollider' has *not* a Physx Collider")
|
||||
pxentity_component = ("Entity: 'EntityWithPxCollider' has a Physx Collider", "Entity: 'EntityWithPxCollider' has *not* a Physx Collider")
|
||||
|
||||
# fmt:on
|
||||
|
||||
def PrefabLevel_OpensLevelWithEntities ():
|
||||
def PrefabLevel_OpensLevelWithEntities():
|
||||
"""
|
||||
Opens the level that contains 2 entities, "EmptyEntity" and "EntityWithPxCollider".
|
||||
This test makes sure that both entities exist after openning the level and that:
|
||||
This test makes sure that both entities exist after opening the level and that:
|
||||
- EmptyEntity is at Position: (10, 20, 30)
|
||||
- EntityWithPxCollider has a PhysXCollider component
|
||||
"""
|
||||
@@ -37,42 +34,41 @@ def PrefabLevel_OpensLevelWithEntities ():
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.bus
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.bus as bus
|
||||
from azlmbr.math import Vector3
|
||||
|
||||
EXPECTED_EMPTY_ENTITY_POS = Vector3 (10.00, 20.0, 30.0)
|
||||
EXPECTED_EMPTY_ENTITY_POS = Vector3(10.00, 20.0, 30.0)
|
||||
|
||||
helper.init_idle ()
|
||||
helper.open_level ("prefab", "PrefabLevel_OpensLevelWithEntities")
|
||||
helper.init_idle()
|
||||
helper.open_level("prefab", "PrefabLevel_OpensLevelWithEntities")
|
||||
|
||||
class EmptyEntity ():
|
||||
value = None
|
||||
def find_entity(entity_name):
|
||||
searchFilter = entity.SearchFilter()
|
||||
searchFilter.names = [entity_name]
|
||||
entityIds = entity.SearchBus(bus.Broadcast, 'SearchEntities', searchFilter)
|
||||
if entityIds[0].IsValid():
|
||||
return entityIds[0]
|
||||
return None
|
||||
|
||||
def find_empty_entity ():
|
||||
EmptyEntity.value = general.find_editor_entity ("EmptyEntity")
|
||||
return EmptyEntity.value.IsValid ()
|
||||
helper.wait_for_condition(lambda: find_entity("EmptyEntity").IsValid(), 5.0)
|
||||
empty_entity_id = find_entity("EmptyEntity")
|
||||
Report.result(Tests.find_empty_entity, empty_entity_id.IsValid())
|
||||
|
||||
helper.wait_for_condition (find_empty_entity, 5.0)
|
||||
Report.result (Tests.find_empty_entity, EmptyEntity.value.IsValid ())
|
||||
|
||||
empty_entity_pos = azlmbr.components.TransformBus (azlmbr.bus.Event, "GetWorldTranslation", EmptyEntity.value)
|
||||
is_at_position = empty_entity_pos.IsClose (EXPECTED_EMPTY_ENTITY_POS)
|
||||
Report.result (Tests.empty_entity_pos, is_at_position)
|
||||
empty_entity_pos = azlmbr.components.TransformBus(azlmbr.bus.Event, "GetWorldTranslation", empty_entity_id)
|
||||
is_at_position = empty_entity_pos.IsClose(EXPECTED_EMPTY_ENTITY_POS)
|
||||
Report.result(Tests.empty_entity_pos, is_at_position)
|
||||
if not is_at_position:
|
||||
Report.info (f'Expected position: {EXPECTED_EMPTY_ENTITY_POS.ToString ()}, actual position: {empty_entity_pos.ToString ()}')
|
||||
Report.info(f'Expected position: {EXPECTED_EMPTY_ENTITY_POS.ToString()}, actual position: {empty_entity_pos.ToString()}')
|
||||
|
||||
pxentity = general.find_editor_entity ("EntityWithPxCollider")
|
||||
Report.result (Tests.find_pxentity, pxentity.IsValid ())
|
||||
|
||||
pxcollider_id = hydra.get_component_type_id ("PhysX Collider")
|
||||
hasComponent = azlmbr.editor.EditorComponentAPIBus (azlmbr.bus.Broadcast, 'HasComponentOfType', pxentity,
|
||||
pxcollider_id)
|
||||
Report.result (Tests.pxentity_component, hasComponent)
|
||||
pxentity = find_entity("EntityWithPxCollider")
|
||||
Report.result(Tests.find_pxentity, pxentity.IsValid())
|
||||
|
||||
pxcollider_id = hydra.get_component_type_id("PhysX Collider")
|
||||
hasComponent = azlmbr.editor.EditorComponentAPIBus(azlmbr.bus.Broadcast, 'HasComponentOfType', pxentity, pxcollider_id)
|
||||
Report.result(Tests.pxentity_component, hasComponent)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test (PrefabLevel_OpensLevelWithEntities)
|
||||
PrefabLevel_OpensLevelWithEntities ()
|
||||
+7
-11
@@ -22,18 +22,14 @@ sys.path.append (os.path.dirname (os.path.abspath (__file__)) + '/../automatedte
|
||||
|
||||
from base import TestAutomationBase
|
||||
|
||||
|
||||
@pytest.mark.SUITE_main
|
||||
@pytest.mark.parametrize ("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize ("project", ["AutomatedTesting"])
|
||||
class TestAutomation (TestAutomationBase):
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
class TestAutomation(TestAutomationBase):
|
||||
|
||||
def _run_prefab_test (self, request, workspace, editor, test_module):
|
||||
self._run_test (request, workspace, editor, test_module,
|
||||
["--regset=/Amazon/Preferences/EnablePrefabSystem=true"])
|
||||
def _run_prefab_test(self, request, workspace, editor, test_module):
|
||||
self._run_test(request, workspace, editor, test_module, ["--regset=/Amazon/Preferences/EnablePrefabSystem=true"])
|
||||
|
||||
def test_PrefabLevel_OpensLevelWithEntities (self, request, workspace, editor, launcher_platform):
|
||||
def test_PrefabLevel_OpensLevelWithEntities(self, request, workspace, editor, launcher_platform):
|
||||
from . import PrefabLevel_OpensLevelWithEntities as test_module
|
||||
|
||||
|
||||
self._run_prefab_test (request, workspace, editor, test_module)
|
||||
self._run_prefab_test(request, workspace, editor, test_module)
|
||||
@@ -7,4 +7,4 @@ distribution (the "License"). All use of this software is governed by the Licens
|
||||
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.
|
||||
"""
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user