merge system component

Signed-off-by: chcurran <82187351+carlitosan@users.noreply.github.com>
monroegm-disable-blank-issue-2
chcurran 4 years ago
commit 72ff163ff0

@ -8,19 +8,21 @@
## Deploy CDK Applications
1. Go to the AWS IAM console and create an IAM role called o3de-automation-tests which adds your own account as as a trusted entity and uses the "AdministratorAccess" permissions policy.
2. Copy {engine_root}\scripts\build\Platform\Windows\deploy_cdk_applications.cmd to your engine root folder.
3. Open a Command Prompt window at the engine root and set the following environment variables:
Set O3DE_AWS_PROJECT_NAME=AWSAUTO
Set O3DE_AWS_DEPLOY_REGION=us-east-1
Set ASSUME_ROLE_ARN="arn:aws:iam::{your_aws_account_id}:role/o3de-automation-tests"
Set COMMIT_ID=HEAD
4. Deploy the CDK applications for AWS gems by running deploy_cdk_applications.cmd in the same Command Prompt window.
5. Edit AWS\common\constants.py to replace the assume role ARN with your own:
arn:aws:iam::{your_aws_account_id}:role/o3de-automation-tests
3. Open a new Command Prompt window at the engine root and set the following environment variables:
Set O3DE_AWS_PROJECT_NAME=AWSAUTO
Set O3DE_AWS_DEPLOY_REGION=us-east-1
Set ASSUME_ROLE_ARN=arn:aws:iam::{your_aws_account_id}:role/o3de-automation-tests
Set COMMIT_ID=HEAD
4. In the same Command Prompt window, Deploy the CDK applications for AWS gems by running deploy_cdk_applications.cmd.
## Run Automation Tests
### CLI
Open a Command Prompt window at the engine root and run the following CLI command:
In the same Command Prompt window, run the following CLI command:
python\python.cmd -m pytest {path_to_the_test_file} --build-directory {directory_to_the_profile_build}
### Pycharm
You can also run any specific automation test directly from Pycharm by providing the "--build-directory" argument in the Run Configuration.
You can also run any specific automation test directly from Pycharm by providing the "--build-directory" argument in the Run Configuration.
## Destroy CDK Applications
1. Copy {engine_root}\scripts\build\Platform\Windows\destroy_cdk_applications.cmd to your engine root folder.
2. In the same Command Prompt window, destroy the CDK applications for AWS gems by running destroy_cdk_applications.cmd.

@ -31,7 +31,7 @@ def setup(launcher: pytest.fixture,
Set up the resource mapping configuration and start the log monitor.
:param launcher: Client launcher for running the test level.
:param asset_processor: asset_processor fixture.
:return log monitor object, metrics file path and the metrics stack name.
:return log monitor object.
"""
asset_processor.start()
asset_processor.wait_for_idle()
@ -73,12 +73,11 @@ def monitor_metrics_submission(log_monitor: pytest.fixture) -> None:
f'unexpected_lines values: {unexpected_lines}')
def query_metrics_from_s3(aws_metrics_utils: pytest.fixture, resource_mappings: pytest.fixture, stack_name: str) -> None:
def query_metrics_from_s3(aws_metrics_utils: pytest.fixture, resource_mappings: pytest.fixture) -> None:
"""
Verify that the metrics events are delivered to the S3 bucket and can be queried.
:param aws_metrics_utils: aws_metrics_utils fixture.
:param resource_mappings: resource_mappings fixture.
:param stack_name: name of the CloudFormation stack.
"""
aws_metrics_utils.verify_s3_delivery(
resource_mappings.get_resource_name_id('AWSMetrics.AnalyticsBucketName')
@ -89,23 +88,24 @@ def query_metrics_from_s3(aws_metrics_utils: pytest.fixture, resource_mappings:
resource_mappings.get_resource_name_id('AWSMetrics.EventsCrawlerName'))
# Remove the events_json table if exists so that the sample query can create a table with the same name.
aws_metrics_utils.delete_table(f'{stack_name}-eventsdatabase', 'events_json')
aws_metrics_utils.run_named_queries(f'{stack_name}-AthenaWorkGroup')
aws_metrics_utils.delete_table(resource_mappings.get_resource_name_id('AWSMetrics.EventDatabaseName'), 'events_json')
aws_metrics_utils.run_named_queries(resource_mappings.get_resource_name_id('AWSMetrics.AthenaWorkGroupName'))
logger.info('Query metrics from S3 successfully.')
def verify_operational_metrics(aws_metrics_utils: pytest.fixture, stack_name: str, start_time: datetime) -> None:
def verify_operational_metrics(aws_metrics_utils: pytest.fixture,
resource_mappings: pytest.fixture, start_time: datetime) -> None:
"""
Verify that operational health metrics are delivered to CloudWatch.
aws_metrics_utils: aws_metrics_utils fixture.
stack_name: name of the CloudFormation stack.
start_time: Time when the game launcher starts.
:param aws_metrics_utils: aws_metrics_utils fixture.
:param resource_mappings: resource_mappings fixture.
:param start_time: Time when the game launcher starts.
"""
aws_metrics_utils.verify_cloud_watch_delivery(
'AWS/Lambda',
'Invocations',
[{'Name': 'FunctionName',
'Value': f'{stack_name}-AnalyticsProcessingLambda'}],
'Value': resource_mappings.get_resource_name_id('AWSMetrics.AnalyticsProcessingLambdaName')}],
start_time)
logger.info('AnalyticsProcessingLambda metrics are sent to CloudWatch.')
@ -113,7 +113,7 @@ def verify_operational_metrics(aws_metrics_utils: pytest.fixture, stack_name: st
'AWS/Lambda',
'Invocations',
[{'Name': 'FunctionName',
'Value': f'{stack_name}-EventsProcessingLambda'}],
'Value': resource_mappings.get_resource_name_id('AWSMetrics.EventProcessingLambdaName')}],
start_time)
logger.info('EventsProcessingLambda metrics are sent to CloudWatch.')
@ -139,7 +139,6 @@ def update_kinesis_analytics_application_status(aws_metrics_utils: pytest.fixtur
@pytest.mark.usefixtures('resource_mappings')
@pytest.mark.parametrize('assume_role_arn', [constants.ASSUME_ROLE_ARN])
@pytest.mark.parametrize('feature_name', [AWS_METRICS_FEATURE_NAME])
@pytest.mark.parametrize('level', ['AWS/Metrics'])
@pytest.mark.parametrize('profile_name', ['AWSAutomationTest'])
@pytest.mark.parametrize('project', ['AutomatedTesting'])
@pytest.mark.parametrize('region_name', [constants.AWS_REGION])
@ -150,6 +149,7 @@ class TestAWSMetricsWindows(object):
"""
Test class to verify the real-time and batch analytics for metrics.
"""
@pytest.mark.parametrize('level', ['AWS/Metrics'])
def test_realtime_and_batch_analytics(self,
level: str,
launcher: pytest.fixture,
@ -157,7 +157,6 @@ class TestAWSMetricsWindows(object):
workspace: pytest.fixture,
aws_utils: pytest.fixture,
resource_mappings: pytest.fixture,
stacks: typing.List,
aws_metrics_utils: pytest.fixture):
"""
Verify that the metrics events are sent to CloudWatch and S3 for analytics.
@ -167,10 +166,6 @@ class TestAWSMetricsWindows(object):
args=(aws_metrics_utils, resource_mappings, True))
kinesis_analytics_application_thread.start()
# Clear the analytics bucket objects before sending new metrics.
aws_metrics_utils.empty_bucket(
resource_mappings.get_resource_name_id('AWSMetrics.AnalyticsBucketName'))
log_monitor = setup(launcher, asset_processor)
# Kinesis analytics application needs to be in the running state before we start the game launcher.
@ -193,10 +188,10 @@ class TestAWSMetricsWindows(object):
operational_threads = list()
operational_threads.append(
AWSMetricsThread(target=query_metrics_from_s3,
args=(aws_metrics_utils, resource_mappings, stacks[0])))
args=(aws_metrics_utils, resource_mappings)))
operational_threads.append(
AWSMetricsThread(target=verify_operational_metrics,
args=(aws_metrics_utils, stacks[0], start_time)))
args=(aws_metrics_utils, resource_mappings, start_time)))
operational_threads.append(
AWSMetricsThread(target=update_kinesis_analytics_application_status,
args=(aws_metrics_utils, resource_mappings, False)))
@ -205,6 +200,7 @@ class TestAWSMetricsWindows(object):
for thread in operational_threads:
thread.join()
@pytest.mark.parametrize('level', ['AWS/Metrics'])
def test_unauthorized_user_request_rejected(self,
level: str,
launcher: pytest.fixture,
@ -227,3 +223,13 @@ class TestAWSMetricsWindows(object):
halt_on_unexpected=True)
assert result, 'Metrics events are sent successfully by unauthorized user'
logger.info('Unauthorized user is rejected to send metrics.')
def test_clean_up_s3_bucket(self,
aws_utils: pytest.fixture,
resource_mappings: pytest.fixture,
aws_metrics_utils: pytest.fixture):
"""
Clear the analytics bucket objects so that the S3 bucket can be destroyed during tear down.
"""
aws_metrics_utils.empty_bucket(
resource_mappings.get_resource_name_id('AWSMetrics.AnalyticsBucketName'))

@ -13,37 +13,56 @@
if(PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_BUILD_TESTS_SUPPORTED AND AutomatedTesting IN_LIST LY_PROJECTS)
ly_add_pytest(
NAME AutomatedTesting::AtomRenderer_HydraTests_Main
NAME AutomatedTesting::Atom_TestSuite_Main
TEST_SUITE main
PATH ${CMAKE_CURRENT_LIST_DIR}/test_Atom_MainSuite.py
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Main.py
TEST_SERIAL
TIMEOUT 600
RUNTIME_DEPENDENCIES
AssetProcessor
AutomatedTesting.Assets
Editor
COMPONENT
Atom
)
ly_add_pytest(
NAME AutomatedTesting::AtomRenderer_HydraTests_Sandbox
NAME AutomatedTesting::Atom_TestSuite_Main_Optimized
TEST_SUITE main
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Main_Optimized.py
TEST_SERIAL
TIMEOUT 600
RUNTIME_DEPENDENCIES
AssetProcessor
AutomatedTesting.Assets
Editor
COMPONENT
Atom
)
ly_add_pytest(
NAME AutomatedTesting::Atom_TestSuite_Sandbox
TEST_SUITE sandbox
PATH ${CMAKE_CURRENT_LIST_DIR}/test_Atom_SandboxSuite.py
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Sandbox.py
TEST_SERIAL
TIMEOUT 400
RUNTIME_DEPENDENCIES
AssetProcessor
AutomatedTesting.Assets
Editor
COMPONENT
Atom
)
ly_add_pytest(
NAME AutomatedTesting::AtomRenderer_HydraTests_GPUTests
NAME AutomatedTesting::Atom_TestSuite_Main_GPU
TEST_SUITE main
TEST_REQUIRES gpu
TEST_SERIAL
TIMEOUT 1200
PATH ${CMAKE_CURRENT_LIST_DIR}/test_Atom_GPUTests.py
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Main_GPU.py
RUNTIME_DEPENDENCIES
AssetProcessor
AutomatedTesting.Assets
Editor
COMPONENT
Atom
)
endif()

@ -13,10 +13,10 @@ import pytest
import ly_test_tools.environment.file_system as file_system
import editor_python_test_tools.hydra_test_utils as hydra
from atom_renderer.atom_utils.atom_constants import LIGHT_TYPES
from Atom.atom_utils.atom_constants import LIGHT_TYPES
logger = logging.getLogger(__name__)
TEST_DIRECTORY = os.path.join(os.path.dirname(__file__), "atom_hydra_scripts")
TEST_DIRECTORY = os.path.join(os.path.dirname(__file__), "tests")
@pytest.mark.parametrize("project", ["AutomatedTesting"])
@ -38,24 +38,24 @@ class TestAtomEditorComponentsMain(object):
7. Exposure Control
8. Directional Light
9. DepthOfField
10. Decal (Atom)
10. Decal
"""
cfg_args = [level]
expected_lines = [
# Decal (Atom) Component
"Decal (Atom) Entity successfully created",
"Decal (Atom)_test: Component added to the entity: True",
"Decal (Atom)_test: Component removed after UNDO: True",
"Decal (Atom)_test: Component added after REDO: True",
"Decal (Atom)_test: Entered game mode: True",
"Decal (Atom)_test: Exit game mode: True",
"Decal (Atom) Controller|Configuration|Material: SUCCESS",
"Decal (Atom)_test: Entity is hidden: True",
"Decal (Atom)_test: Entity is shown: True",
"Decal (Atom)_test: Entity deleted: True",
"Decal (Atom)_test: UNDO entity deletion works: True",
"Decal (Atom)_test: REDO entity deletion works: True",
# Decal Component
"Decal Entity successfully created",
"Decal_test: Component added to the entity: True",
"Decal_test: Component removed after UNDO: True",
"Decal_test: Component added after REDO: True",
"Decal_test: Entered game mode: True",
"Decal_test: Exit game mode: True",
"Decal Controller|Configuration|Material: SUCCESS",
"Decal_test: Entity is hidden: True",
"Decal_test: Entity is shown: True",
"Decal_test: Entity deleted: True",
"Decal_test: UNDO entity deletion works: True",
"Decal_test: REDO entity deletion works: True",
# DepthOfField Component
"DepthOfField Entity successfully created",
"DepthOfField_test: Component added to the entity: True",
@ -161,6 +161,21 @@ class TestAtomEditorComponentsMain(object):
"Display Mapper_test: Entity deleted: True",
"Display Mapper_test: UNDO entity deletion works: True",
"Display Mapper_test: REDO entity deletion works: True",
# Reflection Probe Component
"Reflection Probe Entity successfully created",
"Reflection Probe_test: Component added to the entity: True",
"Reflection Probe_test: Component removed after UNDO: True",
"Reflection Probe_test: Component added after REDO: True",
"Reflection Probe_test: Entered game mode: True",
"Reflection Probe_test: Exit game mode: True",
"Reflection Probe_test: Entity disabled initially: True",
"Reflection Probe_test: Entity enabled after adding required components: True",
"Reflection Probe_test: Cubemap is generated: True",
"Reflection Probe_test: Entity is hidden: True",
"Reflection Probe_test: Entity is shown: True",
"Reflection Probe_test: Entity deleted: True",
"Reflection Probe_test: UNDO entity deletion works: True",
"Reflection Probe_test: REDO entity deletion works: True",
]
unexpected_lines = [
@ -200,8 +215,6 @@ class TestAtomEditorComponentsMain(object):
"Controller|Configuration|Shadows|Shadow filter method set to 1", # PCF
"Controller|Configuration|Shadows|Filtering sample count set to 4",
"Controller|Configuration|Shadows|Filtering sample count set to 64",
"Controller|Configuration|Shadows|PCF method set to 0",
"Controller|Configuration|Shadows|PCF method set to 1",
"Controller|Configuration|Shadows|Shadow filter method set to 2", # ESM
"Controller|Configuration|Shadows|ESM exponent set to 50.0",
"Controller|Configuration|Shadows|ESM exponent set to 5000.0",

@ -3,8 +3,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
Tests that require a GPU in order to run.
"""
import datetime
@ -22,7 +20,7 @@ import editor_python_test_tools.hydra_test_utils as hydra
logger = logging.getLogger(__name__)
DEFAULT_SUBFOLDER_PATH = 'user/PythonTests/Automated/Screenshots'
TEST_DIRECTORY = os.path.join(os.path.dirname(__file__), "atom_hydra_scripts")
TEST_DIRECTORY = os.path.join(os.path.dirname(__file__), "tests")
def golden_images_directory():

@ -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;
}

@ -3,8 +3,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
Hydra script that creates an entity and attaches Atom components to it for test verification.
"""
import os
@ -17,6 +15,7 @@ import azlmbr.asset as asset
import azlmbr.entity as entity
import azlmbr.legacy.general as general
import azlmbr.editor as editor
import azlmbr.render as render
sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests"))
@ -125,6 +124,19 @@ def run():
def verify_set_property(entity_obj, path, value):
entity_obj.get_set_test(0, path, value)
# Verify cubemap generation
def verify_cubemap_generation(component_name, entity_obj):
# Initially Check if the component has Reflection Probe component
if not hydra.has_components(entity_obj.id, ["Reflection Probe"]):
raise ValueError(f"Given entity {entity_obj.name} has no Reflection Probe component")
render.EditorReflectionProbeBus(azlmbr.bus.Event, "BakeReflectionProbe", entity_obj.id)
def get_value():
hydra.get_component_property_value(entity_obj.components[0], "Cubemap|Baked Cubemap Path")
TestHelper.wait_for_condition(lambda: get_value() != "", 20.0)
general.log(f"{component_name}_test: Cubemap is generated: {get_value() != ''}")
# Wait for Editor idle loop before executing Python hydra scripts.
TestHelper.init_idle()
@ -172,7 +184,7 @@ def run():
material_asset = asset.AssetCatalogRequestBus(
bus.Broadcast, "GetAssetIdByPath", material_asset_path, math.Uuid(), False)
ComponentTests(
"Decal (Atom)", lambda entity_obj: verify_set_property(
"Decal", lambda entity_obj: verify_set_property(
entity_obj, "Controller|Configuration|Material", material_asset))
# Directional Light Component
@ -215,6 +227,12 @@ def run():
# Display Mapper Component
ComponentTests("Display Mapper")
# Reflection Probe Component
reflection_probe = "Reflection Probe"
ComponentTests(
reflection_probe,
lambda entity_obj: verify_required_component_addition(entity_obj, ["Box Shape"], reflection_probe),
lambda entity_obj: verify_cubemap_generation(reflection_probe, entity_obj),)
if __name__ == "__main__":
run()

@ -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)

@ -1,10 +1,8 @@
"""
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.
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
Hydra script that creates an entity, attaches the Light component to it for test verifications.
The test verifies that each light type option is available and can be selected without errors.
"""
import os
@ -19,7 +17,7 @@ import azlmbr.legacy.general as general
sys.path.append(os.path.join(azlmbr.paths.devassets, "Gem", "PythonTests"))
import editor_python_test_tools.hydra_editor_utils as hydra
from atom_renderer.atom_utils.atom_constants import LIGHT_TYPES
from Atom.atom_utils.atom_constants import LIGHT_TYPES
LIGHT_TYPE_PROPERTY = 'Controller|Configuration|Light type'
SPHERE_AND_SPOT_DISK_LIGHT_PROPERTIES = [
@ -31,8 +29,6 @@ SPHERE_AND_SPOT_DISK_LIGHT_PROPERTIES = [
("Controller|Configuration|Shadows|Shadow filter method", 1), # PCF
("Controller|Configuration|Shadows|Filtering sample count", 4.0),
("Controller|Configuration|Shadows|Filtering sample count", 64.0),
("Controller|Configuration|Shadows|PCF method", 0), # Bicubic
("Controller|Configuration|Shadows|PCF method", 1), # Boundary search
("Controller|Configuration|Shadows|Shadow filter method", 2), # ECM
("Controller|Configuration|Shadows|ESM exponent", 50),
("Controller|Configuration|Shadows|ESM exponent", 5000),

@ -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)

@ -3,12 +3,12 @@ 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 azlmbr.materialeditor will fail with a ModuleNotFound error when using this script with Editor.exe
This is because azlmbr.materialeditor only binds to MaterialEditor.exe and not Editor.exe
You need to launch this script with MaterialEditor.exe in order for azlmbr.materialeditor to appear.
"""
# import azlmbr.materialeditor will fail with a ModuleNotFound error when using this script with Editor.exe
# This is because azlmbr.materialeditor only binds to MaterialEditor.exe and not Editor.exe
# You need to launch this script with MaterialEditor.exe in order for azlmbr.materialeditor to appear.
import os
import sys
import time
@ -18,7 +18,7 @@ import azlmbr.paths
sys.path.append(os.path.join(azlmbr.paths.devassets, "Gem", "PythonTests"))
import atom_renderer.atom_utils.material_editor_utils as material_editor
import Atom.atom_utils.material_editor_utils as material_editor
NEW_MATERIAL = "test_material.material"
NEW_MATERIAL_1 = "test_material_1.material"

@ -3,11 +3,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
Hydra script that is used to create a new level with a default rendering setup.
After the level is setup, screenshots are diffed against golden images are used to verify pass/fail results of the test.
See the run() function for more in-depth test info.
"""
import os
@ -19,7 +14,7 @@ sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "P
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.editor_test_helper import EditorTestHelper
from atom_renderer.atom_utils.benchmark_utils import BenchmarkHelper
from Atom.atom_utils.benchmark_utils import BenchmarkHelper
SCREEN_WIDTH = 1280
SCREEN_HEIGHT = 720

@ -3,11 +3,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
Hydra script that is used to create a new level with a default rendering setup.
After the level is setup, screenshots are diffed against golden images are used to verify pass/fail results of the test.
See the run() function for more in-depth test info.
"""
import os
@ -26,7 +21,7 @@ sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "P
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.editor_test_helper import EditorTestHelper
from atom_renderer.atom_utils.screenshot_utils import ScreenshotHelper
from Atom.atom_utils.screenshot_utils import ScreenshotHelper
SCREEN_WIDTH = 1280
SCREEN_HEIGHT = 720

@ -3,12 +3,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
Hydra script that is used to create an entity with a Light component attached.
It then updates the property values of the Light component and takes a screenshot.
The screenshot is compared against an expected golden image for test verification.
See the run() function for more in-depth test info.
"""
import os
import sys
@ -23,7 +17,7 @@ import azlmbr.legacy.general as general
sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests"))
import editor_python_test_tools.hydra_editor_utils as hydra
from atom_renderer.atom_utils import atom_component_helper, atom_constants, screenshot_utils
from Atom.atom_utils import atom_component_helper, atom_constants, screenshot_utils
from editor_python_test_tools.editor_test_helper import EditorTestHelper
helper = EditorTestHelper(log_prefix="Atom_EditorTestHelper")

@ -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)

@ -18,10 +18,10 @@ include(${pal_dir}/PAL_traits_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
add_subdirectory(assetpipeline)
## Atom Renderer ##
add_subdirectory(atom_renderer)
add_subdirectory(Atom)
## Physics ##
add_subdirectory(physics)
add_subdirectory(Physics)
## ScriptCanvas ##
add_subdirectory(scripting)

@ -20,6 +20,7 @@ import azlmbr.legacy.general as general
# Helper file Imports
from editor_python_test_tools.utils import Report
class EditorComponent:
"""
EditorComponent class used to set and get the component property value using path
@ -28,7 +29,6 @@ class EditorComponent:
which also assigns self.id and self.type_id to the EditorComponent object.
"""
# Methods
def get_component_name(self) -> str:
"""
Used to get name of component
@ -87,6 +87,13 @@ class EditorComponent:
outcome.IsSuccess()
), f"Failure: Could not set value to '{self.get_component_name()}' : '{component_property_path}'"
def is_enabled(self):
"""
Used to verify if the component is enabled.
:return: True if enabled, otherwise False.
"""
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", self.id)
@staticmethod
def get_type_ids(component_names: list) -> list:
"""
@ -254,7 +261,7 @@ class EditorEntity:
def get_components_of_type(self, component_names: list) -> List[EditorComponent]:
"""
Used to get components of type component_name that already exists on Entity
:param component_name: Name to component to check
:param component_names: List of names of components to check
:return: List of Entity Component objects of given component name
"""
component_list = []
@ -318,3 +325,39 @@ class EditorEntity:
editor.EditorEntityAPIBus(bus.Event, "SetStartStatus", self.id, status_to_set)
set_status = self.get_start_status()
assert set_status == status_to_set, f"Failed to set start status of {desired_start_status} to {self.get_name}"
def delete(self) -> None:
"""
Used to delete the Entity.
:return: None
"""
editor.ToolsApplicationRequestBus(bus.Broadcast, "DeleteEntityById", self.id)
def set_visibility_state(self, is_visible: bool) -> None:
"""
Sets the visibility state on the object to visible or not visible.
:param is_visible: True for making visible, False to make not visible.
:return: None
"""
editor.EditorEntityAPIBus(bus.Event, "SetVisibilityState", self.id, is_visible)
def exists(self) -> bool:
"""
Used to verify if the Entity exists.
:return: True if the Entity exists, False otherwise.
"""
return editor.ToolsApplicationRequestBus(bus.Broadcast, "EntityExists", self.id)
def is_hidden(self) -> bool:
"""
Gets the "isHidden" value from the Entity.
:return: True if "isHidden" is enabled, False otherwise.
"""
return editor.EditorEntityInfoRequestBus(bus.Event, "IsHidden", self.id)
def is_visible(self) -> bool:
"""
Gets the "isVisible" value from the Entity.
:return: True if "isVisible" is enabled, False otherwise.
"""
return editor.EditorEntityInfoRequestBus(bus.Event, "IsVisible", self.id)

@ -81,7 +81,8 @@ def launch_and_validate_results(request, test_directory, editor, editor_script,
def launch_and_validate_results_launcher(launcher, level, remote_console_instance, expected_lines, null_renderer=True,
port_listener_timeout=120, log_monitor_timeout=300, remote_console_port=4600):
port_listener_timeout=120, log_monitor_timeout=300, remote_console_port=4600,
launch_ap=True):
"""
Runs the launcher with the specified level, and monitors Game.log for expected lines.
:param launcher: Configured launcher object to run test against.
@ -92,6 +93,7 @@ def launch_and_validate_results_launcher(launcher, level, remote_console_instanc
:param port_listener_timeout: Timeout for verifying successful connection to Remote Console.
:param log_monitor_timeout: Timeout for monitoring for lines in Game.log
:param remote_console_port: The port used to communicate with the Remote Console.
:param launch_ap: Whether or not to launch AP. Defaults to True.
"""
def _check_for_listening_port(port):
@ -110,7 +112,7 @@ def launch_and_validate_results_launcher(launcher, level, remote_console_instanc
launcher.args.extend(["-rhi=Null"])
# Start the Launcher
with launcher.start():
with launcher.start(launch_ap=launch_ap):
# Ensure Remote Console can be reached
waiter.wait_for(

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save