Gradient Signal automation optimizations with TestAutomationBase/parallelization (#3316)

* GradientSignal automation optimizations with TestAutomationBase/parallelization
* Changing Gradient Signal test registration to use TestAutomationBase

Signed-off-by: jckand-amzn <jckand@amazon.com>
monroegm-disable-blank-issue-2
jckand-amzn 4 years ago committed by GitHub
parent 1a430755df
commit e67485b51f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -157,7 +157,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
NAME AutomatedTesting::GradientSignalTests_Periodic NAME AutomatedTesting::GradientSignalTests_Periodic
TEST_SERIAL TEST_SERIAL
TEST_SUITE periodic TEST_SUITE periodic
PATH ${CMAKE_CURRENT_LIST_DIR}/gradient_signal PATH ${CMAKE_CURRENT_LIST_DIR}/gradient_signal/test_GradientSignal_Periodic.py
RUNTIME_DEPENDENCIES RUNTIME_DEPENDENCIES
AZ::AssetProcessor AZ::AssetProcessor
Legacy::Editor Legacy::Editor

@ -4,24 +4,9 @@ For complete copyright and license terms please see the LICENSE at the root of t
SPDX-License-Identifier: Apache-2.0 OR MIT SPDX-License-Identifier: Apache-2.0 OR MIT
""" """
import os
import sys
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.entity as entity
import azlmbr.paths
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) def GradientGenerators_Incompatibilities():
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.editor_test_helper import EditorTestHelper
class TestGradientGeneratorIncompatibilities(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="GradientGeneratorIncompatibilities", args=["level"])
def run_test(self):
""" """
Summary: Summary:
This test verifies that components are disabled when conflicting components are present on the same entity. This test verifies that components are disabled when conflicting components are present on the same entity.
@ -30,7 +15,7 @@ class TestGradientGeneratorIncompatibilities(EditorTestHelper):
Gradient Generator components are incompatible with Vegetation area components. Gradient Generator components are incompatible with Vegetation area components.
Test Steps: Test Steps:
1) Create a new level 1) Open a simple level
2) Create a new entity in the level 2) Create a new entity in the level
3) Add each Gradient Generator component to an entity, and add a Vegetation Area component to the same entity 3) Add each Gradient Generator component to an entity, and add a Vegetation Area component to the same entity
4) Verify that components are only enabled when entity is free of a conflicting component 4) Verify that components are only enabled when entity is free of a conflicting component
@ -43,6 +28,14 @@ class TestGradientGeneratorIncompatibilities(EditorTestHelper):
:return: None :return: None
""" """
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.entity as entity
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
gradient_generators = [ gradient_generators = [
'Altitude Gradient', 'Altitude Gradient',
'Constant Gradient', 'Constant Gradient',
@ -71,14 +64,9 @@ class TestGradientGeneratorIncompatibilities(EditorTestHelper):
'Vegetation Layer Blocker (Mesh)': 'Mesh' 'Vegetation Layer Blocker (Mesh)': 'Mesh'
} }
# Create a new empty level # Open an existing simple level
self.test_success = self.create_level( helper.init_idle()
self.args["level"], helper.open_level("Physics", "Base")
heightmap_resolution=1024,
heightmap_meters_per_pixel=1,
terrain_texture_resolution=4096,
use_terrain=False,
)
# For every gradient generator component, verify that they are incompatible # For every gradient generator component, verify that they are incompatible
# which each vegetation area component # which each vegetation area component
@ -103,9 +91,11 @@ class TestGradientGeneratorIncompatibilities(EditorTestHelper):
# Verify the gradient generator component is disabled since the vegetation area is incompatible # Verify the gradient generator component is disabled since the vegetation area is incompatible
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component) active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
self.test_success = self.test_success and not active component_is_disabled = (
if not active: f"{component_name} is disabled before removing {vegetation_area_name} component",
self.log(f"{component_name} is disabled before removing {vegetation_area_name} component") f"{component_name} is unexpectedly enabled before removing {vegetation_area_name} component"
)
Report.result(component_is_disabled, not active)
# Remove the vegetation area component # Remove the vegetation area component
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [area_component]) editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [area_component])
@ -118,10 +108,14 @@ class TestGradientGeneratorIncompatibilities(EditorTestHelper):
# Verify the gradient generator component is enabled now that the vegetation area is gone # Verify the gradient generator component is enabled now that the vegetation area is gone
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component) active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
self.test_success = self.test_success and active component_is_enabled = (
if active: f"{component_name} is enabled after removing {vegetation_area_name} component",
self.log(f"{component_name} is enabled after removing {vegetation_area_name} component") f"{component_name} is unexpectedly disabled after removing {vegetation_area_name} component"
)
Report.result(component_is_enabled, active)
if __name__ == "__main__":
test = TestGradientGeneratorIncompatibilities() from editor_python_test_tools.utils import Report
test.run() Report.start_test(GradientGenerators_Incompatibilities)

@ -4,24 +4,9 @@ For complete copyright and license terms please see the LICENSE at the root of t
SPDX-License-Identifier: Apache-2.0 OR MIT SPDX-License-Identifier: Apache-2.0 OR MIT
""" """
import os
import sys
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.entity as entity
import azlmbr.paths
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) def GradientModifiers_Incompatibilities():
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.editor_test_helper import EditorTestHelper
class TestGradientModifiersIncompatibilities(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="GradientModifiersIncompatibilities", args=["level"])
def run_test(self):
""" """
Summary: Summary:
This test verifies that components are disabled when conflicting components are present on the same entity. This test verifies that components are disabled when conflicting components are present on the same entity.
@ -30,7 +15,7 @@ class TestGradientModifiersIncompatibilities(EditorTestHelper):
Gradient Modifier components are incompatible with Vegetation area components. Gradient Modifier components are incompatible with Vegetation area components.
Test Steps: Test Steps:
1) Create a new level 1) Open a simple level
2) Create a new entity in the level 2) Create a new entity in the level
3) Add each Gradient Modifier component to an entity, and add a Vegetation Area component to the same entity 3) Add each Gradient Modifier component to an entity, and add a Vegetation Area component to the same entity
4) Verify that components are only enabled when entity is free of a conflicting component 4) Verify that components are only enabled when entity is free of a conflicting component
@ -43,6 +28,14 @@ class TestGradientModifiersIncompatibilities(EditorTestHelper):
:return: None :return: None
""" """
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.entity as entity
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
gradient_generators = [ gradient_generators = [
'Altitude Gradient', 'Altitude Gradient',
'Constant Gradient', 'Constant Gradient',
@ -80,14 +73,9 @@ class TestGradientModifiersIncompatibilities(EditorTestHelper):
'Vegetation Layer Blocker (Mesh)': 'Mesh' 'Vegetation Layer Blocker (Mesh)': 'Mesh'
} }
# Create a new empty level # Open an existing simple level
self.test_success = self.create_level( helper.init_idle()
self.args["level"], helper.open_level("Physics", "Base")
heightmap_resolution=1024,
heightmap_meters_per_pixel=1,
terrain_texture_resolution=4096,
use_terrain=False,
)
# For every gradient modifier component, verify that they are incompatible # For every gradient modifier component, verify that they are incompatible
# which each vegetation area and gradient generator/modifier component # which each vegetation area and gradient generator/modifier component
@ -113,18 +101,22 @@ class TestGradientModifiersIncompatibilities(EditorTestHelper):
# Verify the gradient modifier component is disabled since the vegetation area is incompatible # Verify the gradient modifier component is disabled since the vegetation area is incompatible
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component) active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
self.test_success = self.test_success and not active component_is_disabled = (
if not active: f"{component_name} is disabled before removing {vegetation_area_name} component",
self.log("{gradient} is disabled before removing {vegetation_area} component".format(gradient=component_name, vegetation_area=vegetation_area_name)) f"{component_name} is unexpectedly enabled before removing {vegetation_area_name} component"
)
Report.result(component_is_disabled, not active)
# Remove the vegetation area component # Remove the vegetation area component
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [area_component]) editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [area_component])
# Verify the gradient modifier component is enabled now that the vegetation area is gone # Verify the gradient modifier component is enabled now that the vegetation area is gone
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component) active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
self.test_success = self.test_success and active component_is_enabled = (
if active: f"{component_name} is enabled after removing {vegetation_area_name} component",
self.log("{gradient} is enabled after removing {vegetation_area} component".format(gradient=component_name, vegetation_area=vegetation_area_name)) f"{component_name} is unexpectedly disabled after removing {vegetation_area_name} component"
)
Report.result(component_is_enabled, active)
for gradient_name in all_gradients: for gradient_name in all_gradients:
# Create a new Entity in the level # Create a new Entity in the level
@ -149,19 +141,25 @@ class TestGradientModifiersIncompatibilities(EditorTestHelper):
# Verify the gradient modifier component is disabled since the other gradient is incompatible # Verify the gradient modifier component is disabled since the other gradient is incompatible
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component) active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
self.test_success = self.test_success and not active component_is_disabled = (
if not active: f"{component_name} is disabled before removing {gradient_name} component",
self.log("{gradient} is disabled before removing {conflicting_gradient} component".format(gradient=component_name, conflicting_gradient=gradient_name)) f"{component_name} is unexpectedly enabled before removing {gradient_name} component"
)
Report.result(component_is_disabled, not active)
# Remove the conflicting gradient component (and transform modifier if it was added) # Remove the conflicting gradient component (and transform modifier if it was added)
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', conflicting_components) editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', conflicting_components)
# Verify the gradient modifier component is enabled now that the other gradient is gone # Verify the gradient modifier component is enabled now that the other gradient is gone
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component) active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
self.test_success = self.test_success and active component_is_enabled = (
if active: f"{component_name} is enabled after removing {gradient_name} component",
self.log("{gradient} is enabled after removing {conflicting_gradient} component".format(gradient=component_name, conflicting_gradient=gradient_name)) f"{component_name} is unexpectedly disabled after removing {gradient_name} component"
)
Report.result(component_is_enabled, active)
if __name__ == "__main__":
test = TestGradientModifiersIncompatibilities() from editor_python_test_tools.utils import Report
test.run() Report.start_test(GradientModifiers_Incompatibilities)

@ -5,26 +5,8 @@ For complete copyright and license terms please see the LICENSE at the root of t
SPDX-License-Identifier: Apache-2.0 OR MIT SPDX-License-Identifier: Apache-2.0 OR MIT
""" """
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__))) def GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin():
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.math as math
import azlmbr.paths
import azlmbr.entity as EntityId
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.editor_test_helper import EditorTestHelper
class TestGradientPreviewSettings(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="GradientPreviewSettings_ClearPinnedEntity", args=["level"])
def run_test(self):
""" """
Summary: Summary:
A temporary level is created. An entity for each test case is created and added with the corresponding A temporary level is created. An entity for each test case is created and added with the corresponding
@ -55,18 +37,29 @@ class TestGradientPreviewSettings(EditorTestHelper):
:return: None :return: None
""" """
import sys
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.math as math
import azlmbr.entity as EntityId
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
WORLD_ORIGIN = math.Vector3(0.0, 0.0, 0.0) WORLD_ORIGIN = math.Vector3(0.0, 0.0, 0.0)
EXPECTED_SIZE = math.Vector3(1.0, 1.0, 1.0) EXPECTED_SIZE = math.Vector3(1.0, 1.0, 1.0)
CLOSE_THRESHOLD = sys.float_info.min CLOSE_THRESHOLD = sys.float_info.min
def create_entity(enity_name, components_to_add): def create_entity(entity_name, components_to_add):
entity_position = math.Vector3(125.0, 136.0, 32.0) entity_position = math.Vector3(125.0, 136.0, 32.0)
entity_id = editor.ToolsApplicationRequestBus( entity_id = editor.ToolsApplicationRequestBus(
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId() bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
) )
entity = hydra.Entity(enity_name, entity_id) entity = hydra.Entity(entity_name, entity_id)
if entity_id.IsValid(): if entity_id.IsValid():
print(f"{enity_name} entity Created") print(f"{entity_name} entity Created")
entity.components = [] entity.components = []
for component in components_to_add: for component in components_to_add:
entity.components.append(hydra.add_component(component, entity_id)) entity.components.append(hydra.add_component(component, entity_id))
@ -78,22 +71,23 @@ class TestGradientPreviewSettings(EditorTestHelper):
preview_position = hydra.get_component_property_value( preview_position = hydra.get_component_property_value(
entity.components[0], "Preview Settings|Preview Position" entity.components[0], "Preview Settings|Preview Position"
) )
if preview_position.IsClose(WORLD_ORIGIN, CLOSE_THRESHOLD): preview_set_to_origin = (
print(f"{entity_name} --- Preview Position set to world origin") f"{entity_name}: Preview Position set to world origin",
f"{entity_name}: Preview Position set to unexpected coords"
)
Report.result(preview_set_to_origin, preview_position.IsClose(WORLD_ORIGIN, CLOSE_THRESHOLD))
if check_preview_size: if check_preview_size:
preview_size = hydra.get_component_property_value(entity.components[0], "Preview Settings|Preview Size") preview_size = hydra.get_component_property_value(entity.components[0], "Preview Settings|Preview Size")
if preview_size.IsClose(EXPECTED_SIZE, CLOSE_THRESHOLD): preview_size_default_set = (
print(f"{entity_name} --- Preview Size set to (1, 1, 1)") f"{entity_name}: Preview Size set as expected",
f"{entity_name}: Preview Size set to unexpected value. Expected {EXPECTED_SIZE}, Found {preview_size}"
)
Report.result(preview_size_default_set, preview_size.IsClose(EXPECTED_SIZE, CLOSE_THRESHOLD))
return entity return entity
# 1) Open level # 1) Open an existing simple level
self.test_success = self.create_level( helper.init_idle()
self.args["level"], helper.open_level("Physics", "Base")
heightmap_resolution=1024,
heightmap_meters_per_pixel=1,
terrain_texture_resolution=4096,
use_terrain=False,
)
# 2) Create entity with Random Noise gradient and verify gradient position after clearing pinned entity # 2) Create entity with Random Noise gradient and verify gradient position after clearing pinned entity
clear_entityid_check_position( clear_entityid_check_position(
@ -129,5 +123,7 @@ class TestGradientPreviewSettings(EditorTestHelper):
) )
test = TestGradientPreviewSettings() if __name__ == "__main__":
test.run()
from editor_python_test_tools.utils import Report
Report.start_test(GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin)

@ -5,18 +5,6 @@ For complete copyright and license terms please see the LICENSE at the root of t
SPDX-License-Identifier: Apache-2.0 OR MIT SPDX-License-Identifier: Apache-2.0 OR MIT
""" """
import os
import sys
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.entity as entity
import azlmbr.paths
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.editor_test_helper import EditorTestHelper
class Scoped: class Scoped:
def __init__(self, constructor, destructor, *args): def __init__(self, constructor, destructor, *args):
@ -33,11 +21,7 @@ class TestParams:
self.accessed_component = accessed_component self.accessed_component = accessed_component
class TestGradientPreviewSettings(EditorTestHelper): def GradientPreviewSettings_DefaultPinnedEntityIsSelf():
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="GradientPreviewSettings_DefaultPinnedEntity", args=["level"])
def run_test(self):
""" """
Summary: Summary:
This test verifies default values for the pinned entity for Gradient Preview settings. This test verifies default values for the pinned entity for Gradient Preview settings.
@ -46,7 +30,7 @@ class TestGradientPreviewSettings(EditorTestHelper):
Pinned entity is self for all gradient generator/modifiers. Pinned entity is self for all gradient generator/modifiers.
Test Steps: Test Steps:
1) Create a new level 1) Open a simple level
2) Create a new entity in the level 2) Create a new entity in the level
3) Add each Gradient Generator component to an entity, and verify the Pin Preview to Shape property is set to 3) Add each Gradient Generator component to an entity, and verify the Pin Preview to Shape property is set to
self self
@ -59,9 +43,20 @@ class TestGradientPreviewSettings(EditorTestHelper):
:return: None :return: None
""" """
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.entity as entity
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
def execute_test(test_id, function, *args): def execute_test(test_id, function, *args):
if function(*args): pinned_to_self = (
self.log(test_id + ' has Preview pinned to own Entity result: SUCCESS') f"{test_id} has Preview pinned to self",
f"{test_id} has Preview pinned to a different entity"
)
Report.result(pinned_to_self, function(*args))
def create_entity(): def create_entity():
return editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId()) return editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
@ -80,7 +75,6 @@ class TestGradientPreviewSettings(EditorTestHelper):
added_components = attach_components(param.required_components, entity_ptr.data) added_components = attach_components(param.required_components, entity_ptr.data)
value = hydra.get_component_property_value(added_components[param.accessed_component], value = hydra.get_component_property_value(added_components[param.accessed_component],
'Preview Settings|Pin Preview to Shape') 'Preview Settings|Pin Preview to Shape')
self.test_success = self.test_success and entity_ptr.data.Equal(value)
return entity_ptr.data.Equal(value) return entity_ptr.data.Equal(value)
param_list = [ param_list = [
@ -95,19 +89,16 @@ class TestGradientPreviewSettings(EditorTestHelper):
TestParams(['Threshold Gradient Modifier'], 0) TestParams(['Threshold Gradient Modifier'], 0)
] ]
# Create a new empty level # 1) Open an existing simple level
self.test_success = self.create_level( helper.init_idle()
self.args["level"], helper.open_level("Physics", "Base")
heightmap_resolution=1024,
heightmap_meters_per_pixel=1,
terrain_texture_resolution=4096,
use_terrain=False,
)
for param in param_list: for param in param_list:
execute_test(param.required_components[param.accessed_component], execute_test(param.required_components[param.accessed_component],
validate_id_is_current, param) validate_id_is_current, param)
test = TestGradientPreviewSettings() if __name__ == "__main__":
test.run()
from editor_python_test_tools.utils import Report
Report.start_test(GradientPreviewSettings_DefaultPinnedEntityIsSelf)

@ -5,24 +5,8 @@ For complete copyright and license terms please see the LICENSE at the root of t
SPDX-License-Identifier: Apache-2.0 OR MIT SPDX-License-Identifier: Apache-2.0 OR MIT
""" """
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__))) def GradientSampling_GradientReferencesAddRemoveSuccessfully():
import azlmbr.math as math
import azlmbr.paths
import azlmbr.entity as EntityId
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.editor_test_helper import EditorTestHelper
class TestGradientSampling(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="GradientSampling_GradientReferences", args=["level"])
def run_test(self):
""" """
Summary: Summary:
An existing gradient generator can be pinned and cleared to/from the Gradient Entity Id field An existing gradient generator can be pinned and cleared to/from the Gradient Entity Id field
@ -45,6 +29,13 @@ class TestGradientSampling(EditorTestHelper):
:return: None :return: None
""" """
import azlmbr.math as math
import azlmbr.entity as EntityId
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
def modifier_pin_clear_to_gradiententityid(modifier): def modifier_pin_clear_to_gradiententityid(modifier):
entity_position = math.Vector3(125.0, 136.0, 32.0) entity_position = math.Vector3(125.0, 136.0, 32.0)
component_to_add = [modifier] component_to_add = [modifier]
@ -54,27 +45,24 @@ class TestGradientSampling(EditorTestHelper):
entity = hydra.get_component_property_value( entity = hydra.get_component_property_value(
gradient_modifier.components[0], "Configuration|Gradient|Gradient Entity Id" gradient_modifier.components[0], "Configuration|Gradient|Gradient Entity Id"
) )
if entity.Equal(random_noise.id): gradient_pinned_to_modifier = (
print(f"Gradient Generator is pinned to the {modifier} successfully") f"Gradient Generator is pinned to the {modifier} successfully",
else: f"Failed to pin Gradient Generator to the {modifier}"
print(f"Failed to pin Gradient Generator to the {modifier}") )
Report.result(gradient_pinned_to_modifier, entity.Equal(random_noise.id))
hydra.get_set_test(gradient_modifier, 0, "Configuration|Gradient|Gradient Entity Id", EntityId.EntityId()) hydra.get_set_test(gradient_modifier, 0, "Configuration|Gradient|Gradient Entity Id", EntityId.EntityId())
entity = hydra.get_component_property_value( entity = hydra.get_component_property_value(
gradient_modifier.components[0], "Configuration|Gradient|Gradient Entity Id" gradient_modifier.components[0], "Configuration|Gradient|Gradient Entity Id"
) )
if entity.Equal(EntityId.EntityId()): gradient_cleared_from_modifier = (
print(f"Gradient Generator is cleared from the {modifier} successfully") f"Gradient Generator is cleared from the {modifier} successfully",
else: f"Failed to clear Gradient Generator from the {modifier}"
print(f"Failed to clear Gradient Generator from the {modifier}")
# 1) Open level
self.test_success = self.create_level(
self.args["level"],
heightmap_resolution=1024,
heightmap_meters_per_pixel=1,
terrain_texture_resolution=4096,
use_terrain=False,
) )
Report.result(gradient_cleared_from_modifier, entity.Equal(EntityId.EntityId()))
# 1) Open an existing simple level
helper.init_idle()
helper.open_level("Physics", "Base")
# 2) Create a new entity with components "Random Noise Gradient", "Gradient Transform Modifier" and "Box Shape" # 2) Create a new entity with components "Random Noise Gradient", "Gradient Transform Modifier" and "Box Shape"
entity_position = math.Vector3(125.0, 136.0, 32.0) entity_position = math.Vector3(125.0, 136.0, 32.0)
@ -92,5 +80,7 @@ class TestGradientSampling(EditorTestHelper):
modifier_pin_clear_to_gradiententityid("Threshold Gradient Modifier") modifier_pin_clear_to_gradiententityid("Threshold Gradient Modifier")
test = TestGradientSampling() if __name__ == "__main__":
test.run()
from editor_python_test_tools.utils import Report
Report.start_test(GradientSampling_GradientReferencesAddRemoveSuccessfully)

@ -5,26 +5,9 @@ For complete copyright and license terms please see the LICENSE at the root of t
SPDX-License-Identifier: Apache-2.0 OR MIT SPDX-License-Identifier: Apache-2.0 OR MIT
""" """
import os
import sys
import azlmbr.math as math
import azlmbr.bus as bus
import azlmbr.entity as entity
import azlmbr.paths
import azlmbr.editor as editor
sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests"))
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.editor_test_helper import EditorTestHelper
class TestGradientSurfaceTagEmitterDependencies(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(
self, log_prefix="GradientSurfaceTagEmitter_ComponentDependencies", args=["level"]
)
def run_test(self):
def GradientSurfaceTagEmitter_ComponentDependencies():
""" """
Summary: Summary:
This test verifies that the Gradient Surface Tag Emitter component is dependent on a gradient component. This test verifies that the Gradient Surface Tag Emitter component is dependent on a gradient component.
@ -46,17 +29,21 @@ class TestGradientSurfaceTagEmitterDependencies(EditorTestHelper):
:return: None :return: None
""" """
import azlmbr.math as math
import azlmbr.bus as bus
import azlmbr.entity as entity
import azlmbr.editor as editor
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
def is_enabled(EntityComponentIdPair): def is_enabled(EntityComponentIdPair):
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair) return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair)
# Create empty level # Open an existing simple level
self.test_success = self.create_level( helper.init_idle()
self.args["level"], helper.open_level("Physics", "Base")
heightmap_resolution=1024,
heightmap_meters_per_pixel=1,
terrain_texture_resolution=4096,
use_terrain=False,
)
# Create an entity with Gradient Surface Tag Emitter component # Create an entity with Gradient Surface Tag Emitter component
position = math.Vector3(512.0, 512.0, 32.0) position = math.Vector3(512.0, 512.0, 32.0)
@ -64,11 +51,11 @@ class TestGradientSurfaceTagEmitterDependencies(EditorTestHelper):
gradient.create_entity(position, ["Gradient Surface Tag Emitter"]) gradient.create_entity(position, ["Gradient Surface Tag Emitter"])
# Make sure Gradient Surface Tag Emitter is disabled # Make sure Gradient Surface Tag Emitter is disabled
is_enable = is_enabled(gradient.components[0]) gradient_surface_tag_disabled = (
if not is_enable: "Gradient Surface Tag Emitter is Disabled",
self.log("Gradient Surface Tag Emitter is Disabled") "Gradient Surface Tag Emitter is Enabled, but should be Disabled without dependencies met"
elif not is_enable: )
self.log("Gradient Surface Tag Emitter is Enabled, but should be Disabled without dependencies met") Report.result(gradient_surface_tag_disabled, not is_enabled(gradient.components[0]))
# Verify Gradient Surface Tag Emitter component is enabled after adding Gradient, Generator, Modifier # Verify Gradient Surface Tag Emitter component is enabled after adding Gradient, Generator, Modifier
# or Reference component # or Reference component
@ -101,18 +88,21 @@ class TestGradientSurfaceTagEmitterDependencies(EditorTestHelper):
ComponentOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'AddComponentsOfType', gradient.id, [typeIdsList[0]]) ComponentOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'AddComponentsOfType', gradient.id, [typeIdsList[0]])
Components = ComponentOutcome.GetValue() Components = ComponentOutcome.GetValue()
ComponentIdPair = Components[0] ComponentIdPair = Components[0]
gradient_enabled = new_components_enabled = False
gradient_enabled = is_enabled(gradient.components[0]) gradient_enabled = is_enabled(gradient.components[0])
new_components_enabled = is_enabled(ComponentIdPair) new_components_enabled = is_enabled(ComponentIdPair)
if new_components_enabled and gradient_enabled: dependencies_met = (
self.log(f"{component} and Gradient Surface Tag Emitter are enabled") f"{component} and Gradient Surface Tag Emitter are enabled",
else: f"{component} and Gradient Surface Tag Emitter are disabled"
self.log(f"{component} and Gradient Surface Tag Emitter are disabled") )
Report.result(dependencies_met, new_components_enabled and gradient_enabled)
if component in component_list: if component in component_list:
hydra.remove_component("Gradient Transform Modifier", gradient.id) hydra.remove_component("Gradient Transform Modifier", gradient.id)
hydra.remove_component("Box Shape", gradient.id) hydra.remove_component("Box Shape", gradient.id)
hydra.remove_component(component, gradient.id) hydra.remove_component(component, gradient.id)
test = TestGradientSurfaceTagEmitterDependencies() if __name__ == "__main__":
test.run()
from editor_python_test_tools.utils import Report
Report.start_test(GradientSurfaceTagEmitter_ComponentDependencies)

@ -5,25 +5,8 @@ For complete copyright and license terms please see the LICENSE at the root of t
SPDX-License-Identifier: Apache-2.0 OR MIT SPDX-License-Identifier: Apache-2.0 OR MIT
""" """
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__))) def GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully():
import azlmbr.math as math
import azlmbr.paths
import azlmbr.surface_data as surface_data
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.editor_test_helper import EditorTestHelper
class TestGradientSurfaceTagEmitter(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSucessfully",
args=["level"])
def run_test(self):
""" """
Summary: Summary:
Entity with Gradient Surface Tag Emitter and Reference Gradient components is created. Entity with Gradient Surface Tag Emitter and Reference Gradient components is created.
@ -45,14 +28,16 @@ class TestGradientSurfaceTagEmitter(EditorTestHelper):
:return: None :return: None
""" """
# 1) Open level import azlmbr.math as math
self.test_success = self.create_level( import azlmbr.surface_data as surface_data
self.args["level"],
heightmap_resolution=1024, import editor_python_test_tools.hydra_editor_utils as hydra
heightmap_meters_per_pixel=1, from editor_python_test_tools.utils import Report
terrain_texture_resolution=4096, from editor_python_test_tools.utils import TestHelper as helper
use_terrain=False,
) # 1) Open an existing simple level
helper.init_idle()
helper.open_level("Physics", "Base")
# 2) Create an entity with Gradient Surface Tag Emitter and Reference Gradient components. # 2) Create an entity with Gradient Surface Tag Emitter and Reference Gradient components.
entity_position = math.Vector3(125.0, 136.0, 32.0) entity_position = math.Vector3(125.0, 136.0, 32.0)
@ -66,14 +51,23 @@ class TestGradientSurfaceTagEmitter(EditorTestHelper):
pte = hydra.get_property_tree(entity.components[0]) pte = hydra.get_property_tree(entity.components[0])
path = "Configuration|Extended Tags" path = "Configuration|Extended Tags"
pte.add_container_item(path, 0, tag) pte.add_container_item(path, 0, tag)
success = self.wait_for_condition(lambda: pte.get_container_count(path).GetValue() == 1) success = helper.wait_for_condition(lambda: pte.get_container_count(path).GetValue() == 1, 1.0)
self.test_success = self.test_success and success tag_added_to_container = (
print(f"Added SurfaceTag: container count is {pte.get_container_count(path).GetValue()}") "Successfully added surface tag",
"Failed to add surface tag"
)
Report.result(tag_added_to_container, success)
pte.remove_container_item(path, 0) pte.remove_container_item(path, 0)
success = self.wait_for_condition(lambda: pte.get_container_count(path).GetValue() == 0) success = helper.wait_for_condition(lambda: pte.get_container_count(path).GetValue() == 0, 1.0)
self.test_success = self.test_success and success tag_removed_from_container = (
print(f"Removed SurfaceTag: container count is {pte.get_container_count(path).GetValue()}") "Successfully removed surface tag",
"Failed to remove surface tag"
)
Report.result(tag_removed_from_container, success)
if __name__ == "__main__":
from editor_python_test_tools.utils import Report
Report.start_test(GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully)
test = TestGradientSurfaceTagEmitter()
test.run()

@ -5,26 +5,8 @@ For complete copyright and license terms please see the LICENSE at the root of t
SPDX-License-Identifier: Apache-2.0 OR MIT SPDX-License-Identifier: Apache-2.0 OR MIT
""" """
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__))) def GradientTransform_ComponentIncompatibleWithExpectedGradients():
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.math as math
import azlmbr.entity as EntityId
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.editor_test_helper import EditorTestHelper
class TestGradientTransform_ComponentIncompatibleWithExpectedGradients(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="GradientTransform_ComponentIncompatibleWithExpectedGradients",
args=["level"])
def run_test(self):
""" """
Summary: Summary:
A New level is created. A New entity is created with components Gradient Transform Modifier and Box Shape. A New level is created. A New entity is created with components Gradient Transform Modifier and Box Shape.
@ -51,17 +33,21 @@ class TestGradientTransform_ComponentIncompatibleWithExpectedGradients(EditorTes
:return: None :return: None
""" """
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.math as math
import azlmbr.entity as EntityId
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
def is_enabled(EntityComponentIdPair): def is_enabled(EntityComponentIdPair):
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair) return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair)
# 1) Create level # 1) Open an existing simple level
self.test_success = self.create_level( helper.init_idle()
self.args["level"], helper.open_level("Physics", "Base")
heightmap_resolution=1024,
heightmap_meters_per_pixel=1,
terrain_texture_resolution=4096,
use_terrain=False,
)
# 2) Create a new entity with components Gradient Transform Modifier and Box Shape # 2) Create a new entity with components Gradient Transform Modifier and Box Shape
entity_position = math.Vector3(125.0, 136.0, 32.0) entity_position = math.Vector3(125.0, 136.0, 32.0)
@ -75,20 +61,20 @@ class TestGradientTransform_ComponentIncompatibleWithExpectedGradients(EditorTes
for component in components_to_add: for component in components_to_add:
gradient.components.append(hydra.add_component(component, gradient_id)) gradient.components.append(hydra.add_component(component, gradient_id))
if gradient_id.isValid(): entity_created = (
self.log("New Entity Created") "Entity created successfully",
"Failed to create entity"
)
Report.critical_result(entity_created, gradient_id.isValid())
# 3) Make sure all components are enabled in Entity # 3) Make sure all components are enabled in Entity
index = 0 index = 0
for component in components_to_add: for component in components_to_add:
is_enable = is_enabled(gradient.components[index]) components_enabled = (
if is_enable: f"{component} is enabled",
self.log(f"{component} is Enabled") f"{component} is unexpectedly disabled"
self.test_success = self.test_success and is_enable )
elif not is_enable: Report.critical_result(components_enabled, is_enabled(gradient.components[index]))
self.log(f"{component} is disabled, but it should be enabled")
self.test_success = self.test_success and is_enable
break
index += 1 index += 1
# 4) Add Constant Gradient, Altitude Gradient, Gradient Mixer, Reference Gradient, Shape # 4) Add Constant Gradient, Altitude Gradient, Gradient Mixer, Reference Gradient, Shape
@ -102,21 +88,19 @@ class TestGradientTransform_ComponentIncompatibleWithExpectedGradients(EditorTes
"Slope Gradient", "Slope Gradient",
"Surface Mask Gradient", "Surface Mask Gradient",
] ]
index = 2
new_components_enabled = False new_components_enabled = False
for component in new_components_to_add: for component in new_components_to_add:
gradient.components.append(hydra.add_component(component, gradient_id)) gradient.components.append(hydra.add_component(component, gradient_id))
new_components_enabled = is_enabled(gradient.components[index]) gradient_components_disabled = (
if new_components_enabled: f"{component} is disabled",
self.log(f"{component} is enabled, but should be disabled") f"{component} is enabled, but should be disabled"
break )
Report.result(gradient_components_disabled, not is_enabled(gradient.components[2]))
if not is_enabled(gradient.components[2]):
editor.EditorComponentAPIBus(bus.Broadcast, "RemoveComponents", component) editor.EditorComponentAPIBus(bus.Broadcast, "RemoveComponents", component)
# 5) Make sure all newly added components are disabled
if not new_components_enabled:
self.log("All newly added components are incompatible and disabled")
self.test_success = self.test_success and not new_components_enabled
if __name__ == "__main__":
test = TestGradientTransform_ComponentIncompatibleWithExpectedGradients() from editor_python_test_tools.utils import Report
test.run() Report.start_test(GradientTransform_ComponentIncompatibleWithExpectedGradients)

@ -5,29 +5,11 @@ For complete copyright and license terms please see the LICENSE at the root of t
SPDX-License-Identifier: Apache-2.0 OR MIT SPDX-License-Identifier: Apache-2.0 OR MIT
""" """
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__))) def GradientTransform_ComponentIncompatibleWithSpawners():
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.math as math
import azlmbr.entity as EntityId
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.editor_test_helper import EditorTestHelper
class TestGradientTransform_ComponentIncompatibleWithSpawners(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="GradientTransform_ComponentIncompatibleWithSpawners",
args=["level"])
def run_test(self):
""" """
Summary: Summary:
A New level is created. A New entity is created with components Gradient Transform Modifier and Box Shape. A simple level is opened. A New entity is created with components Gradient Transform Modifier and Box Shape.
Adding a component Vegetation Layer Spawner to the same entity. Adding a component Vegetation Layer Spawner to the same entity.
Expected Behavior: Expected Behavior:
@ -35,7 +17,7 @@ class TestGradientTransform_ComponentIncompatibleWithSpawners(EditorTestHelper):
Transform Modifier Transform Modifier
Test Steps: Test Steps:
1) Create level 1) Open a simple level
2) Create a new entity with components Gradient Transform Modifier and Box Shape 2) Create a new entity with components Gradient Transform Modifier and Box Shape
3) Make sure all components are enabled in Entity 3) Make sure all components are enabled in Entity
4) Add Vegetation Layer Spawner to the same entity 4) Add Vegetation Layer Spawner to the same entity
@ -49,17 +31,21 @@ class TestGradientTransform_ComponentIncompatibleWithSpawners(EditorTestHelper):
:return: None :return: None
""" """
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.math as math
import azlmbr.entity as EntityId
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
def is_enabled(EntityComponentIdPair): def is_enabled(EntityComponentIdPair):
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair) return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair)
# 1) Create level # 1) Open an existing simple level
self.test_success = self.create_level( helper.init_idle()
self.args["level"], helper.open_level("Physics", "Base")
heightmap_resolution=1024,
heightmap_meters_per_pixel=1,
terrain_texture_resolution=4096,
use_terrain=False,
)
# 2) Create a new entity with components Gradient Transform Modifier and Box Shape # 2) Create a new entity with components Gradient Transform Modifier and Box Shape
entity_position = math.Vector3(125.0, 136.0, 32.0) entity_position = math.Vector3(125.0, 136.0, 32.0)
@ -73,36 +59,34 @@ class TestGradientTransform_ComponentIncompatibleWithSpawners(EditorTestHelper):
for component in components_to_add: for component in components_to_add:
gradient.components.append(hydra.add_component(component, gradient_id)) gradient.components.append(hydra.add_component(component, gradient_id))
if gradient_id.isValid(): entity_created = (
self.log("New Entity Created") "Entity created successfully",
"Failed to create entity"
)
Report.critical_result(entity_created, gradient_id.isValid())
# 3) Make sure all components are enabled in Entity # 3) Make sure all components are enabled in Entity
index = 0 index = 0
for component in components_to_add: for component in components_to_add:
is_enable = is_enabled(gradient.components[index]) components_enabled = (
if is_enable: f"{component} is enabled",
self.log(f"{component} is Enabled") f"{component} is unexpectedly disabled"
self.test_success = self.test_success and is_enable )
elif not is_enable: Report.critical_result(components_enabled, is_enabled(gradient.components[index]))
self.log(f"{component} is Disabled. But It should be Enabled in an Entity")
self.test_success = self.test_success and is_enable
break
index += 1 index += 1
# 4) Add Vegetation Layer Spawner to the same entity # 4) Add Vegetation Layer Spawner to the same entity
new_component_to_add = "Vegetation Layer Spawner" gradient.components.append(hydra.add_component("Vegetation Layer Spawner", gradient_id))
index = 2
gradient.components.append(hydra.add_component(new_component_to_add, gradient_id))
new_component_enabled = is_enabled(gradient.components[index])
# 5) Make sure newly added component is disabled # 5) Make sure newly added component is disabled
if not new_component_enabled: spawner_component_disabled = (
self.log(f"{new_component_to_add} is incompatible and disabled") "Spawner component is disabled",
self.test_success = self.test_success and not new_component_enabled "Spawner component is unexpectedly enabled"
elif new_component_enabled: )
self.log(f"{new_component_to_add} is compatible and enabled. But It should be Incompatible and disabled") Report.result(spawner_component_disabled, not is_enabled(gradient.components[2]))
self.test_success = self.test_success and new_component_enabled
if __name__ == "__main__":
test = TestGradientTransform_ComponentIncompatibleWithSpawners() from editor_python_test_tools.utils import Report
test.run() Report.start_test(GradientTransform_ComponentIncompatibleWithSpawners)

@ -5,30 +5,23 @@ For complete copyright and license terms please see the LICENSE at the root of t
SPDX-License-Identifier: Apache-2.0 OR MIT SPDX-License-Identifier: Apache-2.0 OR MIT
""" """
"""
C3430292: Frequency Zoom can manually be set higher than 8.
"""
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.math as math
import azlmbr.paths
import azlmbr.entity as EntityId
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.editor_test_helper import EditorTestHelper
class Tests:
entity_created = (
"Entity created successfully",
"Failed to create entity"
)
components_added = (
"All expected components added to entity",
"Failed to add expected components to entity"
)
higher_zoom_value_set = (
"Frequency Zoom is equal to expected value",
"Frequency Zoom is not equal to expected value"
)
class TestGradientTransformFrequencyZoom(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="GradientTransform_FrequencyZoomBeyondSliders", args=["level"])
def run_test(self): def GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange():
""" """
Summary: Summary:
Frequency Zoom can manually be set higher than 8 in a random noise gradient Frequency Zoom can manually be set higher than 8 in a random noise gradient
@ -51,22 +44,25 @@ class TestGradientTransformFrequencyZoom(EditorTestHelper):
:return: None :return: None
""" """
# 1) Open level import azlmbr.bus as bus
self.test_success = self.create_level( import azlmbr.editor as editor
self.args["level"], import azlmbr.math as math
heightmap_resolution=1024, import azlmbr.entity as EntityId
heightmap_meters_per_pixel=1,
terrain_texture_resolution=4096, import editor_python_test_tools.hydra_editor_utils as hydra
use_terrain=False, from editor_python_test_tools.utils import Report
) from editor_python_test_tools.utils import TestHelper as helper
# 1) Open an existing simple level
helper.init_idle()
helper.open_level("Physics", "Base")
# 2) Create entity # 2) Create entity
entity_position = math.Vector3(125.0, 136.0, 32.0) entity_position = math.Vector3(125.0, 136.0, 32.0)
entity_id = editor.ToolsApplicationRequestBus( entity_id = editor.ToolsApplicationRequestBus(
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId() bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
) )
if entity_id.IsValid(): Report.critical_result(Tests.entity_created, entity_id.IsValid())
print("Entity Created")
# 3) Add components to the entity # 3) Add components to the entity
components_to_add = ["Random Noise Gradient", "Gradient Transform Modifier", "Box Shape"] components_to_add = ["Random Noise Gradient", "Gradient Transform Modifier", "Box Shape"]
@ -74,18 +70,17 @@ class TestGradientTransformFrequencyZoom(EditorTestHelper):
entity.components = [] entity.components = []
for component in components_to_add: for component in components_to_add:
entity.components.append(hydra.add_component(component, entity_id)) entity.components.append(hydra.add_component(component, entity_id))
print("Components added to the entity") Report.critical_result(Tests.components_added, len(entity.components) == 3)
# 4) Set the frequency value of the component # 4) Set the frequency value of the component
hydra.get_set_test(entity, 1, "Configuration|Frequency Zoom", 10) hydra.get_set_test(entity, 1, "Configuration|Frequency Zoom", 10)
# 5) Verify if the frequency value is set to higher value # 5) Verify if the frequency value is set to higher value
curr_value = hydra.get_component_property_value(entity.components[1], "Configuration|Frequency Zoom") curr_value = hydra.get_component_property_value(entity.components[1], "Configuration|Frequency Zoom")
if curr_value == 10.0: Report.result(Tests.higher_zoom_value_set, curr_value == 10.0)
print("Frequency Zoom is equal to expected value")
else:
print("Frequency Zoom is not equal to expected value")
if __name__ == "__main__":
test = TestGradientTransformFrequencyZoom() from editor_python_test_tools.utils import Report
test.run() Report.start_test(GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange)

@ -4,24 +4,20 @@ For complete copyright and license terms please see the LICENSE at the root of t
SPDX-License-Identifier: Apache-2.0 OR MIT SPDX-License-Identifier: Apache-2.0 OR MIT
""" """
import os
import sys
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.entity as entity
import azlmbr.paths
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.editor_test_helper import EditorTestHelper
class Tests:
disabled_without_shape = (
"Gradient Transform Modifier component is disabled without a Shape component on the Entity",
"Gradient Transform Modifier component is unexpectedly enabled without a Shape component on the Entity",
)
enabled_with_shape = (
"Gradient Transform Modifier component is enabled now that the Entity has a Shape",
"Gradient Transform Modifier component is still disabled alongside a Shape component",
)
class TestGradientTransformRequiresShape(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="GradientTransformRequiresShape", args=["level"])
def run_test(self): def GradientTransform_RequiresShape():
""" """
Summary: Summary:
This test verifies that the Gradient Transform Modifier component is dependent on a shape component. This test verifies that the Gradient Transform Modifier component is dependent on a shape component.
@ -41,14 +37,18 @@ class TestGradientTransformRequiresShape(EditorTestHelper):
:return: None :return: None
""" """
# Create a new empty level
self.test_success = self.create_level( import azlmbr.bus as bus
self.args["level"], import azlmbr.editor as editor
heightmap_resolution=1024, import azlmbr.entity as entity
heightmap_meters_per_pixel=1,
terrain_texture_resolution=4096, import editor_python_test_tools.hydra_editor_utils as hydra
use_terrain=False, from editor_python_test_tools.utils import Report
) from editor_python_test_tools.utils import TestHelper as helper
# Open an existing simple level
helper.init_idle()
helper.open_level("Physics", "Base")
# Create a new Entity in the level # Create a new Entity in the level
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId()) entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
@ -58,19 +58,17 @@ class TestGradientTransformRequiresShape(EditorTestHelper):
# Verify the Gradient Transform Component is not active before adding the Shape # Verify the Gradient Transform Component is not active before adding the Shape
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_transform_component) active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_transform_component)
self.test_success = self.test_success and not active Report.result(Tests.disabled_without_shape, not active)
if not active:
self.log("Gradient Transform component is not active without a Shape component on the Entity")
# Add a Shape component to the same Entity # Add a Shape component to the same Entity
hydra.add_component('Box Shape', entity_id) hydra.add_component('Box Shape', entity_id)
# Check if the Gradient Transform Component is active now after adding the Shape # Check if the Gradient Transform Component is active now after adding the Shape
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_transform_component) active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_transform_component)
self.test_success = self.test_success and active Report.result(Tests.enabled_with_shape, active)
if active:
self.log("Gradient Transform Modifier component is active now that the Entity has a Shape")
if __name__ == "__main__":
test = TestGradientTransformRequiresShape() from editor_python_test_tools.utils import Report
test.run() Report.start_test(GradientTransform_RequiresShape)

@ -5,28 +5,23 @@ For complete copyright and license terms please see the LICENSE at the root of t
SPDX-License-Identifier: Apache-2.0 OR MIT SPDX-License-Identifier: Apache-2.0 OR MIT
""" """
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import azlmbr.asset as asset
import azlmbr.bus as bus
import azlmbr.entity as EntityId
import azlmbr.editor as editor
import azlmbr.math as math
import azlmbr.paths
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.editor_test_helper import EditorTestHelper
class Tests:
image_gradient_entity_created = (
"Image Gradient entity created",
"Failed to create Image Gradient entity",
)
image_gradient_asset_found = (
"image_grad_test_gsi.png was found in the workspace",
"image_grad_test_gsi.png was not found in the workspace"
)
image_gradient_assigned = (
"Successfully assigned image gradient asset",
"Failed to assign image gradient asset"
)
class TestImageGradient(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="ImageGradient_ProcessedImageAssignedSucessfully",
args=["level"])
def run_test(self): def ImageGradient_ProcessedImageAssignedSuccessfully():
""" """
Summary: Summary:
Level created with Entity having Image Gradient and Gradient Transform Modifier components. Level created with Entity having Image Gradient and Gradient Transform Modifier components.
@ -36,7 +31,7 @@ class TestImageGradient(EditorTestHelper):
Image can be assigned as the Image Asset for the Image as Gradient component. Image can be assigned as the Image Asset for the Image as Gradient component.
Test Steps: Test Steps:
1) Create level 1) Open a level
2) Create an entity with Image Gradient and Gradient Transform Modifier components. 2) Create an entity with Image Gradient and Gradient Transform Modifier components.
3) Assign the newly processed gradient image as Image asset. 3) Assign the newly processed gradient image as Image asset.
@ -48,14 +43,21 @@ class TestImageGradient(EditorTestHelper):
:return: None :return: None
""" """
# 1) Create level import os
self.test_success = self.create_level(
self.args["level"], import azlmbr.asset as asset
heightmap_resolution=1024, import azlmbr.bus as bus
heightmap_meters_per_pixel=1, import azlmbr.entity as EntityId
terrain_texture_resolution=4096, import azlmbr.editor as editor
use_terrain=False, import azlmbr.math as math
)
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
# 1) Open an existing simple level
helper.init_idle()
helper.open_level("Physics", "Base")
# 2) Create an entity with Image Gradient and Gradient Transform Modifier components # 2) Create an entity with Image Gradient and Gradient Transform Modifier components
components_to_add = ["Image Gradient", "Gradient Transform Modifier", "Box Shape"] components_to_add = ["Image Gradient", "Gradient Transform Modifier", "Box Shape"]
@ -63,8 +65,7 @@ class TestImageGradient(EditorTestHelper):
new_entity_id = editor.ToolsApplicationRequestBus( new_entity_id = editor.ToolsApplicationRequestBus(
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId() bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
) )
if new_entity_id.IsValid(): Report.critical_result(Tests.image_gradient_entity_created, new_entity_id.IsValid())
print("Image Gradient Entity created")
image_gradient_entity = hydra.Entity("Image Gradient Entity", new_entity_id) image_gradient_entity = hydra.Entity("Image Gradient Entity", new_entity_id)
image_gradient_entity.components = [] image_gradient_entity.components = []
for component in components_to_add: for component in components_to_add:
@ -75,8 +76,7 @@ class TestImageGradient(EditorTestHelper):
# First, check for the base image in the workspace # First, check for the base image in the workspace
base_image = "image_grad_test_gsi.png" base_image = "image_grad_test_gsi.png"
base_image_path = os.path.join("AutomatedTesting", "Assets", "ImageGradients", base_image) base_image_path = os.path.join("AutomatedTesting", "Assets", "ImageGradients", base_image)
if os.path.isfile(base_image_path): Report.critical_result(Tests.image_gradient_asset_found, os.path.isfile(base_image_path))
print(f"{base_image} was found in the workspace")
# Next, assign the processed image to the Image Gradient's Image Asset property # Next, assign the processed image to the Image Gradient's Image Asset property
processed_image_path = os.path.join("Assets", "ImageGradients", "image_grad_test_gsi.gradimage") processed_image_path = os.path.join("Assets", "ImageGradients", "image_grad_test_gsi.gradimage")
@ -86,8 +86,10 @@ class TestImageGradient(EditorTestHelper):
# Finally, verify if the gradient image is assigned as the Image Asset # Finally, verify if the gradient image is assigned as the Image Asset
success = hydra.get_component_property_value(image_gradient_entity.components[0], "Configuration|Image Asset") == asset_id success = hydra.get_component_property_value(image_gradient_entity.components[0], "Configuration|Image Asset") == asset_id
self.test_success = self.test_success and success Report.result(Tests.image_gradient_assigned, success)
if __name__ == "__main__":
test = TestImageGradient() from editor_python_test_tools.utils import Report
test.run() Report.start_test(ImageGradient_ProcessedImageAssignedSuccessfully)

@ -4,24 +4,20 @@ For complete copyright and license terms please see the LICENSE at the root of t
SPDX-License-Identifier: Apache-2.0 OR MIT SPDX-License-Identifier: Apache-2.0 OR MIT
""" """
import os
import sys
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.entity as entity
import azlmbr.paths
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
import editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.editor_test_helper import EditorTestHelper
class Tests:
disabled_without_shape = (
"Image Gradient component is disabled without a Shape component on the Entity",
"Image Gradient component is unexpectedly enabled without a Shape component on the Entity",
)
enabled_with_shape = (
"Image Gradient component is enabled now that the Entity has a Shape",
"Image Gradient component is still disabled alongside a Shape component",
)
class TestImageGradientRequiresShape(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="ImageGradientRequiresShape", args=["level"])
def run_test(self): def ImageGradient_RequiresShape():
""" """
Summary: Summary:
This test verifies that the Image Gradient component is dependent on a shape component. This test verifies that the Image Gradient component is dependent on a shape component.
@ -41,14 +37,18 @@ class TestImageGradientRequiresShape(EditorTestHelper):
:return: None :return: None
""" """
# Create a new empty level
self.test_success = self.create_level( import azlmbr.bus as bus
self.args["level"], import azlmbr.editor as editor
heightmap_resolution=1024, import azlmbr.entity as entity
heightmap_meters_per_pixel=1,
terrain_texture_resolution=4096, import editor_python_test_tools.hydra_editor_utils as hydra
use_terrain=False, from editor_python_test_tools.utils import Report
) from editor_python_test_tools.utils import TestHelper as helper
# Open an existing simple level
helper.init_idle()
helper.open_level("Physics", "Base")
# Create a new Entity in the level # Create a new Entity in the level
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId()) entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
@ -59,19 +59,17 @@ class TestImageGradientRequiresShape(EditorTestHelper):
# Verify the Image Gradient Component is not active before adding the Shape # Verify the Image Gradient Component is not active before adding the Shape
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', image_gradient_component) active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', image_gradient_component)
self.test_success = self.test_success and not active Report.result(Tests.disabled_without_shape, not active)
if not active:
self.log("Image Gradient component is not active without a Shape component on the Entity")
# Add a Shape component to the same Entity # Add a Shape component to the same Entity
hydra.add_component('Box Shape', entity_id) hydra.add_component('Box Shape', entity_id)
# Check if the Image Gradient Component is active now after adding the Shape # Check if the Image Gradient Component is active now after adding the Shape
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', image_gradient_component) active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', image_gradient_component)
self.test_success = self.test_success and active Report.result(Tests.enabled_with_shape, active)
if active:
self.log("Image Gradient component is active now that the Entity has a Shape")
if __name__ == "__main__":
test = TestImageGradientRequiresShape() from editor_python_test_tools.utils import Report
test.run() Report.start_test(ImageGradient_RequiresShape)

@ -0,0 +1,71 @@
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
import os
import pytest
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../../automatedtesting_shared')
from base import TestAutomationBase
@pytest.mark.SUITE_periodic
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
@pytest.mark.parametrize("project", ["AutomatedTesting"])
class TestAutomation(TestAutomationBase):
def test_GradientGenerators_Incompatibilities(self, request, workspace, editor, launcher_platform):
from .EditorScripts import GradientGenerators_Incompatibilities as test_module
self._run_test(request, workspace, editor, test_module)
def test_GradientModifiers_Incompatibilities(self, request, workspace, editor, launcher_platform):
from .EditorScripts import GradientModifiers_Incompatibilities as test_module
self._run_test(request, workspace, editor, test_module)
def test_GradientPreviewSettings_DefaultPinnedEntityIsSelf(self, request, workspace, editor, launcher_platform):
from .EditorScripts import GradientPreviewSettings_DefaultPinnedEntityIsSelf as test_module
self._run_test(request, workspace, editor, test_module)
def test_GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin(self, request, workspace, editor, launcher_platform):
from .EditorScripts import GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin as test_module
self._run_test(request, workspace, editor, test_module)
def test_GradientSampling_GradientReferencesAddRemoveSuccessfully(self, request, workspace, editor, launcher_platform):
from .EditorScripts import GradientSampling_GradientReferencesAddRemoveSuccessfully as test_module
self._run_test(request, workspace, editor, test_module)
def test_GradientSurfaceTagEmitter_ComponentDependencies(self, request, workspace, editor, launcher_platform):
from .EditorScripts import GradientSurfaceTagEmitter_ComponentDependencies as test_module
self._run_test(request, workspace, editor, test_module)
def test_GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully(self, request, workspace, editor, launcher_platform):
from .EditorScripts import GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully as test_module
self._run_test(request, workspace, editor, test_module)
def test_GradientTransform_RequiresShape(self, request, workspace, editor, launcher_platform):
from .EditorScripts import GradientTransform_RequiresShape as test_module
self._run_test(request, workspace, editor, test_module)
def test_GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange(self, request, workspace, editor, launcher_platform):
from .EditorScripts import GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange as test_module
self._run_test(request, workspace, editor, test_module)
def test_GradientTransform_ComponentIncompatibleWithSpawners(self, request, workspace, editor, launcher_platform):
from .EditorScripts import GradientTransform_ComponentIncompatibleWithSpawners as test_module
self._run_test(request, workspace, editor, test_module)
def test_GradientTransform_ComponentIncompatibleWithExpectedGradients(self, request, workspace, editor, launcher_platform):
from .EditorScripts import GradientTransform_ComponentIncompatibleWithExpectedGradients as test_module
self._run_test(request, workspace, editor, test_module)
def test_ImageGradient_RequiresShape(self, request, workspace, editor, launcher_platform):
from .EditorScripts import ImageGradient_RequiresShape as test_module
self._run_test(request, workspace, editor, test_module)
def test_ImageGradient_ProcessedImageAssignedSuccessfully(self, request, workspace, editor, launcher_platform):
from .EditorScripts import ImageGradient_ProcessedImageAssignedSuccessfully as test_module
self._run_test(request, workspace, editor, 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
"""
import pytest
from ly_test_tools.o3de.editor_test import EditorSingleTest, EditorSharedTest, EditorParallelTest, EditorTestSuite
@pytest.mark.SUITE_periodic
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
@pytest.mark.parametrize("project", ["AutomatedTesting"])
class TestAutomation(EditorTestSuite):
class test_GradientGenerators_Incompatibilities(EditorSharedTest):
from .EditorScripts import GradientGenerators_Incompatibilities as test_module
class test_GradientModifiers_Incompatibilities(EditorSharedTest):
from .EditorScripts import GradientModifiers_Incompatibilities as test_module
class test_GradientPreviewSettings_DefaultPinnedEntityIsSelf(EditorSharedTest):
from .EditorScripts import GradientPreviewSettings_DefaultPinnedEntityIsSelf as test_module
class test_GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin(EditorSharedTest):
from .EditorScripts import GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin as test_module
class test_GradientSampling_GradientReferencesAddRemoveSuccessfully(EditorSharedTest):
from .EditorScripts import GradientSampling_GradientReferencesAddRemoveSuccessfully as test_module
class test_GradientSurfaceTagEmitter_ComponentDependencies(EditorSharedTest):
from .EditorScripts import GradientSurfaceTagEmitter_ComponentDependencies as test_module
class test_GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully(EditorSharedTest):
from .EditorScripts import GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully as test_module
class test_GradientTransform_RequiresShape(EditorSharedTest):
from .EditorScripts import GradientTransform_RequiresShape as test_module
class test_GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange(EditorSharedTest):
from .EditorScripts import GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange as test_module
class test_GradientTransform_ComponentIncompatibleWithSpawners(EditorSharedTest):
from .EditorScripts import GradientTransform_ComponentIncompatibleWithSpawners as test_module
class test_GradientTransform_ComponentIncompatibleWithExpectedGradients(EditorSharedTest):
from .EditorScripts import GradientTransform_ComponentIncompatibleWithExpectedGradients as test_module
class test_ImageGradient_RequiresShape(EditorSharedTest):
from .EditorScripts import ImageGradient_RequiresShape as test_module
class test_ImageGradient_ProcessedImageAssignedSuccessfully(EditorSharedTest):
from .EditorScripts import ImageGradient_ProcessedImageAssignedSuccessfully as test_module
Loading…
Cancel
Save