Integrating latest 47acbe8

This commit is contained in:
alexpete
2021-03-25 13:57:57 -07:00
parent 448c549698
commit 75dc720198
10312 changed files with 2711566 additions and 671451 deletions
@@ -0,0 +1,118 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
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 automatedtesting_shared.hydra_editor_utils as hydra
from automatedtesting_shared.editor_test_helper import EditorTestHelper
class TestGradientGeneratorIncompatibilities(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="GradientGeneratorIncompatibilities", args=["level"])
def run_test(self):
"""
Summary:
Verify that Entities are not active when a Gradient Generator and incompatible component are both present
on the same Entity.
:return: None
"""
gradient_generators = [
'Altitude Gradient',
'Constant Gradient',
'FastNoise Gradient',
'Image Gradient',
'Perlin Noise Gradient',
'Random Noise Gradient',
'Shape Falloff Gradient',
'Slope Gradient',
'Surface Mask Gradient'
]
require_transform_modifiers = [
'FastNoise Gradient',
'Image Gradient',
'Perlin Noise Gradient',
'Random Noise Gradient'
]
vegetation_areas = [
'Vegetation Layer Spawner',
'Vegetation Layer Blender',
'Vegetation Layer Blocker',
'Vegetation Layer Blocker (Mesh)'
]
area_dependencies = {
'Vegetation Layer Spawner': 'Vegetation Asset List',
'Vegetation Layer Blocker (Mesh)': 'Mesh'
}
# Create a new empty 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,
)
# For every gradient generator component, verify that they are incompatible
# which each vegetation area component
for component_name in gradient_generators:
for vegetation_area_name in vegetation_areas:
# Create a new Entity in the level
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
# Most of these need a shape, so use a Box Shape
hydra.add_component('Box Shape', entity_id)
# Add the specific vegetation area dependencies (if necessary)
if vegetation_area_name in area_dependencies:
hydra.add_component(area_dependencies[vegetation_area_name], entity_id)
# Add the vegetation area component we are validating against, then add the
# gradient generator afterwards, so that the gradient generator will actually
# be disabled (if it was present before, it would only get deactivated instead of disabled
# by the vegetation area)
area_component = hydra.add_component(vegetation_area_name, entity_id)
gradient_component = hydra.add_component(component_name, entity_id)
# Verify the gradient generator component is disabled since the vegetation area is incompatible
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
self.test_success = self.test_success and not active
if not active:
self.log(f"{component_name} is disabled before removing {vegetation_area_name} component")
# Remove the vegetation area component
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [area_component])
# Add required dependencies for our gradient generators after the vegetation
# area has been removed, because the transform modifier is also incompatible
# with the vegetation areas
if component_name in require_transform_modifiers:
hydra.add_component('Gradient Transform Modifier', entity_id)
# Verify the gradient generator component is enabled now that the vegetation area is gone
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
self.test_success = self.test_success and active
if active:
self.log(f"{component_name} is enabled after removing {vegetation_area_name} component")
test = TestGradientGeneratorIncompatibilities()
test.run()
@@ -0,0 +1,158 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
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 automatedtesting_shared.hydra_editor_utils as hydra
from automatedtesting_shared.editor_test_helper import EditorTestHelper
class TestGradientModifiersIncompatibilities(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="GradientModifiersIncompatibilities", args=["level"])
def run_test(self):
"""
Summary:
Verify that Entities are not active when a Gradient Modifier and incompatible component are both present
on the same Entity.
:return: None
"""
gradient_generators = [
'Altitude Gradient',
'Constant Gradient',
'FastNoise Gradient',
'Image Gradient',
'Perlin Noise Gradient',
'Random Noise Gradient',
'Shape Falloff Gradient',
'Slope Gradient',
'Surface Mask Gradient'
]
require_transform_modifiers = [
'FastNoise Gradient',
'Image Gradient',
'Perlin Noise Gradient',
'Random Noise Gradient'
]
gradient_modifiers = [
'Dither Gradient Modifier',
'Gradient Mixer',
'Invert Gradient Modifier',
'Levels Gradient Modifier',
'Posterize Gradient Modifier',
'Smooth-Step Gradient Modifier',
'Threshold Gradient Modifier'
]
vegetation_areas = [
'Vegetation Layer Spawner',
'Vegetation Layer Blender',
'Vegetation Layer Blocker',
'Vegetation Layer Blocker (Mesh)'
]
area_dependencies = {
'Vegetation Layer Spawner': 'Vegetation Asset List',
'Vegetation Layer Blocker (Mesh)': 'Mesh'
}
# Create a new empty 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,
)
# For every gradient modifier component, verify that they are incompatible
# which each vegetation area and gradient generator/modifier component
all_gradients = gradient_modifiers + gradient_generators
for component_name in gradient_modifiers:
for vegetation_area_name in vegetation_areas:
# Create a new Entity in the level
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
# Most of these need a shape, so use a Box Shape
hydra.add_component('Box Shape', entity_id)
# Add the specific vegetation area dependencies (if necessary)
if vegetation_area_name in area_dependencies:
hydra.add_component(area_dependencies[vegetation_area_name], entity_id)
# Add the vegetation area component we are validating against, then add the
# gradient modifier afterwards, so that the gradient modifier will actually
# be disabled (if it was present before, it would only get deactivated instead of disabled
# by the vegetation area)
area_component = hydra.add_component(vegetation_area_name, entity_id)
gradient_component = hydra.add_component(component_name, entity_id)
# Verify the gradient modifier component is disabled since the vegetation area is incompatible
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
self.test_success = self.test_success and not active
if not active:
self.log("{gradient} is disabled before removing {vegetation_area} component".format(gradient=component_name, vegetation_area=vegetation_area_name))
# Remove the vegetation area component
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [area_component])
# Verify the gradient modifier component is enabled now that the vegetation area is gone
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
self.test_success = self.test_success and active
if active:
self.log("{gradient} is enabled after removing {vegetation_area} component".format(gradient=component_name, vegetation_area=vegetation_area_name))
for gradient_name in all_gradients:
# Create a new Entity in the level
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
# Most of these need a shape, so use a Box Shape
hydra.add_component('Box Shape', entity_id)
# Add the specific gradient generator dependencies (if necessary)
conflicting_components = []
if gradient_name in require_transform_modifiers:
component = hydra.add_component('Gradient Transform Modifier', entity_id)
conflicting_components.append(component)
# Add the gradient component we are validating against, then add the
# gradient modifier afterwards, so that the gradient modifier will actually
# be disabled (if it was present before, it would only get deactivated instead of disabled
# by the other gradient)
component = hydra.add_component(gradient_name, entity_id)
conflicting_components.append(component)
gradient_component = hydra.add_component(component_name, entity_id)
# Verify the gradient modifier component is disabled since the other gradient is incompatible
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
self.test_success = self.test_success and not active
if not active:
self.log("{gradient} is disabled before removing {conflicting_gradient} component".format(gradient=component_name, conflicting_gradient=gradient_name))
# Remove the conflicting gradient component (and transform modifier if it was added)
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', conflicting_components)
# Verify the gradient modifier component is enabled now that the other gradient is gone
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
self.test_success = self.test_success and active
if active:
self.log("{gradient} is enabled after removing {conflicting_gradient} component".format(gradient=component_name, conflicting_gradient=gradient_name))
test = TestGradientModifiersIncompatibilities()
test.run()
@@ -0,0 +1,150 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
"""
The below cases are combined in this script
C2676829
C3961326
C3980659
C3980664
C3980669
C3416548
C2676823
C3961321
C2676826
"""
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 automatedtesting_shared.hydra_editor_utils as hydra
from automatedtesting_shared.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:
A temporary level is created. An entity for each test case is created and added with the corresponding
components to verify if the gradient transform is set to the world origin.
Expected Behavior:
1) Preview image updates to reflect change in transform of the gradient sampler.
2) New Preview Position property is exposed, and set to 0,0,0 (world origin).
3) Preview Size is set to 1,1,1 by default.
Test Steps:
1) Open level
2) Create entity with Random Noise gradient and verify gradient position after clearing pinned entity
3) Create entity with Levels Gradient Modifier and verify gradient position after clearing pinned entity
4) Create entity with Posterize Gradient Modifier and verify gradient position after clearing pinned entity
5) Create entity with Smooth-Step Gradient Modifier and verify gradient position after clearing pinned entity
6) Create entity with Threshold Gradient Modifier and verify gradient position after clearing pinned entity
7) Create entity with FastNoise Gradient and verify gradient position after clearing pinned entity
8) Create entity with Dither Gradient Modifier and verify gradient position after clearing pinned entity
9) Create entity with Invert Gradient Modifier and verify gradient position after clearing pinned entity
10) Create entity with Perlin Noise Gradient and verify gradient position after clearing pinned entity
Note:
- This test file must be called from the Lumberyard Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
:return: None
"""
WORLD_ORIGIN = math.Vector3(0.0, 0.0, 0.0)
EXPECTED_SIZE = math.Vector3(1.0, 1.0, 1.0)
CLOSE_THRESHOLD = sys.float_info.min
def create_entity(enity_name, components_to_add):
entity_position = math.Vector3(125.0, 136.0, 32.0)
entity_id = editor.ToolsApplicationRequestBus(
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
)
entity = hydra.Entity(enity_name, entity_id)
if entity_id.IsValid():
print(f"{enity_name} entity Created")
entity.components = []
for component in components_to_add:
entity.components.append(hydra.add_component(component, entity_id))
return entity
def clear_entityid_check_position(entity_name, components_to_add, check_preview_size=False):
entity = create_entity(entity_name, components_to_add)
hydra.get_set_test(entity, 0, "Preview Settings|Pin Preview to Shape", EntityId.EntityId())
preview_position = hydra.get_component_property_value(
entity.components[0], "Preview Settings|Preview Position"
)
if preview_position.IsClose(WORLD_ORIGIN, CLOSE_THRESHOLD):
print(f"{entity_name} --- Preview Position set to world origin")
if check_preview_size:
preview_size = hydra.get_component_property_value(entity.components[0], "Preview Settings|Preview Size")
if preview_size.IsClose(EXPECTED_SIZE, CLOSE_THRESHOLD):
print(f"{entity_name} --- Preview Size set to (1, 1, 1)")
return entity
# 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,
)
# 2) Create entity with Random Noise gradient and verify gradient position after clearing pinned entity
clear_entityid_check_position(
"Random Noise Gradient", ["Random Noise Gradient", "Gradient Transform Modifier", "Box Shape"], True
)
# 3) Create entity with Levels Gradient Modifier and verify gradient position after clearing pinned entity
clear_entityid_check_position("Levels Gradient Modifier", ["Levels Gradient Modifier"])
# 4) Create entity with Posterize Gradient Modifier and verify gradient position after clearing pinned entity
clear_entityid_check_position("Posterize Gradient Modifier", ["Posterize Gradient Modifier"])
# 5) Create entity with Smooth-Step Gradient Modifier and verify gradient position after clearing pinned entity
clear_entityid_check_position("Smooth-Step Gradient Modifier", ["Smooth-Step Gradient Modifier"])
# 6) Create entity with Threshold Gradient Modifier and verify gradient position after clearing pinned entity
clear_entityid_check_position("Threshold Gradient Modifier", ["Threshold Gradient Modifier"])
# 7) Create entity with FastNoise Gradient and verify gradient position after clearing pinned entity
clear_entityid_check_position(
"FastNoise Gradient", ["FastNoise Gradient", "Gradient Transform Modifier", "Box Shape"], True
)
# 8) Create entity with Dither Gradient Modifier and verify gradient position after clearing pinned entity
clear_entityid_check_position("Dither Gradient Modifier", ["Dither Gradient Modifier"], True)
# 9) Create entity with Invert Gradient Modifier and verify gradient position after clearing pinned entity
clear_entityid_check_position("Invert Gradient Modifier", ["Invert Gradient Modifier"])
# 10) Create entity with Perlin Noise Gradient and verify gradient position after clearing pinned entity
clear_entityid_check_position(
"Perlin Noise Gradient", ["Perlin Noise Gradient", "Gradient Transform Modifier", "Box Shape"], True
)
test = TestGradientPreviewSettings()
test.run()
@@ -0,0 +1,103 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
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 automatedtesting_shared.hydra_editor_utils as hydra
from automatedtesting_shared.editor_test_helper import EditorTestHelper
class Scoped:
def __init__(self, constructor, destructor, *args):
self.data = constructor(*args)
self.destructor = destructor
def __del__(self):
self.destructor(self.data)
class TestParams:
def __init__(self, required_components, accessed_component):
self.required_components = required_components
self.accessed_component = accessed_component
class TestGradientPreviewSettings(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="GradientPreviewSettings_DefaultPinnedEntity", args=["level"])
def run_test(self):
"""
Summary:
Verify if the current entity is set to the pin preview to shape entity by default for several components.
:return: None
"""
def execute_test(test_id, function, *args):
if function(*args):
self.log(test_id + ' has Preview pinned to own Entity result: SUCCESS')
def create_entity():
return editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
def delete_entity(entity_id):
editor.ToolsApplicationRequestBus(bus.Broadcast, 'DeleteEntityAndAllDescendants', entity_id)
def attach_components(component_list, entity_id):
components = []
for i in component_list:
components.append(hydra.add_component(i, entity_id))
return components
def validate_id_is_current(param):
entity_ptr = Scoped(create_entity, delete_entity)
added_components = attach_components(param.required_components, entity_ptr.data)
value = hydra.get_component_property_value(added_components[param.accessed_component],
'Preview Settings|Pin Preview to Shape')
self.test_success = self.test_success and entity_ptr.data.Equal(value)
return entity_ptr.data.Equal(value)
param_list = [
TestParams(['Gradient Transform Modifier', 'Box Shape', 'Perlin Noise Gradient'], 2),
TestParams(['Random Noise Gradient', 'Gradient Transform Modifier', 'Box Shape'], 0),
TestParams(['FastNoise Gradient', 'Gradient Transform Modifier', 'Box Shape'], 0),
TestParams(['Dither Gradient Modifier'], 0),
TestParams(['Invert Gradient Modifier'], 0),
TestParams(['Levels Gradient Modifier'], 0),
TestParams(['Posterize Gradient Modifier'], 0),
TestParams(['Smooth-Step Gradient Modifier'], 0),
TestParams(['Threshold Gradient Modifier'], 0)
]
# Create a new empty 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,
)
for param in param_list:
execute_test(param.required_components[param.accessed_component],
validate_id_is_current, param)
test = TestGradientPreviewSettings()
test.run()
@@ -0,0 +1,100 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
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 automatedtesting_shared.hydra_editor_utils as hydra
from automatedtesting_shared.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:
An existing gradient generator can be pinned and cleared to/from the Gradient Entity Id field
Expected Behavior:
Gradient generator is assigned to the Gradient Entity Id field.
Gradient generator is removed from the field.
Test Steps:
1) Open level
2) Create a new entity with components "Random Noise Gradient", "Gradient Transform Modifier" and "Box Shape"
3) Create a new entity with Gradient Modifier's, pin and clear the random noise entity id to the Gradient Id
field in Gradient Modifier
Note:
- This test file must be called from the Lumberyard Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
:return: None
"""
def modifier_pin_clear_to_gradiententityid(modifier):
entity_position = math.Vector3(125.0, 136.0, 32.0)
component_to_add = [modifier]
gradient_modifier = hydra.Entity(modifier)
gradient_modifier.create_entity(entity_position, component_to_add)
gradient_modifier.get_set_test(0, "Configuration|Gradient|Gradient Entity Id", random_noise.id)
entity = hydra.get_component_property_value(
gradient_modifier.components[0], "Configuration|Gradient|Gradient Entity Id"
)
if entity.Equal(random_noise.id):
print(f"Gradient Generator is pinned to the {modifier} successfully")
else:
print(f"Failed to pin Gradient Generator to the {modifier}")
hydra.get_set_test(gradient_modifier, 0, "Configuration|Gradient|Gradient Entity Id", EntityId.EntityId())
entity = hydra.get_component_property_value(
gradient_modifier.components[0], "Configuration|Gradient|Gradient Entity Id"
)
if entity.Equal(EntityId.EntityId()):
print(f"Gradient Generator is cleared from the {modifier} successfully")
else:
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,
)
# 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)
components_to_add = ["Random Noise Gradient", "Gradient Transform Modifier", "Box Shape"]
random_noise = hydra.Entity("Random_Noise")
random_noise.create_entity(entity_position, components_to_add)
# 3) Create a new entity with Gradient Modifier's, pin and clear the random noise entity id to the Gradient Id
# field in Gradient Modifier
modifier_pin_clear_to_gradiententityid("Dither Gradient Modifier")
modifier_pin_clear_to_gradiententityid("Invert Gradient Modifier")
modifier_pin_clear_to_gradiententityid("Levels Gradient Modifier")
modifier_pin_clear_to_gradiententityid("Posterize Gradient Modifier")
modifier_pin_clear_to_gradiententityid("Smooth-Step Gradient Modifier")
modifier_pin_clear_to_gradiententityid("Threshold Gradient Modifier")
test = TestGradientSampling()
test.run()
@@ -0,0 +1,111 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
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 automatedtesting_shared.hydra_editor_utils as hydra
from automatedtesting_shared.editor_test_helper import EditorTestHelper
class TestGradientSurfaceTagEmitterDependencies(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(
self, log_prefix="GradientSurfaceTagEmitter_ComponentDependencies", args=["level"]
)
def run_test(self):
"""
Summary:
Component has a dependency on a Gradient component
Expected Result:
Component is disabled until a Gradient Generator, Modifier or Gradient Reference component
(and any sub-dependencies) is added to the entity.
:return: None
"""
def is_enabled(EntityComponentIdPair):
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair)
# Create empty 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,
)
# Create an entity with Gradient Surface Tag Emitter component
position = math.Vector3(512.0, 512.0, 32.0)
gradient = hydra.Entity("gradient")
gradient.create_entity(position, ["Gradient Surface Tag Emitter"])
# Make sure Gradient Surface Tag Emitter is disabled
is_enable = is_enabled(gradient.components[0])
if not is_enable:
self.log("Gradient Surface Tag Emitter is Disabled")
elif not is_enable:
self.log("Gradient Surface Tag Emitter is Enabled, but should be Disabled without dependencies met")
# Verify Gradient Surface Tag Emitter component is enabled after adding Gradient, Generator, Modifier
# or Reference component
new_components_to_add = [
"Dither Gradient Modifier",
"Gradient Mixer",
"Invert Gradient Modifier",
"Levels Gradient Modifier",
"Posterize Gradient Modifier",
"Smooth-Step Gradient Modifier",
"Threshold Gradient Modifier",
"Altitude Gradient",
"Constant Gradient",
"FastNoise Gradient",
"Image Gradient",
"Perlin Noise Gradient",
"Random Noise Gradient",
"Reference Gradient",
"Shape Falloff Gradient",
"Slope Gradient",
"Surface Mask Gradient",
]
for component in new_components_to_add:
component_list = ["FastNoise Gradient", "Image Gradient", "Perlin Noise Gradient", "Random Noise Gradient"]
if component in component_list:
for Component in ["Gradient Transform Modifier", "Box Shape"]:
hydra.add_component(Component, gradient.id)
typeIdsList = editor.EditorComponentAPIBus(bus.Broadcast, 'FindComponentTypeIdsByEntityType', [component],
entity.EntityType().Game)
ComponentOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'AddComponentsOfType', gradient.id, [typeIdsList[0]])
Components = ComponentOutcome.GetValue()
ComponentIdPair = Components[0]
gradient_enabled = new_components_enabled = False
gradient_enabled = is_enabled(gradient.components[0])
new_components_enabled = is_enabled(ComponentIdPair)
if new_components_enabled and gradient_enabled:
self.log(f"{component} and Gradient Surface Tag Emitter are enabled")
else:
self.log(f"{component} and Gradient Surface Tag Emitter are disabled")
if component in component_list:
hydra.remove_component("Gradient Transform Modifier", gradient.id)
hydra.remove_component("Box Shape", gradient.id)
hydra.remove_component(component, gradient.id)
test = TestGradientSurfaceTagEmitterDependencies()
test.run()
@@ -0,0 +1,83 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
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 automatedtesting_shared.hydra_editor_utils as hydra
from automatedtesting_shared.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:
Entity with Gradient Surface Tag Emitter and Reference Gradient components is created.
And new surface tag has been added and removed.
Expected Behavior:
A new Surface Tag can be added and removed from the component
Test Steps:
1) Open level
2) Create an entity with Gradient Surface Tag Emitter and Reference Gradient components.
3) Add/ remove Surface Tags
Note:
- This test file must be called from the Lumberyard Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
:return: None
"""
# 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,
)
# 2) Create an entity with Gradient Surface Tag Emitter and Reference Gradient components.
entity_position = math.Vector3(125.0, 136.0, 32.0)
components_to_add = ["Gradient Surface Tag Emitter", "Reference Gradient"]
entity = hydra.Entity("entity")
entity.create_entity(entity_position, components_to_add)
# 3) Add/ remove Surface Tags
tag = surface_data.SurfaceTag()
tag.SetTag("water")
pte = hydra.get_property_tree(entity.components[0])
path = "Configuration|Extended Tags"
pte.add_container_item(path, 0, tag)
success = self.wait_for_condition(lambda: pte.get_container_count(path).GetValue() == 1)
self.test_success = self.test_success and success
print(f"Added SurfaceTag: container count is {pte.get_container_count(path).GetValue()}")
pte.remove_container_item(path, 0)
success = self.wait_for_condition(lambda: pte.get_container_count(path).GetValue() == 0)
self.test_success = self.test_success and success
print(f"Removed SurfaceTag: container count is {pte.get_container_count(path).GetValue()}")
test = TestGradientSurfaceTagEmitter()
test.run()
@@ -0,0 +1,126 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
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.entity as EntityId
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
import automatedtesting_shared.hydra_editor_utils as hydra
from automatedtesting_shared.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:
A New level is created. A New entity is created with components Gradient Transform Modifier and Box Shape.
Adding components Constant Gradient, Altitude Gradient, Gradient Mixer, Reference Gradient, Shape
Falloff Gradient, Slope Gradient and Surface Mask Gradient to the same entity.
Expected Behavior:
All added components are disabled and inform the user that they are incompatible with the Gradient Transform
Modifier
Test Steps:
1) Create level
2) Create a new entity with components Gradient Transform Modifier and Box Shape
3) Make sure all components are enabled in Entity
4) Add Constant Gradient, Altitude Gradient, Gradient Mixer, Reference Gradient, Shape
Falloff Gradient, Slope Gradient and Surface Mask Gradient to the same entity
5) Make sure all newly added components are disabled
Note:
- This test file must be called from the Lumberyard Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
:return: None
"""
def is_enabled(EntityComponentIdPair):
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair)
# 1) Create 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,
)
# 2) Create a new entity with components Gradient Transform Modifier and Box Shape
entity_position = math.Vector3(125.0, 136.0, 32.0)
components_to_add = ["Gradient Transform Modifier", "Box Shape"]
gradient_id = editor.ToolsApplicationRequestBus(
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
)
gradient = hydra.Entity("gradient", gradient_id)
gradient.components = []
for component in components_to_add:
gradient.components.append(hydra.add_component(component, gradient_id))
if gradient_id.isValid():
self.log("New Entity Created")
# 3) Make sure all components are enabled in Entity
index = 0
for component in components_to_add:
is_enable = is_enabled(gradient.components[index])
if is_enable:
self.log(f"{component} is Enabled")
self.test_success = self.test_success and is_enable
elif not is_enable:
self.log(f"{component} is disabled, but it should be enabled")
self.test_success = self.test_success and is_enable
break
index += 1
# 4) Add Constant Gradient, Altitude Gradient, Gradient Mixer, Reference Gradient, Shape
# Falloff Gradient, Slope Gradient and Surface Mask Gradient to the same entity
new_components_to_add = [
"Constant Gradient",
"Altitude Gradient",
"Gradient Mixer",
"Reference Gradient",
"Shape Falloff Gradient",
"Slope Gradient",
"Surface Mask Gradient",
]
index = 2
new_components_enabled = False
for component in new_components_to_add:
gradient.components.append(hydra.add_component(component, gradient_id))
new_components_enabled = is_enabled(gradient.components[index])
if new_components_enabled:
self.log(f"{component} is enabled, but should be disabled")
break
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
test = TestGradientTransform_ComponentIncompatibleWithExpectedGradients()
test.run()
@@ -0,0 +1,112 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
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.entity as EntityId
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
import automatedtesting_shared.hydra_editor_utils as hydra
from automatedtesting_shared.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:
A New level is created. A New entity is created with components Gradient Transform Modifier and Box Shape.
Adding a component Vegetation Layer Spawner to the same entity.
Expected Behavior:
The Vegetation Layer Spawner is deactivated and it is communicated that it is incompatible with Gradient
Transform Modifier
Test Steps:
1) Create level
2) Create a new entity with components Gradient Transform Modifier and Box Shape
3) Make sure all components are enabled in Entity
4) Add Vegetation Layer Spawner to the same entity
5) Make sure newly added component is disabled
Note:
- This test file must be called from the Lumberyard Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
:return: None
"""
def is_enabled(EntityComponentIdPair):
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair)
# 1) Create 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,
)
# 2) Create a new entity with components Gradient Transform Modifier and Box Shape
entity_position = math.Vector3(125.0, 136.0, 32.0)
components_to_add = ["Gradient Transform Modifier", "Box Shape"]
gradient_id = editor.ToolsApplicationRequestBus(
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
)
gradient = hydra.Entity("gradient", gradient_id)
gradient.components = []
for component in components_to_add:
gradient.components.append(hydra.add_component(component, gradient_id))
if gradient_id.isValid():
self.log("New Entity Created")
# 3) Make sure all components are enabled in Entity
index = 0
for component in components_to_add:
is_enable = is_enabled(gradient.components[index])
if is_enable:
self.log(f"{component} is Enabled")
self.test_success = self.test_success and is_enable
elif not is_enable:
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
# 4) Add Vegetation Layer Spawner to the same entity
new_component_to_add = "Vegetation Layer Spawner"
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
if not new_component_enabled:
self.log(f"{new_component_to_add} is incompatible and disabled")
self.test_success = self.test_success and not new_component_enabled
elif new_component_enabled:
self.log(f"{new_component_to_add} is compatible and enabled. But It should be Incompatible and disabled")
self.test_success = self.test_success and new_component_enabled
test = TestGradientTransform_ComponentIncompatibleWithSpawners()
test.run()
@@ -0,0 +1,95 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
"""
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 automatedtesting_shared.hydra_editor_utils as hydra
from automatedtesting_shared.editor_test_helper import EditorTestHelper
class TestGradientTransformFrequencyZoom(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="GradientTransform_FrequencyZoomBeyondSliders", args=["level"])
def run_test(self):
"""
Summary:
Frequency Zoom can manually be set higher than 8 in a random noise gradient
Expected Behavior:
The value properly changes, despite the value being outside of the slider limit
Test Steps:
1) Open level
2) Create entity
3) Add components to the entity
4) Set the frequency value of the component
5) Verify if the frequency value is set to higher value
Note:
- This test file must be called from the Lumberyard Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
:return: None
"""
# 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,
)
# 2) Create entity
entity_position = math.Vector3(125.0, 136.0, 32.0)
entity_id = editor.ToolsApplicationRequestBus(
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
)
if entity_id.IsValid():
print("Entity Created")
# 3) Add components to the entity
components_to_add = ["Random Noise Gradient", "Gradient Transform Modifier", "Box Shape"]
entity = hydra.Entity("entity", entity_id)
entity.components = []
for component in components_to_add:
entity.components.append(hydra.add_component(component, entity_id))
print("Components added to the entity")
# 4) Set the frequency value of the component
hydra.get_set_test(entity, 1, "Configuration|Frequency Zoom", 10)
# 5) Verify if the frequency value is set to higher value
curr_value = hydra.get_component_property_value(entity.components[1], "Configuration|Frequency Zoom")
if curr_value == 10.0:
print("Frequency Zoom is equal to expected value")
else:
print("Frequency Zoom is not equal to expected value")
test = TestGradientTransformFrequencyZoom()
test.run()
@@ -0,0 +1,68 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
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 automatedtesting_shared.hydra_editor_utils as hydra
from automatedtesting_shared.editor_test_helper import EditorTestHelper
class TestGradientTransformRequiresShape(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="GradientTransformRequiresShape", args=["level"])
def run_test(self):
"""
Summary:
Verify that Gradient Transform Modifier component requires a
Shape component before the Entity can become active.
:return: None
"""
# Create a new empty 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,
)
# Create a new Entity in the level
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
# Add a Gradient Transform Component (that will be disabled since there is no shape on the Entity)
gradient_transform_component = hydra.add_component('Gradient Transform Modifier', entity_id)
# Verify the Gradient Transform Component is not active before adding the Shape
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_transform_component)
self.test_success = self.test_success and 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
hydra.add_component('Box Shape', entity_id)
# Check if the Gradient Transform Component is active now after adding the Shape
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_transform_component)
self.test_success = self.test_success and active
if active:
self.log("Gradient Transform Modifier component is active now that the Entity has a Shape")
test = TestGradientTransformRequiresShape()
test.run()
@@ -0,0 +1,97 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
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 automatedtesting_shared.hydra_editor_utils as hydra
from automatedtesting_shared.editor_test_helper import EditorTestHelper
class TestImageGradient(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="ImageGradient_ProcessedImageAssignedSucessfully",
args=["level"])
def run_test(self):
"""
Summary:
Level created with Entity having Image Gradient and Gradient Transform Modifier components.
Save any new image to your workspace with the suffix "_gsi" and assign as image asset.
Expected Behavior:
Image can be assigned as the Image Asset for the Image as Gradient component.
Test Steps:
1) Create level
2) Create an entity with Image Gradient and Gradient Transform Modifier components.
3) Assign the newly processed gradient image as Image asset.
Note:
- This test file must be called from the Lumberyard Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
:return: None
"""
# 1) Create 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,
)
# 2) Create an entity with Image Gradient and Gradient Transform Modifier components
components_to_add = ["Image Gradient", "Gradient Transform Modifier", "Box Shape"]
entity_position = math.Vector3(512.0, 512.0, 32.0)
new_entity_id = editor.ToolsApplicationRequestBus(
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
)
if new_entity_id.IsValid():
print("Image Gradient Entity created")
image_gradient_entity = hydra.Entity("Image Gradient Entity", new_entity_id)
image_gradient_entity.components = []
for component in components_to_add:
image_gradient_entity.add_component(component)
# 3) Assign the processed gradient signal image as the Image Gradient's image asset and verify success
# First, check for the base image in the workspace
base_image = "lumberyard_gsi.png"
base_image_path = os.path.join("AutomatedTesting", "Assets", "ImageGradients", base_image)
if 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
processed_image_path = os.path.join("Assets", "ImageGradients", "lumberyard_gsi.gradimage")
asset_id = asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", processed_image_path, math.Uuid(),
False)
hydra.get_set_test(image_gradient_entity, 0, "Configuration|Image Asset", asset_id)
# 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
self.test_success = self.test_success and success
test = TestImageGradient()
test.run()
@@ -0,0 +1,69 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
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 automatedtesting_shared.hydra_editor_utils as hydra
from automatedtesting_shared.editor_test_helper import EditorTestHelper
class TestImageGradientRequiresShape(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="ImageGradientRequiresShape", args=["level"])
def run_test(self):
"""
Summary:
Verify that Image Gradient component requires a
Shape component before the Entity can become active.
:return: None
"""
# Create a new empty 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,
)
# Create a new Entity in the level
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
# Add an Image Gradient and Gradient Transform Component (should be disabled until a Shape exists on the Entity)
image_gradient_component = hydra.add_component('Image Gradient', entity_id)
hydra.add_component('Gradient Transform Modifier', entity_id)
# Verify the Image Gradient Component is not active before adding the Shape
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', image_gradient_component)
self.test_success = self.test_success and 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
hydra.add_component('Box Shape', entity_id)
# Check if the Image Gradient Component is active now after adding the Shape
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', image_gradient_component)
self.test_success = self.test_success and active
if active:
self.log("Image Gradient component is active now that the Entity has a Shape")
test = TestImageGradientRequiresShape()
test.run()