merge system component
Signed-off-by: chcurran <82187351+carlitosan@users.noreply.github.com>monroegm-disable-blank-issue-2
commit
72ff163ff0
@ -0,0 +1,46 @@
|
||||
"""
|
||||
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 pytest
|
||||
|
||||
from ly_test_tools.o3de.editor_test import EditorSharedTest, EditorTestSuite
|
||||
|
||||
|
||||
@pytest.mark.xfail(reason="Optimized tests are experimental, we will enable xfail and monitor them temporarily.")
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
class TestAutomation(EditorTestSuite):
|
||||
|
||||
class AtomEditorComponents_DecalAdded(EditorSharedTest):
|
||||
from Atom.tests import hydra_AtomEditorComponents_DecalAdded as test_module
|
||||
|
||||
class AtomEditorComponents_DepthOfFieldAdded(EditorSharedTest):
|
||||
from Atom.tests import hydra_AtomEditorComponents_DepthOfFieldAdded as test_module
|
||||
|
||||
class AtomEditorComponents_DirectionalLightAdded(EditorSharedTest):
|
||||
from Atom.tests import hydra_AtomEditorComponents_DirectionalLightAdded as test_module
|
||||
|
||||
class AtomEditorComponents_ExposureControlAdded(EditorSharedTest):
|
||||
from Atom.tests import hydra_AtomEditorComponents_ExposureControlAdded as test_module
|
||||
|
||||
class AtomEditorComponents_GlobalSkylightIBLAdded(EditorSharedTest):
|
||||
from Atom.tests import hydra_AtomEditorComponents_GlobalSkylightIBLAdded as test_module
|
||||
|
||||
class AtomEditorComponents_PhysicalSkyAdded(EditorSharedTest):
|
||||
from Atom.tests import hydra_AtomEditorComponents_PhysicalSkyAdded as test_module
|
||||
|
||||
class AtomEditorComponents_PostFXRadiusWeightModifierAdded(EditorSharedTest):
|
||||
from Atom.tests import (
|
||||
hydra_AtomEditorComponents_PostFXRadiusWeightModifierAdded as test_module)
|
||||
|
||||
class AtomEditorComponents_LightAdded(EditorSharedTest):
|
||||
from Atom.tests import hydra_AtomEditorComponents_LightAdded as test_module
|
||||
|
||||
class AtomEditorComponents_DisplayMapperAdded(EditorSharedTest):
|
||||
from Atom.tests import hydra_AtomEditorComponents_DisplayMapperAdded as test_module
|
||||
|
||||
class ShaderAssetBuilder_RecompilesShaderAsChainOfDependenciesChanges(EditorSharedTest):
|
||||
from Atom.tests import hydra_ShaderAssetBuilder_RecompilesShaderAsChainOfDependenciesChanges as test_module
|
||||
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 is a dummy shader used to validate detection of "#included files"
|
||||
*/
|
||||
|
||||
#include <Atom/Features/SrgSemantics.azsli>
|
||||
|
||||
#include "Test1Color.azsli"
|
||||
#include <Test3Color.azsli>
|
||||
|
||||
ShaderResourceGroup DummySrg : SRG_PerDraw
|
||||
{
|
||||
float4 m_color;
|
||||
}
|
||||
|
||||
struct VSInput
|
||||
{
|
||||
float3 m_position : POSITION;
|
||||
float4 m_color : COLOR0;
|
||||
};
|
||||
|
||||
struct VSOutput
|
||||
{
|
||||
float4 m_position : SV_Position;
|
||||
float4 m_color : COLOR0;
|
||||
};
|
||||
|
||||
VSOutput MainVS(VSInput vsInput)
|
||||
{
|
||||
VSOutput OUT;
|
||||
OUT.m_position = float4(vsInput.m_position, 1.0);
|
||||
OUT.m_color = vsInput.m_color;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
struct PSOutput
|
||||
{
|
||||
float4 m_color : SV_Target0;
|
||||
};
|
||||
|
||||
PSOutput MainPS(VSOutput vsOutput)
|
||||
{
|
||||
PSOutput OUT;
|
||||
|
||||
OUT.m_color = GetTest1Color(DummySrg::m_color) + GetTest3Color(DummySrg::m_color);
|
||||
|
||||
return OUT;
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
// This is a dummy shader used to validate detection of "#included files"
|
||||
{
|
||||
"Source" : "DependencyValidation.azsl",
|
||||
|
||||
"DepthStencilState" : {
|
||||
"Depth" : { "Enable" : false, "CompareFunc" : "GreaterEqual" }
|
||||
},
|
||||
|
||||
"DrawList" : "forward",
|
||||
|
||||
"ProgramSettings":
|
||||
{
|
||||
"EntryPoints":
|
||||
[
|
||||
{
|
||||
"name": "MainVS",
|
||||
"type": "Vertex"
|
||||
},
|
||||
{
|
||||
"name": "MainPS",
|
||||
"type": "Fragment"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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 is a dummy shader used to validate detection of "#included files"
|
||||
*/
|
||||
|
||||
#include "Test2Color.azsli"
|
||||
|
||||
float4 GetTest1Color(float4 color)
|
||||
{
|
||||
return color + GetTest2Color(color);
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* 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 is a dummy shader used to validate detection of "#included files"
|
||||
*/
|
||||
|
||||
float4 GetTest2Color(float4 color)
|
||||
{
|
||||
return color * 0.5;
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* 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 is a dummy shader used to validate detection of "#included files"
|
||||
*/
|
||||
|
||||
float4 GetTest3Color(float4 color)
|
||||
{
|
||||
return color * 0.13;
|
||||
}
|
||||
@ -0,0 +1,151 @@
|
||||
"""
|
||||
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:
|
||||
camera_creation = ("Camera Entity successfully created", "Camera Entity failed to be created")
|
||||
camera_component_added = ("Camera component was added to entity", "Camera component failed to be added to entity")
|
||||
camera_component_check = ("Entity has a Camera component", "Entity failed to find Camera component")
|
||||
creation_undo = ("UNDO Entity creation success", "UNDO Entity creation failed")
|
||||
creation_redo = ("REDO Entity creation success", "REDO Entity creation failed")
|
||||
decal_creation = ("Decal Entity successfully created", "Decal Entity failed to be created")
|
||||
decal_component = ("Entity has a Decal component", "Entity failed to find Decal component")
|
||||
material_property_set = ("Material property set on Decal component", "Couldn't set Material property on Decal component")
|
||||
enter_game_mode = ("Entered game mode", "Failed to enter game mode")
|
||||
exit_game_mode = ("Exited game mode", "Couldn't exit game mode")
|
||||
is_visible = ("Entity is visible", "Entity was not visible")
|
||||
is_hidden = ("Entity is hidden", "Entity was not hidden")
|
||||
entity_deleted = ("Entity deleted", "Entity was not deleted")
|
||||
deletion_undo = ("UNDO deletion success", "UNDO deletion failed")
|
||||
deletion_redo = ("REDO deletion success", "REDO deletion failed")
|
||||
no_error_occurred = ("No errors detected", "Errors were detected")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def AtomEditorComponents_Decal_AddedToEntity():
|
||||
"""
|
||||
Summary:
|
||||
Tests the Decal component can be added to an entity and has the expected functionality.
|
||||
|
||||
Test setup:
|
||||
- Wait for Editor idle loop.
|
||||
- Open the "Base" level.
|
||||
|
||||
Expected Behavior:
|
||||
The component can be added, used in game mode, hidden/shown, deleted, and has accurate required components.
|
||||
Creation and deletion undo/redo should also work.
|
||||
|
||||
Test Steps:
|
||||
1) Create a Decal entity with no components.
|
||||
2) Add Decal component to Decal entity.
|
||||
3) UNDO the entity creation and component addition.
|
||||
4) REDO the entity creation and component addition.
|
||||
5) Enter/Exit game mode.
|
||||
6) Test IsHidden.
|
||||
7) Test IsVisible.
|
||||
8) Set Material property on Decal component.
|
||||
9) Delete Decal entity.
|
||||
10) UNDO deletion.
|
||||
11) REDO deletion.
|
||||
12) Look for errors.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import os
|
||||
|
||||
import azlmbr.asset as asset
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
from editor_python_test_tools.editor_entity_utils import EditorEntity
|
||||
from editor_python_test_tools.utils import Report, Tracer, TestHelper as helper
|
||||
|
||||
with Tracer() as error_tracer:
|
||||
# Test setup begins.
|
||||
# Setup: Wait for Editor idle loop before executing Python hydra scripts then open "Base" level.
|
||||
helper.init_idle()
|
||||
helper.open_level("", "Base")
|
||||
|
||||
# Test steps begin.
|
||||
# 1. Create a Decal entity with no components.
|
||||
decal_name = "Decal"
|
||||
decal_entity = EditorEntity.create_editor_entity_at(math.Vector3(512.0, 512.0, 34.0), decal_name)
|
||||
Report.critical_result(Tests.decal_creation, decal_entity.exists())
|
||||
|
||||
# 2. Add Decal component to Decal entity.
|
||||
decal_component = decal_entity.add_component(decal_name)
|
||||
Report.critical_result(Tests.decal_component, decal_entity.has_component(decal_name))
|
||||
|
||||
# 3. UNDO the entity creation and component addition.
|
||||
# -> UNDO component addition.
|
||||
general.undo()
|
||||
# -> UNDO naming entity.
|
||||
general.undo()
|
||||
# -> UNDO selecting entity.
|
||||
general.undo()
|
||||
# -> UNDO entity creation.
|
||||
general.undo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.creation_undo, not decal_entity.exists())
|
||||
|
||||
# 4. REDO the entity creation and component addition.
|
||||
# -> REDO entity creation.
|
||||
general.redo()
|
||||
# -> REDO selecting entity.
|
||||
general.redo()
|
||||
# -> REDO naming entity.
|
||||
general.redo()
|
||||
# -> REDO component addition.
|
||||
general.redo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.creation_redo, decal_entity.exists())
|
||||
|
||||
# 5. Enter/Exit game mode.
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
general.idle_wait_frames(1)
|
||||
helper.exit_game_mode(Tests.exit_game_mode)
|
||||
|
||||
# 6. Test IsHidden.
|
||||
decal_entity.set_visibility_state(False)
|
||||
Report.result(Tests.is_hidden, decal_entity.is_hidden() is True)
|
||||
|
||||
# 7. Test IsVisible.
|
||||
decal_entity.set_visibility_state(True)
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.is_visible, decal_entity.is_visible() is True)
|
||||
|
||||
# 8. Set Material property on Decal component.
|
||||
decal_material_property_path = "Controller|Configuration|Material"
|
||||
decal_material_asset_path = os.path.join("AutomatedTesting", "Materials", "basic_grey.material")
|
||||
decal_material_asset = asset.AssetCatalogRequestBus(
|
||||
bus.Broadcast, "GetAssetIdByPath", decal_material_asset_path, math.Uuid(), False)
|
||||
decal_component.set_component_property_value(decal_material_property_path, decal_material_asset)
|
||||
get_material_property = decal_component.get_component_property_value(decal_material_property_path)
|
||||
Report.result(Tests.material_property_set, get_material_property == decal_material_asset)
|
||||
|
||||
# 9. Delete Decal entity.
|
||||
decal_entity.delete()
|
||||
Report.result(Tests.entity_deleted, not decal_entity.exists())
|
||||
|
||||
# 10. UNDO deletion.
|
||||
general.undo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.deletion_undo, decal_entity.exists())
|
||||
|
||||
# 11. REDO deletion.
|
||||
general.redo()
|
||||
Report.result(Tests.deletion_redo, not decal_entity.exists())
|
||||
|
||||
# 12. Look for errors.
|
||||
helper.wait_for_condition(lambda: error_tracer.has_errors, 1.0)
|
||||
Report.result(Tests.no_error_occurred, not error_tracer.has_errors)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(AtomEditorComponents_Decal_AddedToEntity)
|
||||
@ -0,0 +1,173 @@
|
||||
"""
|
||||
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:
|
||||
camera_creation = ("Camera Entity successfully created", "Camera Entity failed to be created")
|
||||
camera_component_added = ("Camera component was added to Camera entity", "Camera component failed to be added to entity")
|
||||
camera_component_check = ("Entity has a Camera component", "Entity failed to find Camera component")
|
||||
camera_property_set = ("DepthOfField Entity set Camera Entity", "DepthOfField Entity could not set Camera Entity")
|
||||
creation_undo = ("UNDO Entity creation success", "UNDO Entity creation failed")
|
||||
creation_redo = ("REDO Entity creation success", "REDO Entity creation failed")
|
||||
depth_of_field_creation = ("DepthOfField Entity successfully created", "DepthOfField Entity failed to be created")
|
||||
depth_of_field_component = ("Entity has a DepthOfField component", "Entity failed to find DepthOfField component")
|
||||
depth_of_field_disabled = ("DepthOfField component disabled", "DepthOfField component was not disabled.")
|
||||
post_fx_component = ("Entity has a Post FX Layer component", "Entity did not have a Post FX Layer component")
|
||||
depth_of_field_enabled = ("DepthOfField component enabled", "DepthOfField component was not enabled.")
|
||||
enter_game_mode = ("Entered game mode", "Failed to enter game mode")
|
||||
exit_game_mode = ("Exited game mode", "Couldn't exit game mode")
|
||||
is_visible = ("Entity is visible", "Entity was not visible")
|
||||
is_hidden = ("Entity is hidden", "Entity was not hidden")
|
||||
entity_deleted = ("Entity deleted", "Entity was not deleted")
|
||||
deletion_undo = ("UNDO deletion success", "UNDO deletion failed")
|
||||
deletion_redo = ("REDO deletion success", "REDO deletion failed")
|
||||
no_error_occurred = ("No errors detected", "Errors were detected")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def AtomEditorComponents_DepthOfField_AddedToEntity():
|
||||
"""
|
||||
Summary:
|
||||
Tests the DepthOfField component can be added to an entity and has the expected functionality.
|
||||
|
||||
Test setup:
|
||||
- Wait for Editor idle loop.
|
||||
- Open the "Base" level.
|
||||
|
||||
Expected Behavior:
|
||||
The component can be added, used in game mode, hidden/shown, deleted, and has accurate required components.
|
||||
Creation and deletion undo/redo should also work.
|
||||
|
||||
Test Steps:
|
||||
1) Create a DepthOfField entity with no components.
|
||||
2) Add a DepthOfField component to DepthOfField entity.
|
||||
3) UNDO the entity creation and component addition.
|
||||
4) REDO the entity creation and component addition.
|
||||
5) Verify DepthOfField component not enabled.
|
||||
6) Add Post FX Layer component since it is required by the DepthOfField component.
|
||||
7) Verify DepthOfField component is enabled.
|
||||
8) Enter/Exit game mode.
|
||||
9) Test IsHidden.
|
||||
10) Test IsVisible.
|
||||
11) Add Camera entity.
|
||||
12) Add Camera component to Camera entity.
|
||||
13) Set the DepthOfField components's Camera Entity to the newly created Camera entity.
|
||||
14) Delete DepthOfField entity.
|
||||
15) UNDO deletion.
|
||||
16) REDO deletion.
|
||||
17) Look for errors.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
from editor_python_test_tools.editor_entity_utils import EditorEntity
|
||||
from editor_python_test_tools.utils import Report, Tracer, TestHelper as helper
|
||||
|
||||
with Tracer() as error_tracer:
|
||||
# Test setup begins.
|
||||
# Setup: Wait for Editor idle loop before executing Python hydra scripts then open "Base" level.
|
||||
helper.init_idle()
|
||||
helper.open_level("", "Base")
|
||||
|
||||
# Test steps begin.
|
||||
# 1. Create a DepthOfField entity with no components.
|
||||
depth_of_field_name = "DepthOfField"
|
||||
depth_of_field_entity = EditorEntity.create_editor_entity_at(
|
||||
math.Vector3(512.0, 512.0, 34.0), depth_of_field_name)
|
||||
Report.critical_result(Tests.depth_of_field_creation, depth_of_field_entity.exists())
|
||||
|
||||
# 2. Add a DepthOfField component to DepthOfField entity.
|
||||
depth_of_field_component = depth_of_field_entity.add_component(depth_of_field_name)
|
||||
Report.critical_result(Tests.depth_of_field_component, depth_of_field_entity.has_component(depth_of_field_name))
|
||||
|
||||
# 3. UNDO the entity creation and component addition.
|
||||
# -> UNDO component addition.
|
||||
general.undo()
|
||||
# -> UNDO naming entity.
|
||||
general.undo()
|
||||
# -> UNDO selecting entity.
|
||||
general.undo()
|
||||
# -> UNDO entity creation.
|
||||
general.undo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.creation_undo, not depth_of_field_entity.exists())
|
||||
|
||||
# 4. REDO the entity creation and component addition.
|
||||
# -> REDO entity creation.
|
||||
general.redo()
|
||||
# -> REDO selecting entity.
|
||||
general.redo()
|
||||
# -> REDO naming entity.
|
||||
general.redo()
|
||||
# -> REDO component addition.
|
||||
general.redo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.creation_redo, depth_of_field_entity.exists())
|
||||
|
||||
# 5. Verify DepthOfField component not enabled.
|
||||
Report.result(Tests.depth_of_field_disabled, not depth_of_field_component.is_enabled())
|
||||
|
||||
# 6. Add Post FX Layer component since it is required by the DepthOfField component.
|
||||
post_fx_layer = "PostFX Layer"
|
||||
depth_of_field_entity.add_component(post_fx_layer)
|
||||
Report.result(Tests.post_fx_component, depth_of_field_entity.has_component(post_fx_layer))
|
||||
|
||||
# 7. Verify DepthOfField component is enabled.
|
||||
Report.result(Tests.depth_of_field_enabled, depth_of_field_component.is_enabled())
|
||||
|
||||
# 8. Enter/Exit game mode.
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
general.idle_wait_frames(1)
|
||||
helper.exit_game_mode(Tests.exit_game_mode)
|
||||
|
||||
# 9. Test IsHidden.
|
||||
depth_of_field_entity.set_visibility_state(False)
|
||||
Report.result(Tests.is_hidden, depth_of_field_entity.is_hidden() is True)
|
||||
|
||||
# 10. Test IsVisible.
|
||||
depth_of_field_entity.set_visibility_state(True)
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.is_visible, depth_of_field_entity.is_visible() is True)
|
||||
|
||||
# 11. Add Camera entity.
|
||||
camera_name = "Camera"
|
||||
camera_entity = EditorEntity.create_editor_entity_at(math.Vector3(512.0, 512.0, 34.0), camera_name)
|
||||
Report.result(Tests.camera_creation, camera_entity.exists())
|
||||
|
||||
# 12. Add Camera component to Camera entity.
|
||||
camera_entity.add_component(camera_name)
|
||||
Report.result(Tests.camera_component_added, camera_entity.has_component(camera_name))
|
||||
|
||||
# 13. Set the DepthOfField components's Camera Entity to the newly created Camera entity.
|
||||
depth_of_field_camera_property_path = "Controller|Configuration|Camera Entity"
|
||||
depth_of_field_component.set_component_property_value(depth_of_field_camera_property_path, camera_entity.id)
|
||||
camera_entity_set = depth_of_field_component.get_component_property_value(depth_of_field_camera_property_path)
|
||||
Report.result(Tests.camera_property_set, camera_entity.id == camera_entity_set)
|
||||
|
||||
# 14. Delete DepthOfField entity.
|
||||
depth_of_field_entity.delete()
|
||||
Report.result(Tests.entity_deleted, not depth_of_field_entity.exists())
|
||||
|
||||
# 15. UNDO deletion.
|
||||
general.undo()
|
||||
Report.result(Tests.deletion_undo, depth_of_field_entity.exists())
|
||||
|
||||
# 16. REDO deletion.
|
||||
general.redo()
|
||||
Report.result(Tests.deletion_redo, not depth_of_field_entity.exists())
|
||||
|
||||
# 17. Look for errors.
|
||||
helper.wait_for_condition(lambda: error_tracer.has_errors, 1.0)
|
||||
Report.result(Tests.no_error_occurred, not error_tracer.has_errors)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(AtomEditorComponents_DepthOfField_AddedToEntity)
|
||||
@ -0,0 +1,157 @@
|
||||
"""
|
||||
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:
|
||||
camera_creation = ("Camera Entity successfully created", "Camera Entity failed to be created")
|
||||
camera_component_added = ("Camera component was added to entity", "Camera component failed to be added to entity")
|
||||
camera_component_check = ("Entity has a Camera component", "Entity failed to find Camera component")
|
||||
creation_undo = ("UNDO Entity creation success", "UNDO Entity creation failed")
|
||||
creation_redo = ("REDO Entity creation success", "REDO Entity creation failed")
|
||||
directional_light_creation = ("Directional Light Entity successfully created", "Directional Light Entity failed to be created")
|
||||
directional_light_component = ("Entity has a Directional Light component", "Entity failed to find Directional Light component")
|
||||
shadow_camera_check = ("Directional Light component Shadow camera set", "Directional Light component Shadow camera was not set")
|
||||
enter_game_mode = ("Entered game mode", "Failed to enter game mode")
|
||||
exit_game_mode = ("Exited game mode", "Couldn't exit game mode")
|
||||
is_visible = ("Entity is visible", "Entity was not visible")
|
||||
is_hidden = ("Entity is hidden", "Entity was not hidden")
|
||||
entity_deleted = ("Entity deleted", "Entity was not deleted")
|
||||
deletion_undo = ("UNDO deletion success", "UNDO deletion failed")
|
||||
deletion_redo = ("REDO deletion success", "REDO deletion failed")
|
||||
no_error_occurred = ("No errors detected", "Errors were detected")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def AtomEditorComponents_DirectionalLight_AddedToEntity():
|
||||
"""
|
||||
Summary:
|
||||
Tests the Directional Light component can be added to an entity and has the expected functionality.
|
||||
|
||||
Test setup:
|
||||
- Wait for Editor idle loop.
|
||||
- Open the "Base" level.
|
||||
|
||||
Expected Behavior:
|
||||
The component can be added, used in game mode, hidden/shown, deleted, and has accurate required components.
|
||||
Creation and deletion undo/redo should also work.
|
||||
|
||||
Test Steps:
|
||||
1) Create a Directional Light entity with no components.
|
||||
2) Add Directional Light component to Directional Light entity.
|
||||
3) UNDO the entity creation and component addition.
|
||||
4) REDO the entity creation and component addition.
|
||||
5) Enter/Exit game mode.
|
||||
6) Test IsHidden.
|
||||
7) Test IsVisible.
|
||||
8) Add Camera entity.
|
||||
9) Add Camera component to Camera entity
|
||||
10) Set the Directional Light component property Shadow|Camera to the Camera entity.
|
||||
11) Delete Directional Light entity.
|
||||
12) UNDO deletion.
|
||||
13) REDO deletion.
|
||||
14) Look for errors.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
from editor_python_test_tools.editor_entity_utils import EditorEntity
|
||||
from editor_python_test_tools.utils import Report, Tracer, TestHelper as helper
|
||||
|
||||
with Tracer() as error_tracer:
|
||||
# Test setup begins.
|
||||
# Setup: Wait for Editor idle loop before executing Python hydra scripts then open "Base" level.
|
||||
helper.init_idle()
|
||||
helper.open_level("", "Base")
|
||||
|
||||
# Test steps begin.
|
||||
# 1. Create a Directional Light entity with no components.
|
||||
directional_light_name = "Directional Light"
|
||||
directional_light_entity = EditorEntity.create_editor_entity_at(
|
||||
math.Vector3(512.0, 512.0, 34.0), directional_light_name)
|
||||
Report.critical_result(Tests.directional_light_creation, directional_light_entity.exists())
|
||||
|
||||
# 2. Add Directional Light component to Directional Light entity.
|
||||
directional_light_component = directional_light_entity.add_component(directional_light_name)
|
||||
Report.critical_result(
|
||||
Tests.directional_light_component, directional_light_entity.has_component(directional_light_name))
|
||||
|
||||
# 3. UNDO the entity creation and component addition.
|
||||
# -> UNDO component addition.
|
||||
general.undo()
|
||||
# -> UNDO naming entity.
|
||||
general.undo()
|
||||
# -> UNDO selecting entity.
|
||||
general.undo()
|
||||
# -> UNDO entity creation.
|
||||
general.undo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.creation_undo, not directional_light_entity.exists())
|
||||
|
||||
# 4. REDO the entity creation and component addition.
|
||||
# -> REDO entity creation.
|
||||
general.redo()
|
||||
# -> REDO selecting entity.
|
||||
general.redo()
|
||||
# -> REDO naming entity.
|
||||
general.redo()
|
||||
# -> REDO component addition.
|
||||
general.redo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.creation_redo, directional_light_entity.exists())
|
||||
|
||||
# 5. Enter/Exit game mode.
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
general.idle_wait_frames(1)
|
||||
helper.exit_game_mode(Tests.exit_game_mode)
|
||||
|
||||
# 6. Test IsHidden.
|
||||
directional_light_entity.set_visibility_state(False)
|
||||
Report.result(Tests.is_hidden, directional_light_entity.is_hidden() is True)
|
||||
|
||||
# 7. Test IsVisible.
|
||||
directional_light_entity.set_visibility_state(True)
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.is_visible, directional_light_entity.is_visible() is True)
|
||||
|
||||
# 8. Add Camera entity.
|
||||
camera_name = "Camera"
|
||||
camera_entity = EditorEntity.create_editor_entity_at(math.Vector3(512.0, 512.0, 34.0), camera_name)
|
||||
Report.result(Tests.camera_creation, camera_entity.exists())
|
||||
|
||||
# 9. Add Camera component to Camera entity.
|
||||
camera_entity.add_component(camera_name)
|
||||
Report.result(Tests.camera_component_added, camera_entity.has_component(camera_name))
|
||||
|
||||
# 10. Set the Directional Light component property Shadow|Camera to the Camera entity.
|
||||
shadow_camera_property_path = "Controller|Configuration|Shadow|Camera"
|
||||
directional_light_component.set_component_property_value(shadow_camera_property_path, camera_entity.id)
|
||||
shadow_camera_set = directional_light_component.get_component_property_value(shadow_camera_property_path)
|
||||
Report.result(Tests.shadow_camera_check, camera_entity.id == shadow_camera_set)
|
||||
|
||||
# 11. Delete DirectionalLight entity.
|
||||
directional_light_entity.delete()
|
||||
Report.result(Tests.entity_deleted, not directional_light_entity.exists())
|
||||
|
||||
# 12. UNDO deletion.
|
||||
general.undo()
|
||||
Report.result(Tests.deletion_undo, directional_light_entity.exists())
|
||||
|
||||
# 13. REDO deletion.
|
||||
general.redo()
|
||||
Report.result(Tests.deletion_redo, not directional_light_entity.exists())
|
||||
|
||||
# 14. Look for errors.
|
||||
helper.wait_for_condition(lambda: error_tracer.has_errors, 1.0)
|
||||
Report.result(Tests.no_error_occurred, not error_tracer.has_errors)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(AtomEditorComponents_DirectionalLight_AddedToEntity)
|
||||
@ -0,0 +1,137 @@
|
||||
"""
|
||||
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:
|
||||
camera_creation = ("Camera Entity successfully created", "Camera Entity failed to be created")
|
||||
camera_component_added = ("Camera component was added to entity", "Camera component failed to be added to entity")
|
||||
camera_component_check = ("Entity has a Camera component", "Entity failed to find Camera component")
|
||||
creation_undo = ("UNDO Entity creation success", "UNDO Entity creation failed")
|
||||
creation_redo = ("REDO Entity creation success", "REDO Entity creation failed")
|
||||
display_mapper_creation = ("Display Mapper Entity successfully created", "Display Mapper Entity failed to be created")
|
||||
display_mapper_component = ("Entity has a Display Mapper component", "Entity failed to find Display Mapper component")
|
||||
enter_game_mode = ("Entered game mode", "Failed to enter game mode")
|
||||
exit_game_mode = ("Exited game mode", "Couldn't exit game mode")
|
||||
is_visible = ("Entity is visible", "Entity was not visible")
|
||||
is_hidden = ("Entity is hidden", "Entity was not hidden")
|
||||
entity_deleted = ("Entity deleted", "Entity was not deleted")
|
||||
deletion_undo = ("UNDO deletion success", "UNDO deletion failed")
|
||||
deletion_redo = ("REDO deletion success", "REDO deletion failed")
|
||||
no_error_occurred = ("No errors detected", "Errors were detected")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def AtomEditorComponents_DisplayMapper_AddedToEntity():
|
||||
"""
|
||||
Summary:
|
||||
Tests the Display Mapper component can be added to an entity and has the expected functionality.
|
||||
|
||||
Test setup:
|
||||
- Wait for Editor idle loop.
|
||||
- Open the "Base" level.
|
||||
|
||||
Expected Behavior:
|
||||
The component can be added, used in game mode, hidden/shown, deleted, and has accurate required components.
|
||||
Creation and deletion undo/redo should also work.
|
||||
|
||||
Test Steps:
|
||||
1) Create a Display Mapper entity with no components.
|
||||
2) Add Display Mapper component to Display Mapper entity.
|
||||
3) UNDO the entity creation and component addition.
|
||||
4) REDO the entity creation and component addition.
|
||||
5) Enter/Exit game mode.
|
||||
6) Test IsHidden.
|
||||
7) Test IsVisible.
|
||||
8) Delete Display Mapper entity.
|
||||
9) UNDO deletion.
|
||||
10) REDO deletion.
|
||||
11) Look for errors.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
from editor_python_test_tools.editor_entity_utils import EditorEntity
|
||||
from editor_python_test_tools.utils import Report, Tracer, TestHelper as helper
|
||||
|
||||
with Tracer() as error_tracer:
|
||||
# Test setup begins.
|
||||
# Setup: Wait for Editor idle loop before executing Python hydra scripts then open "Base" level.
|
||||
helper.init_idle()
|
||||
helper.open_level("", "Base")
|
||||
|
||||
# Test steps begin.
|
||||
# 1. Create a Display Mapper entity with no components.
|
||||
display_mapper = "Display Mapper"
|
||||
display_mapper_entity = EditorEntity.create_editor_entity_at(
|
||||
math.Vector3(512.0, 512.0, 34.0), f"{display_mapper}")
|
||||
Report.critical_result(Tests.display_mapper_creation, display_mapper_entity.exists())
|
||||
|
||||
# 2. Add Display Mapper component to Display Mapper entity.
|
||||
display_mapper_entity.add_component(display_mapper)
|
||||
Report.critical_result(Tests.display_mapper_component, display_mapper_entity.has_component(display_mapper))
|
||||
|
||||
# 3. UNDO the entity creation and component addition.
|
||||
# -> UNDO component addition.
|
||||
general.undo()
|
||||
# -> UNDO naming entity.
|
||||
general.undo()
|
||||
# -> UNDO selecting entity.
|
||||
general.undo()
|
||||
# -> UNDO entity creation.
|
||||
general.undo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.creation_undo, not display_mapper_entity.exists())
|
||||
|
||||
# 4. REDO the entity creation and component addition.
|
||||
# -> REDO entity creation.
|
||||
general.redo()
|
||||
# -> REDO selecting entity.
|
||||
general.redo()
|
||||
# -> REDO naming entity.
|
||||
general.redo()
|
||||
# -> REDO component addition.
|
||||
general.redo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.creation_redo, display_mapper_entity.exists())
|
||||
|
||||
# 5. Enter/Exit game mode.
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
general.idle_wait_frames(1)
|
||||
helper.exit_game_mode(Tests.exit_game_mode)
|
||||
|
||||
# 6. Test IsHidden.
|
||||
display_mapper_entity.set_visibility_state(False)
|
||||
Report.result(Tests.is_hidden, display_mapper_entity.is_hidden() is True)
|
||||
|
||||
# 7. Test IsVisible.
|
||||
display_mapper_entity.set_visibility_state(True)
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.is_visible, display_mapper_entity.is_visible() is True)
|
||||
|
||||
# 8. Delete Display Mapper entity.
|
||||
display_mapper_entity.delete()
|
||||
Report.result(Tests.entity_deleted, not display_mapper_entity.exists())
|
||||
|
||||
# 9. UNDO deletion.
|
||||
general.undo()
|
||||
Report.result(Tests.deletion_undo, display_mapper_entity.exists())
|
||||
|
||||
# 10. REDO deletion.
|
||||
general.redo()
|
||||
Report.result(Tests.deletion_redo, not display_mapper_entity.exists())
|
||||
|
||||
# 11. Look for errors.
|
||||
helper.wait_for_condition(lambda: error_tracer.has_errors, 1.0)
|
||||
Report.result(Tests.no_error_occurred, not error_tracer.has_errors)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(AtomEditorComponents_DisplayMapper_AddedToEntity)
|
||||
@ -0,0 +1,145 @@
|
||||
"""
|
||||
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:
|
||||
camera_creation = ("Camera Entity successfully created", "Camera Entity failed to be created")
|
||||
camera_component_added = ("Camera component was added to entity", "Camera component failed to be added to entity")
|
||||
camera_component_check = ("Entity has a Camera component", "Entity failed to find Camera component")
|
||||
creation_undo = ("UNDO Entity creation success", "UNDO Entity creation failed")
|
||||
creation_redo = ("REDO Entity creation success", "REDO Entity creation failed")
|
||||
exposure_control_creation = ("ExposureControl Entity successfully created", "ExposureControl Entity failed to be created")
|
||||
exposure_control_component = ("Entity has a Exposure Control component", "Entity failed to find Exposure Control component")
|
||||
post_fx_component = ("Entity has a Post FX Layer component", "Entity did not have a Post FX Layer component")
|
||||
enter_game_mode = ("Entered game mode", "Failed to enter game mode")
|
||||
exit_game_mode = ("Exited game mode", "Couldn't exit game mode")
|
||||
is_visible = ("Entity is visible", "Entity was not visible")
|
||||
is_hidden = ("Entity is hidden", "Entity was not hidden")
|
||||
entity_deleted = ("Entity deleted", "Entity was not deleted")
|
||||
deletion_undo = ("UNDO deletion success", "UNDO deletion failed")
|
||||
deletion_redo = ("REDO deletion success", "REDO deletion failed")
|
||||
no_error_occurred = ("No errors detected", "Errors were detected")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def AtomEditorComponents_ExposureControl_AddedToEntity():
|
||||
"""
|
||||
Summary:
|
||||
Tests the Exposure Control component can be added to an entity and has the expected functionality.
|
||||
|
||||
Test setup:
|
||||
- Wait for Editor idle loop.
|
||||
- Open the "Base" level.
|
||||
|
||||
Expected Behavior:
|
||||
The component can be added, used in game mode, hidden/shown, deleted, and has accurate required components.
|
||||
Creation and deletion undo/redo should also work.
|
||||
|
||||
Test Steps:
|
||||
1) Create an Exposure Control entity with no components.
|
||||
2) Add Exposure Control component to Exposure Control entity.
|
||||
3) UNDO the entity creation and component addition.
|
||||
4) REDO the entity creation and component addition.
|
||||
5) Enter/Exit game mode.
|
||||
6) Test IsHidden.
|
||||
7) Test IsVisible.
|
||||
8) Add Post FX Layer component.
|
||||
9) Delete Exposure Control entity.
|
||||
10) UNDO deletion.
|
||||
11) REDO deletion.
|
||||
12) Look for errors.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
from editor_python_test_tools.editor_entity_utils import EditorEntity
|
||||
from editor_python_test_tools.utils import Report, Tracer, TestHelper as helper
|
||||
|
||||
with Tracer() as error_tracer:
|
||||
# Test setup begins.
|
||||
# Setup: Wait for Editor idle loop before executing Python hydra scripts then open "Base" level.
|
||||
helper.init_idle()
|
||||
helper.open_level("", "Base")
|
||||
|
||||
# Test steps begin.
|
||||
# 1. Creation of Exposure Control entity with no components.
|
||||
exposure_control_name = "Exposure Control"
|
||||
exposure_control_entity = EditorEntity.create_editor_entity_at(
|
||||
math.Vector3(512.0, 512.0, 34.0), f"{exposure_control_name}")
|
||||
Report.critical_result(Tests.exposure_control_creation, exposure_control_entity.exists())
|
||||
|
||||
# 2. Add Exposure Control component to Exposure Control entity.
|
||||
exposure_control_entity.add_component(exposure_control_name)
|
||||
Report.critical_result(
|
||||
Tests.exposure_control_component, exposure_control_entity.has_component(exposure_control_name))
|
||||
|
||||
# 3. UNDO the entity creation and component addition.
|
||||
# -> UNDO component addition.
|
||||
general.undo()
|
||||
# -> UNDO naming entity.
|
||||
general.undo()
|
||||
# -> UNDO selecting entity.
|
||||
general.undo()
|
||||
# -> UNDO entity creation.
|
||||
general.undo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.creation_undo, not exposure_control_entity.exists())
|
||||
|
||||
# 4. REDO the entity creation and component addition.
|
||||
# -> REDO entity creation.
|
||||
general.redo()
|
||||
# -> REDO selecting entity.
|
||||
general.redo()
|
||||
# -> REDO naming entity.
|
||||
general.redo()
|
||||
# -> REDO component addition.
|
||||
general.redo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.creation_redo, exposure_control_entity.exists())
|
||||
|
||||
# 5. Enter/Exit game mode.
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
general.idle_wait_frames(1)
|
||||
helper.exit_game_mode(Tests.exit_game_mode)
|
||||
|
||||
# 6. Test IsHidden.
|
||||
exposure_control_entity.set_visibility_state(False)
|
||||
Report.result(Tests.is_hidden, exposure_control_entity.is_hidden() is True)
|
||||
|
||||
# 7. Test IsVisible.
|
||||
exposure_control_entity.set_visibility_state(True)
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.is_visible, exposure_control_entity.is_visible() is True)
|
||||
|
||||
# 8. Add Post FX Layer component.
|
||||
post_fx_layer_name = "PostFX Layer"
|
||||
exposure_control_entity.add_component(post_fx_layer_name)
|
||||
Report.result(Tests.post_fx_component, exposure_control_entity.has_component(post_fx_layer_name))
|
||||
|
||||
# 9. Delete ExposureControl entity.
|
||||
exposure_control_entity.delete()
|
||||
Report.result(Tests.entity_deleted, not exposure_control_entity.exists())
|
||||
|
||||
# 10. UNDO deletion.
|
||||
general.undo()
|
||||
Report.result(Tests.deletion_undo, exposure_control_entity.exists())
|
||||
|
||||
# 11. REDO deletion.
|
||||
general.redo()
|
||||
Report.result(Tests.deletion_redo, not exposure_control_entity.exists())
|
||||
|
||||
# 12. Look for errors.
|
||||
helper.wait_for_condition(lambda: error_tracer.has_errors, 1.0)
|
||||
Report.result(Tests.no_error_occurred, not error_tracer.has_errors)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(AtomEditorComponents_ExposureControl_AddedToEntity)
|
||||
@ -0,0 +1,164 @@
|
||||
"""
|
||||
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:
|
||||
camera_creation = ("Camera Entity successfully created", "Camera Entity failed to be created")
|
||||
camera_component_added = ("Camera component was added to entity", "Camera component failed to be added to entity")
|
||||
camera_component_check = ("Entity has a Camera component", "Entity failed to find Camera component")
|
||||
creation_undo = ("UNDO Entity creation success", "UNDO Entity creation failed")
|
||||
creation_redo = ("REDO Entity creation success", "REDO Entity creation failed")
|
||||
global_skylight_creation = ("Global Skylight (IBL) Entity successfully created", "Global Skylight (IBL) Entity failed to be created")
|
||||
global_skylight_component = ("Entity has a Global Skylight (IBL) component", "Entity failed to find Global Skylight (IBL) component")
|
||||
diffuse_image_set = ("Entity has the Diffuse Image set", "Entity did not the Diffuse Image set")
|
||||
specular_image_set = ("Entity has the Specular Image set", "Entity did not the Specular Image set")
|
||||
enter_game_mode = ("Entered game mode", "Failed to enter game mode")
|
||||
exit_game_mode = ("Exited game mode", "Couldn't exit game mode")
|
||||
is_visible = ("Entity is visible", "Entity was not visible")
|
||||
is_hidden = ("Entity is hidden", "Entity was not hidden")
|
||||
entity_deleted = ("Entity deleted", "Entity was not deleted")
|
||||
deletion_undo = ("UNDO deletion success", "UNDO deletion failed")
|
||||
deletion_redo = ("REDO deletion success", "REDO deletion failed")
|
||||
no_error_occurred = ("No errors detected", "Errors were detected")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def AtomEditorComponents_GlobalSkylightIBL_AddedToEntity():
|
||||
"""
|
||||
Summary:
|
||||
Tests the Global Skylight (IBL) component can be added to an entity and has the expected functionality.
|
||||
|
||||
Test setup:
|
||||
- Wait for Editor idle loop.
|
||||
- Open the "Base" level.
|
||||
|
||||
Expected Behavior:
|
||||
The component can be added, used in game mode, hidden/shown, deleted, and has accurate required components.
|
||||
Creation and deletion undo/redo should also work.
|
||||
|
||||
Test Steps:
|
||||
1) Create a Global Skylight (IBL) entity with no components.
|
||||
2) Add Global Skylight (IBL) component to Global Skylight (IBL) entity.
|
||||
3) UNDO the entity creation and component addition.
|
||||
4) REDO the entity creation and component addition.
|
||||
5) Enter/Exit game mode.
|
||||
6) Test IsHidden.
|
||||
7) Test IsVisible.
|
||||
8) Add Post FX Layer component.
|
||||
9) Add Camera component
|
||||
10) Delete Global Skylight (IBL) entity.
|
||||
11) UNDO deletion.
|
||||
12) REDO deletion.
|
||||
13) Look for errors.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import os
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
from editor_python_test_tools.asset_utils import Asset
|
||||
from editor_python_test_tools.editor_entity_utils import EditorEntity
|
||||
from editor_python_test_tools.utils import Report, Tracer, TestHelper as helper
|
||||
|
||||
with Tracer() as error_tracer:
|
||||
# Test setup begins.
|
||||
# Setup: Wait for Editor idle loop before executing Python hydra scripts then open "Base" level.
|
||||
helper.init_idle()
|
||||
helper.open_level("", "Base")
|
||||
|
||||
# Test steps begin.
|
||||
# 1. Create a Global Skylight (IBL) entity with no components.
|
||||
global_skylight_name = "Global Skylight (IBL)"
|
||||
global_skylight_entity = EditorEntity.create_editor_entity_at(
|
||||
math.Vector3(512.0, 512.0, 34.0), global_skylight_name)
|
||||
Report.critical_result(Tests.global_skylight_creation, global_skylight_entity.exists())
|
||||
|
||||
# 2. Add Global Skylight (IBL) component to Global Skylight (IBL) entity.
|
||||
global_skylight_component = global_skylight_entity.add_component(global_skylight_name)
|
||||
Report.critical_result(
|
||||
Tests.global_skylight_component, global_skylight_entity.has_component(global_skylight_name))
|
||||
|
||||
# 3. UNDO the entity creation and component addition.
|
||||
# -> UNDO component addition.
|
||||
general.undo()
|
||||
# -> UNDO naming entity.
|
||||
general.undo()
|
||||
# -> UNDO selecting entity.
|
||||
general.undo()
|
||||
# -> UNDO entity creation.
|
||||
general.undo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.creation_undo, not global_skylight_entity.exists())
|
||||
|
||||
# 4. REDO the entity creation and component addition.
|
||||
# -> REDO entity creation.
|
||||
general.redo()
|
||||
# -> REDO selecting entity.
|
||||
general.redo()
|
||||
# -> REDO naming entity.
|
||||
general.redo()
|
||||
# -> REDO component addition.
|
||||
general.redo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.creation_redo, global_skylight_entity.exists())
|
||||
|
||||
# 5. Enter/Exit game mode.
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
general.idle_wait_frames(1)
|
||||
helper.exit_game_mode(Tests.exit_game_mode)
|
||||
|
||||
# 6. Test IsHidden.
|
||||
global_skylight_entity.set_visibility_state(False)
|
||||
Report.result(Tests.is_hidden, global_skylight_entity.is_hidden() is True)
|
||||
|
||||
# 7. Test IsVisible.
|
||||
global_skylight_entity.set_visibility_state(True)
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.is_visible, global_skylight_entity.is_visible() is True)
|
||||
|
||||
# 8. Set the Diffuse Image asset on the Global Skylight (IBL) entity.
|
||||
global_skylight_diffuse_image_property = "Controller|Configuration|Diffuse Image"
|
||||
diffuse_image_path = os.path.join("LightingPresets", "greenwich_park_02_4k_iblskyboxcm.exr.streamingimage")
|
||||
diffuse_image_asset = Asset.find_asset_by_path(diffuse_image_path, False)
|
||||
global_skylight_component.set_component_property_value(
|
||||
global_skylight_diffuse_image_property, diffuse_image_asset.id)
|
||||
diffuse_image_set = global_skylight_component.get_component_property_value(
|
||||
global_skylight_diffuse_image_property)
|
||||
Report.result(Tests.diffuse_image_set, diffuse_image_set == diffuse_image_asset.id)
|
||||
|
||||
# 9. Set the Specular Image asset on the Global Light (IBL) entity.
|
||||
global_skylight_specular_image_property = "Controller|Configuration|Specular Image"
|
||||
specular_image_path = os.path.join("LightingPresets", "greenwich_park_02_4k_iblskyboxcm.exr.streamingimage")
|
||||
specular_image_asset = Asset.find_asset_by_path(specular_image_path, False)
|
||||
global_skylight_component.set_component_property_value(
|
||||
global_skylight_specular_image_property, specular_image_asset.id)
|
||||
specular_image_added = global_skylight_component.get_component_property_value(
|
||||
global_skylight_specular_image_property)
|
||||
Report.result(Tests.specular_image_set, specular_image_added == specular_image_asset.id)
|
||||
|
||||
# 10. Delete Global Skylight (IBL) entity.
|
||||
global_skylight_entity.delete()
|
||||
Report.result(Tests.entity_deleted, not global_skylight_entity.exists())
|
||||
|
||||
# 11. UNDO deletion.
|
||||
general.undo()
|
||||
Report.result(Tests.deletion_undo, global_skylight_entity.exists())
|
||||
|
||||
# 12. REDO deletion.
|
||||
general.redo()
|
||||
Report.result(Tests.deletion_redo, not global_skylight_entity.exists())
|
||||
|
||||
# 13. Look for errors.
|
||||
helper.wait_for_condition(lambda: error_tracer.has_errors, 1.0)
|
||||
Report.result(Tests.no_error_occurred, not error_tracer.has_errors)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(AtomEditorComponents_GlobalSkylightIBL_AddedToEntity)
|
||||
@ -0,0 +1,136 @@
|
||||
"""
|
||||
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:
|
||||
camera_creation = ("Camera Entity successfully created", "Camera Entity failed to be created")
|
||||
camera_component_added = ("Camera component was added to entity", "Camera component failed to be added to entity")
|
||||
camera_component_check = ("Entity has a Camera component", "Entity failed to find Camera component")
|
||||
creation_undo = ("UNDO Entity creation success", "UNDO Entity creation failed")
|
||||
creation_redo = ("REDO Entity creation success", "REDO Entity creation failed")
|
||||
light_creation = ("Light Entity successfully created", "Light Entity failed to be created")
|
||||
light_component = ("Entity has a Light component", "Entity failed to find Light component")
|
||||
enter_game_mode = ("Entered game mode", "Failed to enter game mode")
|
||||
exit_game_mode = ("Exited game mode", "Couldn't exit game mode")
|
||||
is_visible = ("Entity is visible", "Entity was not visible")
|
||||
is_hidden = ("Entity is hidden", "Entity was not hidden")
|
||||
entity_deleted = ("Entity deleted", "Entity was not deleted")
|
||||
deletion_undo = ("UNDO deletion success", "UNDO deletion failed")
|
||||
deletion_redo = ("REDO deletion success", "REDO deletion failed")
|
||||
no_error_occurred = ("No errors detected", "Errors were detected")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def AtomEditorComponents_Light_AddedToEntity():
|
||||
"""
|
||||
Summary:
|
||||
Tests the Light component can be added to an entity and has the expected functionality.
|
||||
|
||||
Test setup:
|
||||
- Wait for Editor idle loop.
|
||||
- Open the "Base" level.
|
||||
|
||||
Expected Behavior:
|
||||
The component can be added, used in game mode, hidden/shown, deleted, and has accurate required components.
|
||||
Creation and deletion undo/redo should also work.
|
||||
|
||||
Test Steps:
|
||||
1) Create a Light entity with no components.
|
||||
2) Add Light component to the Light entity.
|
||||
3) UNDO the entity creation and component addition.
|
||||
4) REDO the entity creation and component addition.
|
||||
5) Enter/Exit game mode.
|
||||
6) Test IsHidden.
|
||||
7) Test IsVisible.
|
||||
8) Delete Light entity.
|
||||
9) UNDO deletion.
|
||||
10) REDO deletion.
|
||||
11) Look for errors.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
from editor_python_test_tools.editor_entity_utils import EditorEntity
|
||||
from editor_python_test_tools.utils import Report, Tracer, TestHelper as helper
|
||||
|
||||
with Tracer() as error_tracer:
|
||||
# Test setup begins.
|
||||
# Setup: Wait for Editor idle loop before executing Python hydra scripts then open "Base" level.
|
||||
helper.init_idle()
|
||||
helper.open_level("", "Base")
|
||||
|
||||
# Test steps begin.
|
||||
# 1. Create a Light entity with no components.
|
||||
light_name = "Light"
|
||||
light_entity = EditorEntity.create_editor_entity_at(math.Vector3(512.0, 512.0, 34.0), light_name)
|
||||
Report.critical_result(Tests.light_creation, light_entity.exists())
|
||||
|
||||
# 2. Add Light component to the Light entity.
|
||||
light_entity.add_component(light_name)
|
||||
Report.critical_result(Tests.light_component, light_entity.has_component(light_name))
|
||||
|
||||
# 3. UNDO the entity creation and component addition.
|
||||
# -> UNDO component addition.
|
||||
general.undo()
|
||||
# -> UNDO naming entity.
|
||||
general.undo()
|
||||
# -> UNDO selecting entity.
|
||||
general.undo()
|
||||
# -> UNDO entity creation.
|
||||
general.undo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.creation_undo, not light_entity.exists())
|
||||
|
||||
# 4. REDO the entity creation and component addition.
|
||||
# -> REDO entity creation.
|
||||
general.redo()
|
||||
# -> REDO selecting entity.
|
||||
general.redo()
|
||||
# -> REDO naming entity.
|
||||
general.redo()
|
||||
# -> REDO component addition.
|
||||
general.redo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.creation_redo, light_entity.exists())
|
||||
|
||||
# 5. Enter/Exit game mode.
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
general.idle_wait_frames(1)
|
||||
helper.exit_game_mode(Tests.exit_game_mode)
|
||||
|
||||
# 6. Test IsHidden.
|
||||
light_entity.set_visibility_state(False)
|
||||
Report.result(Tests.is_hidden, light_entity.is_hidden() is True)
|
||||
|
||||
# 7. Test IsVisible.
|
||||
light_entity.set_visibility_state(True)
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.is_visible, light_entity.is_visible() is True)
|
||||
|
||||
# 8. Delete Light entity.
|
||||
light_entity.delete()
|
||||
Report.result(Tests.entity_deleted, not light_entity.exists())
|
||||
|
||||
# 9. UNDO deletion.
|
||||
general.undo()
|
||||
Report.result(Tests.deletion_undo, light_entity.exists())
|
||||
|
||||
# 10. REDO deletion.
|
||||
general.redo()
|
||||
Report.result(Tests.deletion_redo, not light_entity.exists())
|
||||
|
||||
# 11. Look for errors.
|
||||
helper.wait_for_condition(lambda: error_tracer.has_errors, 1.0)
|
||||
Report.result(Tests.no_error_occurred, not error_tracer.has_errors)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(AtomEditorComponents_Light_AddedToEntity)
|
||||
@ -0,0 +1,136 @@
|
||||
"""
|
||||
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:
|
||||
camera_creation = ("Camera Entity successfully created", "Camera Entity failed to be created")
|
||||
camera_component_added = ("Camera component was added to entity", "Camera component failed to be added to entity")
|
||||
camera_component_check = ("Entity has a Camera component", "Entity failed to find Camera component")
|
||||
creation_undo = ("UNDO Entity creation success", "UNDO Entity creation failed")
|
||||
creation_redo = ("REDO Entity creation success", "REDO Entity creation failed")
|
||||
physical_sky_creation = ("Physical Sky Entity successfully created", "Physical Sky Entity failed to be created")
|
||||
physical_sky_component = ("Entity has a Physical Sky component", "Entity failed to find Physical Sky component")
|
||||
enter_game_mode = ("Entered game mode", "Failed to enter game mode")
|
||||
exit_game_mode = ("Exited game mode", "Couldn't exit game mode")
|
||||
is_visible = ("Entity is visible", "Entity was not visible")
|
||||
is_hidden = ("Entity is hidden", "Entity was not hidden")
|
||||
entity_deleted = ("Entity deleted", "Entity was not deleted")
|
||||
deletion_undo = ("UNDO deletion success", "UNDO deletion failed")
|
||||
deletion_redo = ("REDO deletion success", "REDO deletion failed")
|
||||
no_error_occurred = ("No errors detected", "Errors were detected")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def AtomEditorComponents_PhysicalSky_AddedToEntity():
|
||||
"""
|
||||
Summary:
|
||||
Tests the Physical Sky component can be added to an entity and has the expected functionality.
|
||||
|
||||
Test setup:
|
||||
- Wait for Editor idle loop.
|
||||
- Open the "Base" level.
|
||||
|
||||
Expected Behavior:
|
||||
The component can be added, used in game mode, hidden/shown, deleted, and has accurate required components.
|
||||
Creation and deletion undo/redo should also work.
|
||||
|
||||
Test Steps:
|
||||
1) Create a Physical Sky entity with no components.
|
||||
2) Add Physical Sky component to Physical Sky entity.
|
||||
3) UNDO the entity creation and component addition.
|
||||
4) REDO the entity creation and component addition.
|
||||
5) Enter/Exit game mode.
|
||||
6) Test IsHidden.
|
||||
7) Test IsVisible.
|
||||
8) Delete Physical Sky entity.
|
||||
9) UNDO deletion.
|
||||
10) REDO deletion.
|
||||
11) Look for errors.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
from editor_python_test_tools.editor_entity_utils import EditorEntity
|
||||
from editor_python_test_tools.utils import Report, Tracer, TestHelper as helper
|
||||
|
||||
with Tracer() as error_tracer:
|
||||
# Test setup begins.
|
||||
# Setup: Wait for Editor idle loop before executing Python hydra scripts then open "Base" level.
|
||||
helper.init_idle()
|
||||
helper.open_level("", "Base")
|
||||
|
||||
# Test steps begin.
|
||||
# 1. Create a Physical Sky entity with no components.
|
||||
physical_sky_name = "Physical Sky"
|
||||
physical_sky_entity = EditorEntity.create_editor_entity_at(math.Vector3(512.0, 512.0, 34.0), physical_sky_name)
|
||||
Report.critical_result(Tests.physical_sky_creation, physical_sky_entity.exists())
|
||||
|
||||
# 2. Add Physical Sky component to Physical Sky entity.
|
||||
physical_sky_entity.add_component(physical_sky_name)
|
||||
Report.critical_result(Tests.physical_sky_component, physical_sky_entity.has_component(physical_sky_name))
|
||||
|
||||
# 3. UNDO the entity creation and component addition.
|
||||
# -> UNDO component addition.
|
||||
general.undo()
|
||||
# -> UNDO naming entity.
|
||||
general.undo()
|
||||
# -> UNDO selecting entity.
|
||||
general.undo()
|
||||
# -> UNDO entity creation.
|
||||
general.undo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.creation_undo, not physical_sky_entity.exists())
|
||||
|
||||
# 4. REDO the entity creation and component addition.
|
||||
# -> REDO entity creation.
|
||||
general.redo()
|
||||
# -> REDO selecting entity.
|
||||
general.redo()
|
||||
# -> REDO naming entity.
|
||||
general.redo()
|
||||
# -> REDO component addition.
|
||||
general.redo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.creation_redo, physical_sky_entity.exists())
|
||||
|
||||
# 5. Enter/Exit game mode.
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
general.idle_wait_frames(1)
|
||||
helper.exit_game_mode(Tests.exit_game_mode)
|
||||
|
||||
# 6. Test IsHidden.
|
||||
physical_sky_entity.set_visibility_state(False)
|
||||
Report.result(Tests.is_hidden, physical_sky_entity.is_hidden() is True)
|
||||
|
||||
# 7. Test IsVisible.
|
||||
physical_sky_entity.set_visibility_state(True)
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.is_visible, physical_sky_entity.is_visible() is True)
|
||||
|
||||
# 8. Delete Physical Sky entity.
|
||||
physical_sky_entity.delete()
|
||||
Report.result(Tests.entity_deleted, not physical_sky_entity.exists())
|
||||
|
||||
# 9. UNDO deletion.
|
||||
general.undo()
|
||||
Report.result(Tests.deletion_undo, physical_sky_entity.exists())
|
||||
|
||||
# 10. REDO deletion.
|
||||
general.redo()
|
||||
Report.result(Tests.deletion_redo, not physical_sky_entity.exists())
|
||||
|
||||
# 11. Look for errors.
|
||||
helper.wait_for_condition(lambda: error_tracer.has_errors, 1.0)
|
||||
Report.result(Tests.no_error_occurred, not error_tracer.has_errors)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(AtomEditorComponents_PhysicalSky_AddedToEntity)
|
||||
@ -0,0 +1,138 @@
|
||||
"""
|
||||
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:
|
||||
camera_creation = ("Camera Entity successfully created", "Camera Entity failed to be created")
|
||||
camera_component_added = ("Camera component was added to entity", "Camera component failed to be added to entity")
|
||||
camera_component_check = ("Entity has a Camera component", "Entity failed to find Camera component")
|
||||
creation_undo = ("UNDO Entity creation success", "UNDO Entity creation failed")
|
||||
creation_redo = ("REDO Entity creation success", "REDO Entity creation failed")
|
||||
postfx_radius_weight_creation = ("PostFX Radius Weight Modifier Entity successfully created", "PostFX Radius Weight Modifier Entity failed to be created")
|
||||
postfx_radius_weight_component = ("Entity has a PostFX Radius Weight Modifier component", "Entity failed to find PostFX Radius Weight Modifier component")
|
||||
enter_game_mode = ("Entered game mode", "Failed to enter game mode")
|
||||
exit_game_mode = ("Exited game mode", "Couldn't exit game mode")
|
||||
is_visible = ("Entity is visible", "Entity was not visible")
|
||||
is_hidden = ("Entity is hidden", "Entity was not hidden")
|
||||
entity_deleted = ("Entity deleted", "Entity was not deleted")
|
||||
deletion_undo = ("UNDO deletion success", "UNDO deletion failed")
|
||||
deletion_redo = ("REDO deletion success", "REDO deletion failed")
|
||||
no_error_occurred = ("No errors detected", "Errors were detected")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def AtomEditorComponents_PostFXRadiusWeightModifier_AddedToEntity():
|
||||
"""
|
||||
Summary:
|
||||
Tests the PostFX Radius Weight Modifier component can be added to an entity and has the expected functionality.
|
||||
|
||||
Test setup:
|
||||
- Wait for Editor idle loop.
|
||||
- Open the "Base" level.
|
||||
|
||||
Expected Behavior:
|
||||
The component can be added, used in game mode, hidden/shown, deleted, and has accurate required components.
|
||||
Creation and deletion undo/redo should also work.
|
||||
|
||||
Test Steps:
|
||||
1) Create a Post FX Radius Weight Modifier entity with no components.
|
||||
2) Add Post FX Radius Weight Modifier component to Post FX Radius Weight Modifier entity.
|
||||
3) UNDO the entity creation and component addition.
|
||||
4) REDO the entity creation and component addition.
|
||||
5) Enter/Exit game mode.
|
||||
6) Test IsHidden.
|
||||
7) Test IsVisible.
|
||||
8) Delete PostFX Radius Weight Modifier entity.
|
||||
9) UNDO deletion.
|
||||
10) REDO deletion.
|
||||
11) Look for errors.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
from editor_python_test_tools.editor_entity_utils import EditorEntity
|
||||
from editor_python_test_tools.utils import Report, Tracer, TestHelper as helper
|
||||
|
||||
with Tracer() as error_tracer:
|
||||
# Test setup begins.
|
||||
# Setup: Wait for Editor idle loop before executing Python hydra scripts then open "Base" level.
|
||||
helper.init_idle()
|
||||
helper.open_level("", "Base")
|
||||
|
||||
# Test steps begin.
|
||||
# 1. Create a Post FX Radius Weight Modifier entity with no components.
|
||||
postfx_radius_weight_name = "PostFX Radius Weight Modifier"
|
||||
postfx_radius_weight_entity = EditorEntity.create_editor_entity_at(
|
||||
math.Vector3(512.0, 512.0, 34.0), postfx_radius_weight_name)
|
||||
Report.critical_result(Tests.postfx_radius_weight_creation, postfx_radius_weight_entity.exists())
|
||||
|
||||
# 2. Add Post FX Radius Weight Modifier component to Post FX Radius Weight Modifier entity.
|
||||
postfx_radius_weight_entity.add_component(postfx_radius_weight_name)
|
||||
Report.critical_result(
|
||||
Tests.postfx_radius_weight_component, postfx_radius_weight_entity.has_component(postfx_radius_weight_name))
|
||||
|
||||
# 3. UNDO the entity creation and component addition.
|
||||
# -> UNDO component addition.
|
||||
general.undo()
|
||||
# -> UNDO naming entity.
|
||||
general.undo()
|
||||
# -> UNDO selecting entity.
|
||||
general.undo()
|
||||
# -> UNDO entity creation.
|
||||
general.undo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.creation_undo, not postfx_radius_weight_entity.exists())
|
||||
|
||||
# 4. REDO the entity creation and component addition.
|
||||
# -> REDO entity creation.
|
||||
general.redo()
|
||||
# -> REDO selecting entity.
|
||||
general.redo()
|
||||
# -> REDO naming entity.
|
||||
general.redo()
|
||||
# -> REDO component addition.
|
||||
general.redo()
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.creation_redo, postfx_radius_weight_entity.exists())
|
||||
|
||||
# 5. Enter/Exit game mode.
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
general.idle_wait_frames(1)
|
||||
helper.exit_game_mode(Tests.exit_game_mode)
|
||||
|
||||
# 6. Test IsHidden.
|
||||
postfx_radius_weight_entity.set_visibility_state(False)
|
||||
Report.result(Tests.is_hidden, postfx_radius_weight_entity.is_hidden() is True)
|
||||
|
||||
# 7. Test IsVisible.
|
||||
postfx_radius_weight_entity.set_visibility_state(True)
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.is_visible, postfx_radius_weight_entity.is_visible() is True)
|
||||
|
||||
# 8. Delete PostFX Radius Weight Modifier entity.
|
||||
postfx_radius_weight_entity.delete()
|
||||
Report.result(Tests.entity_deleted, not postfx_radius_weight_entity.exists())
|
||||
|
||||
# 9. UNDO deletion.
|
||||
general.undo()
|
||||
Report.result(Tests.deletion_undo, postfx_radius_weight_entity.exists())
|
||||
|
||||
# 10. REDO deletion.
|
||||
general.redo()
|
||||
Report.result(Tests.deletion_redo, not postfx_radius_weight_entity.exists())
|
||||
|
||||
# 11. Look for errors.
|
||||
helper.wait_for_condition(lambda: error_tracer.has_errors, 1.0)
|
||||
Report.result(Tests.no_error_occurred, not error_tracer.has_errors)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(AtomEditorComponents_PostFXRadiusWeightModifier_AddedToEntity)
|
||||
@ -0,0 +1,187 @@
|
||||
"""
|
||||
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():
|
||||
azshader_was_removed = ("azshader was removed", "Failed to remove azshader")
|
||||
azshader_was_compiled = ("azshader was compiled", "Failed to compile azshader")
|
||||
no_error_occurred = ("No errors detected", "Errors were detected")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def ShaderAssetBuilder_RecompilesShaderAsChainOfDependenciesChanges():
|
||||
"""
|
||||
This test validates: "Shader Builders May Fail When Multiple New Files Are Added"
|
||||
It creates source assets to compile a particular shader.
|
||||
1- The first phase generates the source assets out of order and slowly. The AP should
|
||||
wakeup each time one of the source dependencies appears but will fail each time. Only when the
|
||||
last dependency appears then the shader should build successfully.
|
||||
2- The second phase is similar as above, except that all source assets will be created
|
||||
at once and We also expect that in the end the shader is built successfully.
|
||||
"""
|
||||
import os
|
||||
import shutil
|
||||
|
||||
import azlmbr.asset as azasset
|
||||
import azlmbr.bus as azbus
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as azmath
|
||||
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
from editor_python_test_tools.utils import Tracer
|
||||
import ly_test_tools.environment.file_system as fs
|
||||
|
||||
def _copy_file(src_file, src_path, target_file, target_path):
|
||||
# type: (str, str, str, str) -> None
|
||||
"""
|
||||
Copies the [src_file] located in [src_path] to the [target_file] located at [target_path].
|
||||
Leaves the [target_file] unlocked for reading and writing privileges
|
||||
:param src_file: The source file to copy (file name)
|
||||
:param src_path: The source file's path
|
||||
:param target_file: The target file to copy into (file name)
|
||||
:param target_path: The target file's path
|
||||
:return: None
|
||||
"""
|
||||
target_file_path = os.path.join(target_path, target_file)
|
||||
src_file_path = os.path.join(src_path, src_file)
|
||||
if os.path.exists(target_file_path):
|
||||
fs.unlock_file(target_file_path)
|
||||
shutil.copyfile(src_file_path, target_file_path)
|
||||
|
||||
def _copy_tmp_files_in_order(src_directory, file_list, dst_directory, wait_time_in_between=0.0):
|
||||
# type: (str, list, str, float) -> None
|
||||
"""
|
||||
This function assumes that for each file name listed in @file_list
|
||||
there's file named "@filename.txt" which the original source file
|
||||
but they will be copied with just the @filename (.txt removed).
|
||||
"""
|
||||
for filename in file_list:
|
||||
src_name = f"{filename}.txt"
|
||||
_copy_file(src_name, src_directory, filename, dst_directory)
|
||||
if wait_time_in_between > 0.0:
|
||||
print(f"Created {filename} in {dst_directory}")
|
||||
general.idle_wait(wait_time_in_between)
|
||||
|
||||
def _remove_file(src_file, src_path):
|
||||
# type: (str, str) -> None
|
||||
"""
|
||||
Removes the [src_file] located in [src_path].
|
||||
:param src_file: The source file to copy (file name)
|
||||
:param src_path: The source file's path
|
||||
:return: None
|
||||
"""
|
||||
src_file_path = os.path.join(src_path, src_file)
|
||||
if os.path.exists(src_file_path):
|
||||
fs.unlock_file(src_file_path)
|
||||
os.remove(src_file_path)
|
||||
|
||||
def _remove_files(directory, file_list):
|
||||
for filename in file_list:
|
||||
_remove_file(filename, directory)
|
||||
|
||||
def _asset_exists(cache_relative_path):
|
||||
asset_id = azasset.AssetCatalogRequestBus(azbus.Broadcast, "GetAssetIdByPath", cache_relative_path,
|
||||
azmath.Uuid(), False)
|
||||
return asset_id.is_valid()
|
||||
|
||||
# Required for automated tests
|
||||
helper.init_idle()
|
||||
|
||||
game_root_path = os.path.normpath(general.get_game_folder())
|
||||
game_asset_path = os.path.join(game_root_path, "Assets")
|
||||
|
||||
base_dir = os.path.dirname(__file__)
|
||||
src_assets_subdir = os.path.join(base_dir, "TestAssets", "ShaderAssetBuilder")
|
||||
|
||||
with Tracer() as error_tracer:
|
||||
# The script drives the execution of the test, to return the flow back to the editor,
|
||||
# we will tick it one time
|
||||
general.idle_wait_frames(1)
|
||||
|
||||
# This is the order in which the source assets should be deployed
|
||||
# to avoid source dependency issues with the old MCPP-based CreateJobs.
|
||||
file_list = [
|
||||
"Test2Color.azsli",
|
||||
"Test3Color.azsli",
|
||||
"Test1Color.azsli",
|
||||
"DependencyValidation.azsl",
|
||||
"DependencyValidation.shader"
|
||||
]
|
||||
|
||||
reverse_file_list = file_list[::-1]
|
||||
|
||||
# Remove files in reverse order
|
||||
_remove_files(game_asset_path, reverse_file_list)
|
||||
|
||||
# Wait here until the azshader doesn't exist anymore.
|
||||
azshader_name = "assets/dependencyvalidation.azshader"
|
||||
helper.wait_for_condition(lambda: not _asset_exists(azshader_name), 5.0)
|
||||
|
||||
Report.critical_result(Tests.azshader_was_removed, not _asset_exists(azshader_name))
|
||||
|
||||
_copy_tmp_files_in_order(src_assets_subdir, file_list, game_asset_path, 1.0)
|
||||
|
||||
# Give enough time to AP to compile the shader
|
||||
helper.wait_for_condition(lambda: _asset_exists(azshader_name), 60.0)
|
||||
|
||||
Report.critical_result(Tests.azshader_was_compiled, _asset_exists(azshader_name))
|
||||
|
||||
# The first part was about compiling the shader under normal conditions.
|
||||
# Let's remove the files from the previous phase and will proceed
|
||||
# to make the source files visible to the AP in reverse order. The
|
||||
# ShaderAssetBuilder will only succeed when the last file becomes visible.
|
||||
_remove_files(game_asset_path, reverse_file_list)
|
||||
helper.wait_for_condition(lambda: not _asset_exists(azshader_name), 5.0)
|
||||
Report.critical_result(Tests.azshader_was_removed, not _asset_exists(azshader_name))
|
||||
|
||||
# Remark, if you are running this test manually from the Editor with "pyRunFile",
|
||||
# You'll notice how the AP issues notifications that it fails to compile the shader
|
||||
# as the source files are being copied to the "Assets" subfolder.
|
||||
# Those errors are OK and also expected because We need the AP to wake up as each
|
||||
# reported source dependency exists. Once the last file is copied then all source
|
||||
# dependencies are fully satisfied and the shader should compile successfully.
|
||||
# And this summarizes the importance of this Test: The previous version
|
||||
# of ShaderAssetBuilder::CreateJobs was incapable of compiling the shader under the conditions
|
||||
# presented in this test, but with the new version of ShaderAssetBuilder::CreateJobs, which
|
||||
# doesn't use MCPP for #include files discovery, it should eventually compile the shader
|
||||
# once all the source files are in place.
|
||||
_copy_tmp_files_in_order(src_assets_subdir, reverse_file_list, game_asset_path, 3.0)
|
||||
|
||||
# Give enough time to AP to compile the shader
|
||||
helper.wait_for_condition(lambda: _asset_exists(azshader_name), 60.0)
|
||||
|
||||
Report.critical_result(Tests.azshader_was_compiled, _asset_exists(azshader_name))
|
||||
|
||||
# The last phase of the test puts stress on potential race conditions
|
||||
# when all required files appear as soon as possible.
|
||||
|
||||
# First Clean up.
|
||||
# Remove left over files.
|
||||
_remove_files(game_asset_path, reverse_file_list)
|
||||
helper.wait_for_condition(lambda: not _asset_exists(azshader_name), 5.0)
|
||||
Report.critical_result(Tests.azshader_was_removed, not _asset_exists(azshader_name))
|
||||
|
||||
# Now let's copy all the source files to the "Assets" folder as fast as possible.
|
||||
_copy_tmp_files_in_order(src_assets_subdir, reverse_file_list, game_asset_path)
|
||||
|
||||
# Give enough time to AP to compile the shader
|
||||
helper.wait_for_condition(lambda: _asset_exists(azshader_name), 60.0)
|
||||
|
||||
Report.critical_result(Tests.azshader_was_compiled, _asset_exists(azshader_name))
|
||||
|
||||
# All good, let's cleanup leftover files before closing the test.
|
||||
_remove_files(game_asset_path, reverse_file_list)
|
||||
helper.wait_for_condition(lambda: not _asset_exists(azshader_name), 5.0)
|
||||
|
||||
# Look for errors to raise.
|
||||
helper.wait_for_condition(lambda: error_tracer.has_errors, 1.0)
|
||||
Report.result(Tests.no_error_occurred, not error_tracer.has_errors)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(ShaderAssetBuilder_RecompilesShaderAsChainOfDependenciesChanges)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue