Merge pull request #689 from aws-lumberyard-dev/Prefab/Automation/Tests
Prefab/automation/testsmain
commit
8101b60f5d
@ -0,0 +1,76 @@
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
|
||||
# fmt:off
|
||||
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")
|
||||
find_pxentity = ("Entity: 'EntityWithPxCollider' found", "Entity: 'EntityWithPxCollider' *not* found in level")
|
||||
pxentity_component = ("Entity: 'EntityWithPxCollider' has a Physx Collider", "Entity: 'EntityWithPxCollider' does *not* have a Physx Collider")
|
||||
|
||||
# fmt:on
|
||||
|
||||
def PrefabLevel_OpensLevelWithEntities():
|
||||
"""
|
||||
Opens the level that contains 2 entities, "EmptyEntity" and "EntityWithPxCollider".
|
||||
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
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
|
||||
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)
|
||||
|
||||
helper.init_idle()
|
||||
helper.open_level("prefab", "PrefabLevel_OpensLevelWithEntities")
|
||||
|
||||
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
|
||||
#Checks for an entity called "EmptyEntity"
|
||||
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())
|
||||
|
||||
# Checks if the EmptyEntity is in the correct position and if it fails, it will provide the expected postion and the actual postion of the entity in the Editor log
|
||||
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()}')
|
||||
|
||||
#Checks for an entity called "EntityWithPxCollider" and if it has the PhysX Collider component
|
||||
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)
|
||||
@ -0,0 +1,35 @@
|
||||
"""
|
||||
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.
|
||||
|
||||
"""
|
||||
|
||||
# This suite consists of all test cases that are passing and have been verified.
|
||||
|
||||
import pytest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from ly_test_tools import LAUNCHERS
|
||||
|
||||
sys.path.append (os.path.dirname (os.path.abspath (__file__)) + '/../automatedtesting_shared')
|
||||
|
||||
from base import TestAutomationBase
|
||||
|
||||
@pytest.mark.SUITE_main
|
||||
@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 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)
|
||||
@ -0,0 +1,10 @@
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
@ -0,0 +1,171 @@
|
||||
{
|
||||
"Source": "Levels/PrefabLevel_OpensLevelWithEntities/PrefabLevel_OpensLevelWithEntities.prefab",
|
||||
"ContainerEntity": {
|
||||
"Id": "Entity_[403811863694]",
|
||||
"Name": "Level",
|
||||
"Components": {
|
||||
"Component_[10582285743525614098]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 10582285743525614098
|
||||
},
|
||||
"Component_[12253783095375428046]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 12253783095375428046
|
||||
},
|
||||
"Component_[13764860261821571747]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 13764860261821571747,
|
||||
"Parent Entity": ""
|
||||
},
|
||||
"Component_[15844324401733835865]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 15844324401733835865
|
||||
},
|
||||
"Component_[1605854641405361768]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 1605854641405361768
|
||||
},
|
||||
"Component_[17698173984524983803]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 17698173984524983803
|
||||
},
|
||||
"Component_[3444251662966224826]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 3444251662966224826
|
||||
},
|
||||
"Component_[4231768881195179982]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 4231768881195179982
|
||||
},
|
||||
"Component_[4722360315410084479]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 4722360315410084479
|
||||
},
|
||||
"Component_[7614719100624882952]": {
|
||||
"$type": "EditorPrefabComponent",
|
||||
"Id": 7614719100624882952
|
||||
},
|
||||
"Component_[9585901769691795481]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 9585901769691795481
|
||||
}
|
||||
},
|
||||
"IsDependencyReady": true
|
||||
},
|
||||
"Entities": {
|
||||
"Entity_[438171602062]": {
|
||||
"Id": "Entity_[438171602062]",
|
||||
"Name": "EntityWithPxCollider",
|
||||
"Components": {
|
||||
"Component_[11161653124805884473]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 11161653124805884473
|
||||
},
|
||||
"Component_[13116773315299882093]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 13116773315299882093
|
||||
},
|
||||
"Component_[15820915681461536711]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 15820915681461536711
|
||||
},
|
||||
"Component_[2222061938345834243]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 2222061938345834243
|
||||
},
|
||||
"Component_[3861913165076405600]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 3861913165076405600
|
||||
},
|
||||
"Component_[7118587015611303204]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 7118587015611303204
|
||||
},
|
||||
"Component_[7751174327125555504]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 7751174327125555504
|
||||
},
|
||||
"Component_[8304730147756374057]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 8304730147756374057,
|
||||
"Parent Entity": "Entity_[403811863694]",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
0.0,
|
||||
20.0,
|
||||
34.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[8866353210615920259]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 8866353210615920259
|
||||
},
|
||||
"Component_[8988181228601932779]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 8988181228601932779
|
||||
},
|
||||
"Component_[7103333782129541775]": {
|
||||
"$type": "EditorColliderComponent",
|
||||
"Id": 7103333782129541775
|
||||
}
|
||||
},
|
||||
"IsDependencyReady": true
|
||||
},
|
||||
"Entity_[532660882574]": {
|
||||
"Id": "Entity_[532660882574]",
|
||||
"Name": "EmptyEntity",
|
||||
"Components": {
|
||||
"Component_[16437814751543997955]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 16437814751543997955
|
||||
},
|
||||
"Component_[16751517102089557119]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 16751517102089557119
|
||||
},
|
||||
"Component_[16773275259304187949]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 16773275259304187949
|
||||
},
|
||||
"Component_[17283539636910567200]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 17283539636910567200
|
||||
},
|
||||
"Component_[250004123617033400]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 250004123617033400
|
||||
},
|
||||
"Component_[2791138963683667073]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 2791138963683667073,
|
||||
"Parent Entity": "Entity_[403811863694]",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
10.0,
|
||||
20.0,
|
||||
30.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[3296942400051129145]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 3296942400051129145
|
||||
},
|
||||
"Component_[3422076964671342434]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 3422076964671342434
|
||||
},
|
||||
"Component_[3431895414183121731]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 3431895414183121731
|
||||
},
|
||||
"Component_[7072085777705148766]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 7072085777705148766
|
||||
}
|
||||
},
|
||||
"IsDependencyReady": true
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue