diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/CMakeLists.txt b/AutomatedTesting/Gem/PythonTests/largeworlds/CMakeLists.txt index f3536c4071..f133780fbc 100644 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/CMakeLists.txt +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/CMakeLists.txt @@ -157,7 +157,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_ NAME AutomatedTesting::GradientSignalTests_Periodic TEST_SERIAL TEST_SUITE periodic - PATH ${CMAKE_CURRENT_LIST_DIR}/gradient_signal + PATH ${CMAKE_CURRENT_LIST_DIR}/gradient_signal/test_GradientSignal_Periodic.py RUNTIME_DEPENDENCIES AZ::AssetProcessor Legacy::Editor diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientGenerators_Incompatibilities.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientGenerators_Incompatibilities.py index 37679d34ef..09cd760647 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientGenerators_Incompatibilities.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientGenerators_Incompatibilities.py @@ -4,124 +4,118 @@ For complete copyright and license terms please see the LICENSE at the root of t 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 TestGradientGeneratorIncompatibilities(EditorTestHelper): - def __init__(self): - EditorTestHelper.__init__(self, log_prefix="GradientGeneratorIncompatibilities", args=["level"]) - - def run_test(self): - """ - Summary: - This test verifies that components are disabled when conflicting components are present on the same entity. - - Expected Behavior: - Gradient Generator components are incompatible with Vegetation area components. - - Test Steps: - 1) Create a new 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 - 4) Verify that components are only enabled when entity is free of a conflicting component - - Note: - - This test file must be called from the Open 3D Engine 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 - """ - - 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() + + +def GradientGenerators_Incompatibilities(): + """ + Summary: + This test verifies that components are disabled when conflicting components are present on the same entity. + + Expected Behavior: + Gradient Generator components are incompatible with Vegetation area components. + + Test Steps: + 1) Open a simple 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 + 4) Verify that components are only enabled when entity is free of a conflicting component + + Note: + - This test file must be called from the Open 3D Engine 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 + """ + + 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 = [ + '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' + } + + # Open an existing simple level + helper.init_idle() + helper.open_level("Physics", "Base") + + # 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) + component_is_disabled = ( + 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 + 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) + component_is_enabled = ( + 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__": + + from editor_python_test_tools.utils import Report + Report.start_test(GradientGenerators_Incompatibilities) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientModifiers_Incompatibilities.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientModifiers_Incompatibilities.py index 8908493187..a4d9181744 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientModifiers_Incompatibilities.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientModifiers_Incompatibilities.py @@ -4,164 +4,162 @@ For complete copyright and license terms please see the LICENSE at the root of t 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 TestGradientModifiersIncompatibilities(EditorTestHelper): - def __init__(self): - EditorTestHelper.__init__(self, log_prefix="GradientModifiersIncompatibilities", args=["level"]) - - def run_test(self): - """ - Summary: - This test verifies that components are disabled when conflicting components are present on the same entity. - - Expected Behavior: - Gradient Modifier components are incompatible with Vegetation area components. - - Test Steps: - 1) Create a new 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 - 4) Verify that components are only enabled when entity is free of a conflicting component - - Note: - - This test file must be called from the Open 3D Engine 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 - """ - - 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)) +def GradientModifiers_Incompatibilities(): + """ + Summary: + This test verifies that components are disabled when conflicting components are present on the same entity. + + Expected Behavior: + Gradient Modifier components are incompatible with Vegetation area components. + + Test Steps: + 1) Open a simple 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 + 4) Verify that components are only enabled when entity is free of a conflicting component + + Note: + - This test file must be called from the Open 3D Engine 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 + """ + + 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 = [ + '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' + } + + # Open an existing simple level + helper.init_idle() + helper.open_level("Physics", "Base") + + # 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) + component_is_disabled = ( + 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 + 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) + component_is_enabled = ( + 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) + + 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) -test = TestGradientModifiersIncompatibilities() -test.run() + # 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) + component_is_disabled = ( + f"{component_name} is disabled before removing {gradient_name} component", + 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) + 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) + component_is_enabled = ( + f"{component_name} is enabled after removing {gradient_name} component", + f"{component_name} is unexpectedly disabled after removing {gradient_name} component" + ) + Report.result(component_is_enabled, active) + + +if __name__ == "__main__": + + from editor_python_test_tools.utils import Report + Report.start_test(GradientModifiers_Incompatibilities) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin.py index 73e8b95823..3749f93bf5 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin.py @@ -5,129 +5,125 @@ For complete copyright and license terms please see the LICENSE at the root of t SPDX-License-Identifier: Apache-2.0 OR MIT """ -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 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 Open 3D Engine 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 +def GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin(): + """ + 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 Open 3D Engine 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 + """ + + 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) + EXPECTED_SIZE = math.Vector3(1.0, 1.0, 1.0) + CLOSE_THRESHOLD = sys.float_info.min + + def create_entity(entity_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(entity_name, entity_id) + if entity_id.IsValid(): + print(f"{entity_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" + ) + preview_set_to_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: + preview_size = hydra.get_component_property_value(entity.components[0], "Preview Settings|Preview Size") + preview_size_default_set = ( + 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 - # 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"]) + # 1) Open an existing simple level + helper.init_idle() + helper.open_level("Physics", "Base") - # 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"]) + # 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 + ) - # 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"]) + # 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"]) - # 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"]) + # 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"]) - # 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 - ) + # 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"]) - # 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) + # 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"]) - # 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"]) + # 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 + ) - # 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 - ) +if __name__ == "__main__": -test = TestGradientPreviewSettings() -test.run() + from editor_python_test_tools.utils import Report + Report.start_test(GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientPreviewSettings_DefaultPinnedEntityIsSelf.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientPreviewSettings_DefaultPinnedEntityIsSelf.py index 99a54f614a..3756452710 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientPreviewSettings_DefaultPinnedEntityIsSelf.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientPreviewSettings_DefaultPinnedEntityIsSelf.py @@ -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 """ -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: def __init__(self, constructor, destructor, *args): @@ -33,81 +21,84 @@ class TestParams: 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: - This test verifies default values for the pinned entity for Gradient Preview settings. - - Expected Behavior: - Pinned entity is self for all gradient generator/modifiers. - - Test Steps: - 1) Create a new 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 - self - - Note: - - This test file must be called from the Open 3D Engine 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 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, - ) +def GradientPreviewSettings_DefaultPinnedEntityIsSelf(): + """ + Summary: + This test verifies default values for the pinned entity for Gradient Preview settings. + + Expected Behavior: + Pinned entity is self for all gradient generator/modifiers. - for param in param_list: - execute_test(param.required_components[param.accessed_component], - validate_id_is_current, param) + Test Steps: + 1) Open a simple 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 + self + Note: + - This test file must be called from the Open 3D Engine 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. -test = TestGradientPreviewSettings() -test.run() + :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): + pinned_to_self = ( + 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(): + 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') + 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) + ] + + # 1) Open an existing simple level + helper.init_idle() + helper.open_level("Physics", "Base") + + for param in param_list: + execute_test(param.required_components[param.accessed_component], + validate_id_is_current, param) + + +if __name__ == "__main__": + + from editor_python_test_tools.utils import Report + Report.start_test(GradientPreviewSettings_DefaultPinnedEntityIsSelf) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSampling_GradientReferencesAddRemoveSuccessfully.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSampling_GradientReferencesAddRemoveSuccessfully.py index 6d88f43d5a..8e85345a6f 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSampling_GradientReferencesAddRemoveSuccessfully.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSampling_GradientReferencesAddRemoveSuccessfully.py @@ -5,92 +5,82 @@ For complete copyright and license terms please see the LICENSE at the root of t SPDX-License-Identifier: Apache-2.0 OR MIT """ -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 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: - 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 Open 3D Engine 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" +def GradientSampling_GradientReferencesAddRemoveSuccessfully(): + """ + 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 Open 3D Engine 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 + """ + + 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): 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() + 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" + ) + gradient_pinned_to_modifier = ( + f"Gradient Generator is pinned to the {modifier} successfully", + 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()) + entity = hydra.get_component_property_value( + gradient_modifier.components[0], "Configuration|Gradient|Gradient Entity Id" + ) + gradient_cleared_from_modifier = ( + f"Gradient Generator is cleared from the {modifier} successfully", + f"Failed to clear Gradient Generator from the {modifier}" + ) + 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" + 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") + + +if __name__ == "__main__": + + from editor_python_test_tools.utils import Report + Report.start_test(GradientSampling_GradientReferencesAddRemoveSuccessfully) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSurfaceTagEmitter_ComponentDependencies.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSurfaceTagEmitter_ComponentDependencies.py index 26d791495a..f653515a39 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSurfaceTagEmitter_ComponentDependencies.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSurfaceTagEmitter_ComponentDependencies.py @@ -5,114 +5,104 @@ For complete copyright and license terms please see the LICENSE at the root of t 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): - """ - Summary: - This test verifies that the Gradient Surface Tag Emitter component is dependent on a gradient component. - - Expected Result: - Gradient Surface Tag Emitter component is disabled until a Gradient Generator, Modifier or Gradient Reference - component (and any sub-dependencies) is added to the entity. - - Test Steps: - 1) Open level - 2) Create a new entity with a Gradient Surface Tag Emitter component - 3) Verify the component is disabled until a dependent component is also added to the entity - - Note: - - This test file must be called from the Open 3D Engine 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) - - # 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, + +def GradientSurfaceTagEmitter_ComponentDependencies(): + """ + Summary: + This test verifies that the Gradient Surface Tag Emitter component is dependent on a gradient component. + + Expected Result: + Gradient Surface Tag Emitter component is disabled until a Gradient Generator, Modifier or Gradient Reference + component (and any sub-dependencies) is added to the entity. + + Test Steps: + 1) Open level + 2) Create a new entity with a Gradient Surface Tag Emitter component + 3) Verify the component is disabled until a dependent component is also added to the entity + + Note: + - This test file must be called from the Open 3D Engine 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 + """ + + 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): + return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair) + + # Open an existing simple level + helper.init_idle() + helper.open_level("Physics", "Base") + + # 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 + gradient_surface_tag_disabled = ( + "Gradient Surface Tag Emitter is Disabled", + "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 + # 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 = is_enabled(gradient.components[0]) + new_components_enabled = is_enabled(ComponentIdPair) + dependencies_met = ( + f"{component} and Gradient Surface Tag Emitter are enabled", + f"{component} and Gradient Surface Tag Emitter are disabled" ) + Report.result(dependencies_met, new_components_enabled and gradient_enabled) + + 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) + + +if __name__ == "__main__": - # 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() + from editor_python_test_tools.utils import Report + Report.start_test(GradientSurfaceTagEmitter_ComponentDependencies) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully.py index 44c9792296..90840a135d 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully.py @@ -5,75 +5,69 @@ For complete copyright and license terms please see the LICENSE at the root of t SPDX-License-Identifier: Apache-2.0 OR MIT """ -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 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: - 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 Open 3D Engine 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() + +def GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully(): + """ + 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 Open 3D Engine 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 + """ + + import azlmbr.math as math + import azlmbr.surface_data as surface_data + + 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 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 = helper.wait_for_condition(lambda: pte.get_container_count(path).GetValue() == 1, 1.0) + tag_added_to_container = ( + "Successfully added surface tag", + "Failed to add surface tag" + ) + Report.result(tag_added_to_container, success) + pte.remove_container_item(path, 0) + success = helper.wait_for_condition(lambda: pte.get_container_count(path).GetValue() == 0, 1.0) + tag_removed_from_container = ( + "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) + diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_ComponentIncompatibleWithExpectedGradients.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_ComponentIncompatibleWithExpectedGradients.py index b5f342a15f..5e6df4d52f 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_ComponentIncompatibleWithExpectedGradients.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_ComponentIncompatibleWithExpectedGradients.py @@ -5,118 +5,102 @@ For complete copyright and license terms please see the LICENSE at the root of t SPDX-License-Identifier: Apache-2.0 OR MIT """ -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 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: - 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 Open 3D Engine 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() +def GradientTransform_ComponentIncompatibleWithExpectedGradients(): + """ + 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 Open 3D Engine 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 + """ + + 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): + return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair) + + # 1) Open an existing simple level + helper.init_idle() + helper.open_level("Physics", "Base") + + # 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)) + 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 + index = 0 + for component in components_to_add: + components_enabled = ( + f"{component} is enabled", + f"{component} is unexpectedly disabled" + ) + Report.critical_result(components_enabled, is_enabled(gradient.components[index])) + 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", + ] + new_components_enabled = False + for component in new_components_to_add: + gradient.components.append(hydra.add_component(component, gradient_id)) + gradient_components_disabled = ( + f"{component} is disabled", + f"{component} is enabled, but should be disabled" ) - 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 + Report.result(gradient_components_disabled, not is_enabled(gradient.components[2])) + if not is_enabled(gradient.components[2]): 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() -test.run() + from editor_python_test_tools.utils import Report + Report.start_test(GradientTransform_ComponentIncompatibleWithExpectedGradients) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_ComponentIncompatibleWithSpawners.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_ComponentIncompatibleWithSpawners.py index 54270c5ee5..fd65996fdd 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_ComponentIncompatibleWithSpawners.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_ComponentIncompatibleWithSpawners.py @@ -5,104 +5,88 @@ For complete copyright and license terms please see the LICENSE at the root of t SPDX-License-Identifier: Apache-2.0 OR MIT """ -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 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: - 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 Open 3D Engine 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() +def GradientTransform_ComponentIncompatibleWithSpawners(): + """ + Summary: + 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. + + Expected Behavior: + The Vegetation Layer Spawner is deactivated and it is communicated that it is incompatible with Gradient + Transform Modifier + + Test Steps: + 1) Open a simple 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 Open 3D Engine 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 + """ + + 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): + return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair) + + # 1) Open an existing simple level + helper.init_idle() + helper.open_level("Physics", "Base") + + # 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)) + 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 + index = 0 + for component in components_to_add: + components_enabled = ( + f"{component} is enabled", + f"{component} is unexpectedly disabled" ) - 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() + Report.critical_result(components_enabled, is_enabled(gradient.components[index])) + index += 1 + + # 4) Add Vegetation Layer Spawner to the same entity + gradient.components.append(hydra.add_component("Vegetation Layer Spawner", gradient_id)) + + # 5) Make sure newly added component is disabled + spawner_component_disabled = ( + "Spawner component is disabled", + "Spawner component is unexpectedly enabled" + ) + Report.result(spawner_component_disabled, not is_enabled(gradient.components[2])) + + +if __name__ == "__main__": + + from editor_python_test_tools.utils import Report + Report.start_test(GradientTransform_ComponentIncompatibleWithSpawners) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange.py index 94647a0b6f..530503db86 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange.py @@ -5,87 +5,82 @@ For complete copyright and license terms please see the LICENSE at the root of t 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 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 Open 3D Engine 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() +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" + ) + + +def GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange(): + """ + 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 Open 3D Engine 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 + """ + + 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 + + # 1) Open an existing simple level + helper.init_idle() + helper.open_level("Physics", "Base") + + # 2) Create entity + entity_position = math.Vector3(125.0, 136.0, 32.0) + entity_id = editor.ToolsApplicationRequestBus( + bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId() + ) + Report.critical_result(Tests.entity_created, entity_id.IsValid()) + + # 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)) + Report.critical_result(Tests.components_added, len(entity.components) == 3) + + # 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") + Report.result(Tests.higher_zoom_value_set, curr_value == 10.0) + + +if __name__ == "__main__": + + from editor_python_test_tools.utils import Report + Report.start_test(GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_RequiresShape.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_RequiresShape.py index c9cfc225d1..09cce359d5 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_RequiresShape.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/GradientTransform_RequiresShape.py @@ -4,73 +4,71 @@ For complete copyright and license terms please see the LICENSE at the root of t 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 TestGradientTransformRequiresShape(EditorTestHelper): - def __init__(self): - EditorTestHelper.__init__(self, log_prefix="GradientTransformRequiresShape", args=["level"]) - - def run_test(self): - """ - Summary: - This test verifies that the Gradient Transform Modifier component is dependent on a shape component. - - Expected Result: - Gradient Transform Modifier component is disabled until a shape component is added to the entity. - - Test Steps: - 1) Open level - 2) Create a new entity with a Gradient Transform Modifier component - 3) Verify the component is disabled until a shape component is also added to the entity - - Note: - - This test file must be called from the Open 3D Engine 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 - """ - # 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() + + +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", + ) + + +def GradientTransform_RequiresShape(): + """ + Summary: + This test verifies that the Gradient Transform Modifier component is dependent on a shape component. + + Expected Result: + Gradient Transform Modifier component is disabled until a shape component is added to the entity. + + Test Steps: + 1) Open level + 2) Create a new entity with a Gradient Transform Modifier component + 3) Verify the component is disabled until a shape component is also added to the entity + + Note: + - This test file must be called from the Open 3D Engine 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 + """ + + 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 + + # Open an existing simple level + helper.init_idle() + helper.open_level("Physics", "Base") + + # 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) + Report.result(Tests.disabled_without_shape, not active) + + # 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) + Report.result(Tests.enabled_with_shape, active) + + +if __name__ == "__main__": + + from editor_python_test_tools.utils import Report + Report.start_test(GradientTransform_RequiresShape) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/ImageGradient_ProcessedImageAssignedSuccessfully.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/ImageGradient_ProcessedImageAssignedSuccessfully.py index 1063260550..42458665e1 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/ImageGradient_ProcessedImageAssignedSuccessfully.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/ImageGradient_ProcessedImageAssignedSuccessfully.py @@ -5,89 +5,91 @@ For complete copyright and license terms please see the LICENSE at the root of t 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 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 Open 3D Engine 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 = "image_grad_test_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", "image_grad_test_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() + +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" + ) + + +def ImageGradient_ProcessedImageAssignedSuccessfully(): + """ + 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) Open a 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 Open 3D Engine 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 + """ + + import os + + 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 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 + 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() + ) + Report.critical_result(Tests.image_gradient_entity_created, new_entity_id.IsValid()) + 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 = "image_grad_test_gsi.png" + base_image_path = os.path.join("AutomatedTesting", "Assets", "ImageGradients", base_image) + Report.critical_result(Tests.image_gradient_asset_found, os.path.isfile(base_image_path)) + + # 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") + 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 + Report.result(Tests.image_gradient_assigned, success) + + +if __name__ == "__main__": + + from editor_python_test_tools.utils import Report + Report.start_test(ImageGradient_ProcessedImageAssignedSuccessfully) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/ImageGradient_RequiresShape.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/ImageGradient_RequiresShape.py index 2c6ac8d15b..3b832d160a 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/ImageGradient_RequiresShape.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/EditorScripts/ImageGradient_RequiresShape.py @@ -4,74 +4,72 @@ For complete copyright and license terms please see the LICENSE at the root of t 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 TestImageGradientRequiresShape(EditorTestHelper): - def __init__(self): - EditorTestHelper.__init__(self, log_prefix="ImageGradientRequiresShape", args=["level"]) - - def run_test(self): - """ - Summary: - This test verifies that the Image Gradient component is dependent on a shape component. - - Expected Result: - Gradient Transform Modifier component is disabled until a shape component is added to the entity. - - Test Steps: - 1) Open level - 2) Create a new entity with a Image Gradient component - 3) Verify the component is disabled until a shape component is also added to the entity - - Note: - - This test file must be called from the Open 3D Engine 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 - """ - # 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() + + +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", + ) + + +def ImageGradient_RequiresShape(): + """ + Summary: + This test verifies that the Image Gradient component is dependent on a shape component. + + Expected Result: + Gradient Transform Modifier component is disabled until a shape component is added to the entity. + + Test Steps: + 1) Open level + 2) Create a new entity with a Image Gradient component + 3) Verify the component is disabled until a shape component is also added to the entity + + Note: + - This test file must be called from the Open 3D Engine 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 + """ + + 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 + + # Open an existing simple level + helper.init_idle() + helper.open_level("Physics", "Base") + + # 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) + Report.result(Tests.disabled_without_shape, not active) + + # 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) + Report.result(Tests.enabled_with_shape, active) + + +if __name__ == "__main__": + + from editor_python_test_tools.utils import Report + Report.start_test(ImageGradient_RequiresShape) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientSignal_Periodic.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientSignal_Periodic.py new file mode 100644 index 0000000000..21eecf642c --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientSignal_Periodic.py @@ -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) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientSignal_Periodic_Optimized.py b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientSignal_Periodic_Optimized.py new file mode 100644 index 0000000000..514504d324 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/gradient_signal/test_GradientSignal_Periodic_Optimized.py @@ -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