Fix prefab/instance name inconsistency issue in automated testing's prefab utils (#7122)

* Ensure to fire OnEditorEntityCreated notification in SandboxIntegrationManager::CreateNewEntityAtPosition

Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com>

* Ensure to fire OnEditorEntityCreated notification in SandboxIntegrationManager::CreateNewEntityAtPosition

Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com>

* convert test AreaNodes_DependentComponentsAdded to use prefab system

Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com>

* Prevent SetupEditorEntity being called twice

Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com>

* Fix prefab utils prefab naming issue

Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com>

* revert test changes

Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com>

* fix a grammatical error

Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com>
This commit is contained in:
chiyenteng
2022-01-25 14:57:16 -08:00
committed by GitHub
parent 8766de21cc
commit f91c605144
10 changed files with 91 additions and 43 deletions
@@ -38,6 +38,10 @@ class TestAutomation(TestAutomationBase):
from Prefab.tests.instantiate_prefab import InstantiatePrefab_ContainingASingleEntity as test_module
self._run_prefab_test(request, workspace, editor, test_module)
def test_InstantiatePrefab_FromCreatedPrefabWithSingleEntity(self, request, workspace, editor, launcher_platform):
from Prefab.tests.instantiate_prefab import InstantiatePrefab_FromCreatedPrefabWithSingleEntity as test_module
self._run_prefab_test(request, workspace, editor, test_module)
def test_DeletePrefab_ContainingASingleEntity(self, request, workspace, editor, launcher_platform):
from Prefab.tests.delete_prefab import DeletePrefab_ContainingASingleEntity as test_module
self._run_prefab_test(request, workspace, editor, test_module)
@@ -45,8 +45,12 @@ class TestAutomationNoAutoTestMode(EditorTestSuite):
class test_InstantiatePrefab_ContainingASingleEntity(EditorSharedTest):
from .tests.instantiate_prefab import InstantiatePrefab_ContainingASingleEntity as test_module
class test_InstantiatePrefab_FromCreatedPrefabWithSingleEntity(EditorSharedTest):
from .tests.instantiate_prefab import InstantiatePrefab_FromCreatedPrefabWithSingleEntity as test_module
class test_DeletePrefab_ContainingASingleEntity(EditorSharedTest):
from .tests.delete_prefab import DeletePrefab_ContainingASingleEntity as test_module
class test_DuplicatePrefab_ContainingASingleEntity(EditorSharedTest):
from .tests.duplicate_prefab import DuplicatePrefab_ContainingASingleEntity as test_module
from .tests.duplicate_prefab import DuplicatePrefab_ContainingASingleEntity as test_module
@@ -13,7 +13,8 @@ def CreatePrefab_UnderAnEntity():
Test is successful if the new instanced prefab of the child has the parent entity id
"""
CAR_PREFAB_FILE_NAME = 'car_prefab'
from pathlib import Path
CAR_PREFAB_FILE_NAME = Path(__file__).stem + 'car_prefab'
from editor_python_test_tools.editor_entity_utils import EditorEntity
from editor_python_test_tools.prefab_utils import Prefab
@@ -7,7 +7,8 @@ SPDX-License-Identifier: Apache-2.0 OR MIT
def CreatePrefab_WithSingleEntity():
CAR_PREFAB_FILE_NAME = 'car_prefab'
from pathlib import Path
CAR_PREFAB_FILE_NAME = Path(__file__).stem + 'car_prefab'
from editor_python_test_tools.editor_entity_utils import EditorEntity
from editor_python_test_tools.utils import Report
@@ -7,7 +7,8 @@ SPDX-License-Identifier: Apache-2.0 OR MIT
def DeletePrefab_ContainingASingleEntity():
CAR_PREFAB_FILE_NAME = 'car_prefab'
from pathlib import Path
CAR_PREFAB_FILE_NAME = Path(__file__).stem + 'car_prefab'
from editor_python_test_tools.editor_entity_utils import EditorEntity
from editor_python_test_tools.prefab_utils import Prefab
@@ -7,8 +7,9 @@ SPDX-License-Identifier: Apache-2.0 OR MIT
def DetachPrefab_UnderAnotherPrefab():
CAR_PREFAB_FILE_NAME = 'car_prefab2'
WHEEL_PREFAB_FILE_NAME = 'wheel_prefab2'
from pathlib import Path
CAR_PREFAB_FILE_NAME = Path(__file__).stem + 'car_prefab'
WHEEL_PREFAB_FILE_NAME = Path(__file__).stem + 'wheel_prefab'
import editor_python_test_tools.pyside_utils as pyside_utils
@@ -7,7 +7,8 @@ SPDX-License-Identifier: Apache-2.0 OR MIT
def DuplicatePrefab_ContainingASingleEntity():
CAR_PREFAB_FILE_NAME = 'car_prefab'
from pathlib import Path
CAR_PREFAB_FILE_NAME = Path(__file__).stem + 'car_prefab'
from editor_python_test_tools.editor_entity_utils import EditorEntity
from editor_python_test_tools.prefab_utils import Prefab
@@ -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 InstantiatePrefab_FromCreatedPrefabWithSingleEntity():
from pathlib import Path
CAR_PREFAB_FILE_NAME = Path(__file__).stem + '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 Prefab.tests.PrefabTestUtils as prefab_test_utils
prefab_test_utils.open_base_tests_level()
# Creates a new entity at the root level
car_entity = EditorEntity.create_editor_entity()
car_prefab_entities = [car_entity]
# Creates a prefab from the new entity
car_prefab, car_prefab_instance = Prefab.create_prefab(car_prefab_entities, CAR_PREFAB_FILE_NAME)
# Instantiate another instance and verify
car_prefab_instance_2 = car_prefab.instantiate()
assert car_prefab_instance_2.is_valid(), "Failed to instantiate prefab"
if __name__ == "__main__":
from editor_python_test_tools.utils import Report
Report.start_test(InstantiatePrefab_FromCreatedPrefabWithSingleEntity)
@@ -7,8 +7,9 @@ SPDX-License-Identifier: Apache-2.0 OR MIT
def ReparentPrefab_UnderAnotherPrefab():
CAR_PREFAB_FILE_NAME = 'car_prefab'
WHEEL_PREFAB_FILE_NAME = 'wheel_prefab'
from pathlib import Path
CAR_PREFAB_FILE_NAME = Path(__file__).stem + 'car_prefab'
WHEEL_PREFAB_FILE_NAME = Path(__file__).stem + 'wheel_prefab'
import editor_python_test_tools.pyside_utils as pyside_utils