Rename prefab -> Prefab (#4825)
* Rename part 1 * Rename part 2 * Rename part 3
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# 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
|
||||
#
|
||||
#
|
||||
|
||||
## Prefab ##
|
||||
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::PrefabTests
|
||||
TEST_SUITE main
|
||||
TEST_SERIAL
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Main.py
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
)
|
||||
endif()
|
||||
@@ -0,0 +1,49 @@
|
||||
"""
|
||||
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
|
||||
|
||||
"""
|
||||
|
||||
# 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, batch_mode=True, autotest_mode=True):
|
||||
self._run_test(request, workspace, editor, test_module,
|
||||
extra_cmdline_args=["--regset=/Amazon/Preferences/EnablePrefabSystem=true"],
|
||||
batch_mode=batch_mode,
|
||||
autotest_mode=autotest_mode)
|
||||
|
||||
def test_PrefabLevel_OpensLevelWithEntities(self, request, workspace, editor, launcher_platform):
|
||||
from .tests import PrefabLevel_OpensLevelWithEntities as test_module
|
||||
self._run_prefab_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_PrefabBasicWorkflow_CreatePrefab(self, request, workspace, editor, launcher_platform):
|
||||
from .tests import PrefabBasicWorkflow_CreatePrefab as test_module
|
||||
self._run_prefab_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_PrefabBasicWorkflow_InstantiatePrefab(self, request, workspace, editor, launcher_platform):
|
||||
from .tests import PrefabBasicWorkflow_InstantiatePrefab as test_module
|
||||
self._run_prefab_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_PrefabBasicWorkflow_CreateAndDeletePrefab(self, request, workspace, editor, launcher_platform):
|
||||
from .tests import PrefabBasicWorkflow_CreateAndDeletePrefab as test_module
|
||||
self._run_prefab_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_PrefabBasicWorkflow_CreateAndReparentPrefab(self, request, workspace, editor, launcher_platform):
|
||||
from .tests import PrefabBasicWorkflow_CreateAndReparentPrefab as test_module
|
||||
self._run_prefab_test(request, workspace, editor, test_module, autotest_mode=False)
|
||||
@@ -0,0 +1,6 @@
|
||||
"""
|
||||
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
|
||||
"""
|
||||
@@ -0,0 +1,107 @@
|
||||
{
|
||||
"ContainerEntity": {
|
||||
"Id": "ContainerEntity",
|
||||
"Name": "Test",
|
||||
"Components": {
|
||||
"Component_[12826143848076424135]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 12826143848076424135
|
||||
},
|
||||
"Component_[15101974329990766813]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 15101974329990766813
|
||||
},
|
||||
"Component_[16680274563691182095]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 16680274563691182095
|
||||
},
|
||||
"Component_[17501195180351523199]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 17501195180351523199
|
||||
},
|
||||
"Component_[17646858836910065148]": {
|
||||
"$type": "EditorPrefabComponent",
|
||||
"Id": 17646858836910065148
|
||||
},
|
||||
"Component_[18334569630592611766]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 18334569630592611766,
|
||||
"Parent Entity": ""
|
||||
},
|
||||
"Component_[1851406541343621754]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 1851406541343621754
|
||||
},
|
||||
"Component_[25876196591746739]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 25876196591746739
|
||||
},
|
||||
"Component_[2800966138796329695]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 2800966138796329695
|
||||
},
|
||||
"Component_[8557036193836405255]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 8557036193836405255
|
||||
},
|
||||
"Component_[9320658693245331333]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 9320658693245331333
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entities": {
|
||||
"Entity_[965482067476]": {
|
||||
"Id": "Entity_[965482067476]",
|
||||
"Name": "Test_Entity",
|
||||
"Components": {
|
||||
"Component_[10201286510014079044]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 10201286510014079044
|
||||
},
|
||||
"Component_[10449365794489552009]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 10449365794489552009,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 8658441042113324226
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[14918448446211728610]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 14918448446211728610
|
||||
},
|
||||
"Component_[16421196842573146832]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 16421196842573146832
|
||||
},
|
||||
"Component_[18246651644622464292]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 18246651644622464292
|
||||
},
|
||||
"Component_[2027518491025985743]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 2027518491025985743
|
||||
},
|
||||
"Component_[4284802475196956760]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 4284802475196956760
|
||||
},
|
||||
"Component_[5856000098143259126]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 5856000098143259126
|
||||
},
|
||||
"Component_[7830595068045232876]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 7830595068045232876
|
||||
},
|
||||
"Component_[8658441042113324226]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 8658441042113324226,
|
||||
"Parent Entity": "ContainerEntity"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
def PrefabBasicWorkflow_CreateAndDeletePrefab():
|
||||
|
||||
CAR_PREFAB_FILE_NAME = 'car_prefab'
|
||||
|
||||
from editor_python_test_tools.editor_entity_utils import EditorEntity
|
||||
from editor_python_test_tools.prefab_utils import Prefab
|
||||
|
||||
import PrefabTestUtils as prefab_test_utils
|
||||
|
||||
prefab_test_utils.open_base_tests_level()
|
||||
|
||||
# Creates a new Entity at the root level
|
||||
# Asserts if creation didn't succeed
|
||||
car_entity = EditorEntity.create_editor_entity()
|
||||
car_prefab_entities = [car_entity]
|
||||
|
||||
# Asserts if prefab creation doesn't succeeds
|
||||
_, car = Prefab.create_prefab(
|
||||
car_prefab_entities, CAR_PREFAB_FILE_NAME)
|
||||
|
||||
# Asserts if prefab deletion fails
|
||||
Prefab.remove_prefabs([car])
|
||||
|
||||
if __name__ == "__main__":
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(PrefabBasicWorkflow_CreateAndDeletePrefab)
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
def PrefabBasicWorkflow_CreateAndReparentPrefab():
|
||||
|
||||
CAR_PREFAB_FILE_NAME = 'car_prefab'
|
||||
WHEEL_PREFAB_FILE_NAME = 'wheel_prefab'
|
||||
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
|
||||
@pyside_utils.wrap_async
|
||||
async def run_test():
|
||||
|
||||
from editor_python_test_tools.editor_entity_utils import EditorEntity
|
||||
from editor_python_test_tools.prefab_utils import Prefab
|
||||
|
||||
import PrefabTestUtils as prefab_test_utils
|
||||
|
||||
prefab_test_utils.open_base_tests_level()
|
||||
|
||||
# Creates a new Entity at the root level
|
||||
# Asserts if creation didn't succeed
|
||||
car_entity = EditorEntity.create_editor_entity()
|
||||
car_prefab_entities = [car_entity]
|
||||
|
||||
# Checks for prefab creation passed or not
|
||||
_, car = Prefab.create_prefab(
|
||||
car_prefab_entities, CAR_PREFAB_FILE_NAME)
|
||||
|
||||
# Creates another new Entity at the root level
|
||||
wheel_entity = EditorEntity.create_editor_entity()
|
||||
wheel_prefab_entities = [wheel_entity]
|
||||
|
||||
# Checks for wheel prefab creation passed or not
|
||||
_, wheel = Prefab.create_prefab(
|
||||
wheel_prefab_entities, WHEEL_PREFAB_FILE_NAME)
|
||||
|
||||
# Checks for prefab reparenting passed or not
|
||||
await wheel.ui_reparent_prefab_instance(car.container_entity.id)
|
||||
|
||||
run_test()
|
||||
|
||||
if __name__ == "__main__":
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(PrefabBasicWorkflow_CreateAndReparentPrefab)
|
||||
@@ -0,0 +1,30 @@
|
||||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
def PrefabBasicWorkflow_CreatePrefab():
|
||||
|
||||
CAR_PREFAB_FILE_NAME = 'car_prefab'
|
||||
|
||||
from editor_python_test_tools.editor_entity_utils import EditorEntity
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.prefab_utils import Prefab
|
||||
|
||||
import PrefabTestUtils as prefab_test_utils
|
||||
|
||||
prefab_test_utils.open_base_tests_level()
|
||||
|
||||
# Creates a new Entity at the root level
|
||||
# Asserts if creation didn't succeed
|
||||
car_entity = EditorEntity.create_editor_entity()
|
||||
car_prefab_entities = [car_entity]
|
||||
|
||||
# Checks for prefab creation passed or not
|
||||
Prefab.create_prefab(car_prefab_entities, CAR_PREFAB_FILE_NAME)
|
||||
|
||||
if __name__ == "__main__":
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(PrefabBasicWorkflow_CreatePrefab)
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
def PrefabBasicWorkflow_InstantiatePrefab():
|
||||
|
||||
from azlmbr.math import Vector3
|
||||
|
||||
EXISTING_TEST_PREFAB_FILE_NAME = "Gem/PythonTests/Prefab/data/Test.prefab"
|
||||
INSTANTIATED_TEST_PREFAB_POSITION = Vector3(10.00, 20.0, 30.0)
|
||||
EXPECTED_TEST_PREFAB_CHILDREN_COUNT = 1
|
||||
|
||||
from editor_python_test_tools.prefab_utils import Prefab
|
||||
|
||||
import PrefabTestUtils as prefab_test_utils
|
||||
|
||||
prefab_test_utils.open_base_tests_level()
|
||||
|
||||
# Checks for prefab instantiation passed or not
|
||||
test_prefab = Prefab.get_prefab(EXISTING_TEST_PREFAB_FILE_NAME)
|
||||
|
||||
test_instance = test_prefab.instantiate(
|
||||
prefab_position=INSTANTIATED_TEST_PREFAB_POSITION)
|
||||
|
||||
prefab_test_utils.check_entity_children_count(
|
||||
test_instance.container_entity.id,
|
||||
EXPECTED_TEST_PREFAB_CHILDREN_COUNT)
|
||||
|
||||
if __name__ == "__main__":
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(PrefabBasicWorkflow_InstantiatePrefab)
|
||||
@@ -0,0 +1,73 @@
|
||||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
# 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,65 @@
|
||||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from azlmbr.entity import EntityId
|
||||
from azlmbr.math import Vector3
|
||||
from editor_python_test_tools.editor_entity_utils import EditorEntity
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.components as components
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.legacy.general as general
|
||||
|
||||
def check_entity_at_position(entity_id, expected_entity_position):
|
||||
entity_at_expected_position_result = (
|
||||
"entity is at expected position",
|
||||
"entity is *not* at expected position")
|
||||
|
||||
actual_entity_position = components.TransformBus(bus.Event, "GetWorldTranslation", entity_id)
|
||||
is_at_position = actual_entity_position.IsClose(expected_entity_position)
|
||||
Report.result(entity_at_expected_position_result, is_at_position)
|
||||
|
||||
if not is_at_position:
|
||||
Report.info(f"Entity '{entity_id.ToString()}'\'s expected position: {expected_entity_position.ToString()}, actual position: {actual_entity_position.ToString()}")
|
||||
|
||||
return is_at_position
|
||||
|
||||
def check_entity_children_count(entity_id, expected_children_count):
|
||||
entity_children_count_matched_result = (
|
||||
"Entity with a unique name found",
|
||||
"Entity with a unique name *not* found")
|
||||
|
||||
entity = EditorEntity(entity_id)
|
||||
children_entity_ids = entity.get_children_ids()
|
||||
entity_children_count_matched = len(children_entity_ids) == expected_children_count
|
||||
Report.result(entity_children_count_matched_result, entity_children_count_matched)
|
||||
|
||||
if not entity_children_count_matched:
|
||||
Report.info(f"Entity '{entity_id.ToString()}' actual children count: {len(children_entity_ids)}. Expected children count: {expected_children_count}")
|
||||
|
||||
return entity_children_count_matched
|
||||
|
||||
def get_children_ids_by_name(entity_id, entity_name):
|
||||
entity = EditorEntity(entity_id)
|
||||
children_entity_ids = entity.get_children_ids()
|
||||
|
||||
result = []
|
||||
for child_entity_id in children_entity_ids:
|
||||
child_entity = EditorEntity(child_entity_id)
|
||||
child_entity_name = child_entity.get_name()
|
||||
if child_entity_name == entity_name:
|
||||
result.append(child_entity_id)
|
||||
|
||||
return result
|
||||
|
||||
def open_base_tests_level():
|
||||
helper.init_idle()
|
||||
helper.open_level("Prefab", "Base")
|
||||
Reference in New Issue
Block a user