From b000b5fab3247489d568e5d2b75f70d8a17cddd4 Mon Sep 17 00:00:00 2001 From: Neil Widmaier Date: Fri, 5 Nov 2021 12:38:57 -0700 Subject: [PATCH 1/4] Adding P0 HDRi Skybox test Signed-off-by: Neil Widmaier --- .../Gem/PythonTests/Atom/TestSuite_Main.py | 4 + ...ra_AtomEditorComponents_HDRiSkyboxAdded.py | 159 ++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_HDRiSkyboxAdded.py diff --git a/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Main.py b/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Main.py index 52e7ec993e..6fc18f9043 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Main.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Main.py @@ -53,6 +53,10 @@ class TestAutomation(EditorTestSuite): class AtomEditorComponents_HDRColorGradingAdded(EditorSharedTest): from Atom.tests import hydra_AtomEditorComponents_HDRColorGradingAdded as test_module + @pytest.mark.test_case_id("C32078116") + class AtomEditorComponents_HDRiSkyboxAdded(EditorSharedTest): + from Atom.tests import hydra_AtomEditorComponents_HDRiSkyboxAdded as test_module + @pytest.mark.test_case_id("C32078117") class AtomEditorComponents_LightAdded(EditorSharedTest): from Atom.tests import hydra_AtomEditorComponents_LightAdded as test_module diff --git a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_HDRiSkyboxAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_HDRiSkyboxAdded.py new file mode 100644 index 0000000000..92ac98f3ec --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_HDRiSkyboxAdded.py @@ -0,0 +1,159 @@ +""" +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 +""" + +class Tests: + creation_undo = ( + "UNDO Entity creation success", + "UNDO Entity creation failed") + creation_redo = ( + "REDO Entity creation success", + "REDO Entity creation failed") + hdri_skybox_entity_creation = ( + "HDRi Skybox successfully created", + "HDRi Skybox failed to be created") + hdri_skybox_entity_component_added = ( + "Entity has a HDRi Skybox component", + "Entity failed to find HDRi Skybox component") + enter_game_mode = ( + "Entered game mode", + "Failed to enter game mode") + exit_game_mode = ( + "Exited game mode", + "Couldn't exit game mode") + is_visible = ( + "Entity is visible", + "Entity was not visible") + is_hidden = ( + "Entity is hidden", + "Entity was not hidden") + entity_deleted = ( + "Entity deleted", + "Entity was not deleted") + deletion_undo = ( + "UNDO deletion success", + "UNDO deletion failed") + deletion_redo = ( + "REDO deletion success", + "REDO deletion failed") + + +def AtomEditorComponents_HDRiSkybox_AddedToEntity(): + """ + Summary: + Tests the HDRi Skybox component can be added to an entity and has the expected functionality. + + Test setup: + - Wait for Editor idle loop. + - Open the "Base" level. + + Expected Behavior: + The component can be added, used in game mode, hidden/shown, deleted, and has accurate required components. + Creation and deletion undo/redo should also work. + + Test Steps: + 1) Create a HDRi Skybox with no components. + 2) Add a HDRi Skybox component to HDRi Skybox. + 3) UNDO the entity creation and component addition. + 4) REDO the entity creation and component addition. + 5) Enter/Exit game mode. + 6) Test IsHidden. + 7) Test IsVisible. + 8) Delete HDRi Skybox. + 9) UNDO deletion. + 10) REDO deletion. + 11) Look for errors. + + :return: None + """ + + import azlmbr.legacy.general as general + + from editor_python_test_tools.editor_entity_utils import EditorEntity + from editor_python_test_tools.utils import Report, Tracer, TestHelper + from Atom.atom_utils.atom_constants import AtomComponentProperties + + with Tracer() as error_tracer: + # Test setup begins. + # Setup: Wait for Editor idle loop before executing Python hydra scripts then open "Base" level. + TestHelper.init_idle() + TestHelper.open_level("", "Base") + + # Test steps begin. + # 1. Create a HDRi Skybox with no components. + hdri_skybox_entity = EditorEntity.create_editor_entity( + AtomComponentProperties.hdri_skybox()) + Report.critical_result(Tests.hdri_skybox_entity_creation, + hdri_skybox_entity.exists()) + + # 2. Add a HDRi Skybox component to HDRi Skybox. + hdri_skybox_component = hdri_skybox_entity.add_component( + AtomComponentProperties.hdri_skybox()) + Report.critical_result( + Tests.hdri_skybox_entity_component_added, + hdri_skybox_entity.has_component(AtomComponentProperties.hdri_skybox())) + + # 3. UNDO the entity creation and component addition. + # -> UNDO component addition. + general.undo() + # -> UNDO naming entity. + general.undo() + # -> UNDO selecting entity. + general.undo() + # -> UNDO entity creation. + general.undo() + general.idle_wait_frames(1) + Report.result(Tests.creation_undo, not hdri_skybox_entity.exists()) + + # 4. REDO the entity creation and component addition. + # -> REDO entity creation. + general.redo() + # -> REDO selecting entity. + general.redo() + # -> REDO naming entity. + general.redo() + # -> REDO component addition. + general.redo() + general.idle_wait_frames(1) + Report.result(Tests.creation_redo, hdri_skybox_entity.exists()) + + # 5. Enter/Exit game mode. + TestHelper.enter_game_mode(Tests.enter_game_mode) + general.idle_wait_frames(1) + TestHelper.exit_game_mode(Tests.exit_game_mode) + + # 6. Test IsHidden. + hdri_skybox_entity.set_visibility_state(False) + Report.result(Tests.is_hidden, hdri_skybox_entity.is_hidden() is True) + + # 7. Test IsVisible. + hdri_skybox_entity.set_visibility_state(True) + general.idle_wait_frames(1) + Report.result(Tests.is_visible, hdri_skybox_entity.is_visible() is True) + + # 8. Delete hdri_skybox entity. + hdri_skybox_entity.delete() + Report.result(Tests.entity_deleted, not hdri_skybox_entity.exists()) + + # 9. UNDO deletion. + general.undo() + Report.result(Tests.deletion_undo, hdri_skybox_entity.exists()) + + # 10. REDO deletion. + general.redo() + Report.result(Tests.deletion_redo, not hdri_skybox_entity.exists()) + + # 11. Look for errors or asserts. + TestHelper.wait_for_condition(lambda: error_tracer.has_errors or error_tracer.has_asserts, 1.0) + for error_info in error_tracer.errors: + Report.info(f"Error: {error_info.filename} {error_info.function} | {error_info.message}") + for assert_info in error_tracer.asserts: + Report.info(f"Assert: {assert_info.filename} {assert_info.function} | {assert_info.message}") + + +if __name__ == "__main__": + from editor_python_test_tools.utils import Report + Report.start_test(AtomEditorComponents_HDRiSkybox_AddedToEntity) From c886996bd7b4ac7abb01a5208c51375001d050cd Mon Sep 17 00:00:00 2001 From: Neil Widmaier Date: Fri, 5 Nov 2021 14:15:11 -0700 Subject: [PATCH 2/4] fixing typos and formatting Signed-off-by: Neil Widmaier --- .../hydra_AtomEditorComponents_HDRiSkyboxAdded.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_HDRiSkyboxAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_HDRiSkyboxAdded.py index 92ac98f3ec..835026a135 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_HDRiSkyboxAdded.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_HDRiSkyboxAdded.py @@ -5,6 +5,7 @@ For complete copyright and license terms please see the LICENSE at the root of t SPDX-License-Identifier: Apache-2.0 OR MIT """ + class Tests: creation_undo = ( "UNDO Entity creation success", @@ -16,7 +17,7 @@ class Tests: "HDRi Skybox successfully created", "HDRi Skybox failed to be created") hdri_skybox_entity_component_added = ( - "Entity has a HDRi Skybox component", + "Entity has an HDRi Skybox component", "Entity failed to find HDRi Skybox component") enter_game_mode = ( "Entered game mode", @@ -55,8 +56,8 @@ def AtomEditorComponents_HDRiSkybox_AddedToEntity(): Creation and deletion undo/redo should also work. Test Steps: - 1) Create a HDRi Skybox with no components. - 2) Add a HDRi Skybox component to HDRi Skybox. + 1) Create an HDRi Skybox with no components. + 2) Add an HDRi Skybox component to HDRi Skybox. 3) UNDO the entity creation and component addition. 4) REDO the entity creation and component addition. 5) Enter/Exit game mode. @@ -83,13 +84,13 @@ def AtomEditorComponents_HDRiSkybox_AddedToEntity(): TestHelper.open_level("", "Base") # Test steps begin. - # 1. Create a HDRi Skybox with no components. + # 1. Create an HDRi Skybox with no components. hdri_skybox_entity = EditorEntity.create_editor_entity( AtomComponentProperties.hdri_skybox()) Report.critical_result(Tests.hdri_skybox_entity_creation, hdri_skybox_entity.exists()) - # 2. Add a HDRi Skybox component to HDRi Skybox. + # 2. Add an HDRi Skybox component to HDRi Skybox. hdri_skybox_component = hdri_skybox_entity.add_component( AtomComponentProperties.hdri_skybox()) Report.critical_result( From 9d656005c48b85778d26e048539c03e5b555fe80 Mon Sep 17 00:00:00 2001 From: Neil Widmaier Date: Fri, 5 Nov 2021 14:48:15 -0700 Subject: [PATCH 3/4] Adding fmt comments Signed-off-by: Neil Widmaier --- .../tests/hydra_AtomEditorComponents_HDRiSkyboxAdded.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_HDRiSkyboxAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_HDRiSkyboxAdded.py index 835026a135..0576de0a62 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_HDRiSkyboxAdded.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_HDRiSkyboxAdded.py @@ -6,6 +6,9 @@ SPDX-License-Identifier: Apache-2.0 OR MIT """ +#fmt: off + + class Tests: creation_undo = ( "UNDO Entity creation success", @@ -42,6 +45,9 @@ class Tests: "REDO deletion failed") +#fmt: on + + def AtomEditorComponents_HDRiSkybox_AddedToEntity(): """ Summary: From 98f589745b1aa6a911b49812c7ec920f8b52f2fe Mon Sep 17 00:00:00 2001 From: Neil Widmaier Date: Fri, 12 Nov 2021 10:55:52 -0800 Subject: [PATCH 4/4] Adding step to assign a cubemap Signed-off-by: Neil Widmaier --- .../Gem/PythonTests/Atom/TestSuite_Main.py | 16 ++++++++ ...ra_AtomEditorComponents_HDRiSkyboxAdded.py | 41 ++++++++++++------- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Main.py b/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Main.py index 6fc18f9043..b4de39ae98 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Main.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Main.py @@ -29,6 +29,10 @@ class TestAutomation(EditorTestSuite): class AtomEditorComponents_DepthOfFieldAdded(EditorSharedTest): from Atom.tests import hydra_AtomEditorComponents_DepthOfFieldAdded as test_module + @pytest.mark.test_case_id("C36525659") + class AtomEditorComponents_DiffuseProbeGridAdded(EditorSharedTest): + from Atom.tests import hydra_AtomEditorComponents_DiffuseProbeGridAdded as test_module + @pytest.mark.test_case_id("C32078120") class AtomEditorComponents_DirectionalLightAdded(EditorSharedTest): from Atom.tests import hydra_AtomEditorComponents_DirectionalLightAdded as test_module @@ -37,6 +41,10 @@ class TestAutomation(EditorTestSuite): class AtomEditorComponents_DisplayMapperAdded(EditorSharedTest): from Atom.tests import hydra_AtomEditorComponents_DisplayMapperAdded as test_module + @pytest.mark.test_case_id("C36525661") + class AtomEditorComponents_EntityReferenceAdded(EditorSharedTest): + from Atom.tests import hydra_AtomEditorComponents_EntityReferenceAdded as test_module + @pytest.mark.test_case_id("C32078121") class AtomEditorComponents_ExposureControlAdded(EditorSharedTest): from Atom.tests import hydra_AtomEditorComponents_ExposureControlAdded as test_module @@ -61,6 +69,10 @@ class TestAutomation(EditorTestSuite): class AtomEditorComponents_LightAdded(EditorSharedTest): from Atom.tests import hydra_AtomEditorComponents_LightAdded as test_module + @pytest.mark.test_case_id("C36525662") + class AtomEditorComponents_LookModificationAdded(EditorSharedTest): + from Atom.tests import hydra_AtomEditorComponents_LookModificationAdded as test_module + @pytest.mark.test_case_id("C32078123") class AtomEditorComponents_MaterialAdded(EditorSharedTest): from Atom.tests import hydra_AtomEditorComponents_MaterialAdded as test_module @@ -98,5 +110,9 @@ class TestAutomation(EditorTestSuite): class AtomEditorComponents_ReflectionProbeAdded(EditorSharedTest): from Atom.tests import hydra_AtomEditorComponents_ReflectionProbeAdded as test_module + @pytest.mark.test_case_id("C36525666") + class AtomEditorComponents_SSAOAdded(EditorSharedTest): + from Atom.tests import hydra_AtomEditorComponents_SSAOAdded as test_module + class ShaderAssetBuilder_RecompilesShaderAsChainOfDependenciesChanges(EditorSharedTest): from Atom.tests import hydra_ShaderAssetBuilder_RecompilesShaderAsChainOfDependenciesChanges as test_module diff --git a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_HDRiSkyboxAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_HDRiSkyboxAdded.py index 0576de0a62..0f96bc5424 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_HDRiSkyboxAdded.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_HDRiSkyboxAdded.py @@ -6,9 +6,6 @@ SPDX-License-Identifier: Apache-2.0 OR MIT """ -#fmt: off - - class Tests: creation_undo = ( "UNDO Entity creation success", @@ -19,9 +16,12 @@ class Tests: hdri_skybox_entity_creation = ( "HDRi Skybox successfully created", "HDRi Skybox failed to be created") - hdri_skybox_entity_component_added = ( + hdri_skybox_component = ( "Entity has an HDRi Skybox component", "Entity failed to find HDRi Skybox component") + cubemap_property_set = ( + "Cubemap property set on HDRi Skybox component", + "Couldn't set Cubemap property on HDRi Skybox component") enter_game_mode = ( "Entered game mode", "Failed to enter game mode") @@ -45,9 +45,6 @@ class Tests: "REDO deletion failed") -#fmt: on - - def AtomEditorComponents_HDRiSkybox_AddedToEntity(): """ Summary: @@ -77,8 +74,11 @@ def AtomEditorComponents_HDRiSkybox_AddedToEntity(): :return: None """ + import os + import azlmbr.legacy.general as general + from editor_python_test_tools.asset_utils import Asset from editor_python_test_tools.editor_entity_utils import EditorEntity from editor_python_test_tools.utils import Report, Tracer, TestHelper from Atom.atom_utils.atom_constants import AtomComponentProperties @@ -100,7 +100,7 @@ def AtomEditorComponents_HDRiSkybox_AddedToEntity(): hdri_skybox_component = hdri_skybox_entity.add_component( AtomComponentProperties.hdri_skybox()) Report.critical_result( - Tests.hdri_skybox_entity_component_added, + Tests.hdri_skybox_component, hdri_skybox_entity.has_component(AtomComponentProperties.hdri_skybox())) # 3. UNDO the entity creation and component addition. @@ -127,33 +127,44 @@ def AtomEditorComponents_HDRiSkybox_AddedToEntity(): general.idle_wait_frames(1) Report.result(Tests.creation_redo, hdri_skybox_entity.exists()) - # 5. Enter/Exit game mode. + + # 5. Set Cubemap Texture on HDRi Skybox component. + skybox_cubemap_asset_path = os.path.join("LightingPresets", "default_iblskyboxcm.exr.streamingimage") + skybox_cubemap_material_asset = Asset.find_asset_by_path(skybox_cubemap_asset_path, False) + hdri_skybox_component.set_component_property_value( + AtomComponentProperties.hdri_skybox('Cubemap Texture'), skybox_cubemap_material_asset.id) + get_cubemap_property = hdri_skybox_component.get_component_property_value( + AtomComponentProperties.hdri_skybox('Cubemap Texture')) + Report.result(Tests.cubemap_property_set, get_cubemap_property == skybox_cubemap_material_asset.id) + + + # 6. Enter/Exit game mode. TestHelper.enter_game_mode(Tests.enter_game_mode) general.idle_wait_frames(1) TestHelper.exit_game_mode(Tests.exit_game_mode) - # 6. Test IsHidden. + # 7. Test IsHidden. hdri_skybox_entity.set_visibility_state(False) Report.result(Tests.is_hidden, hdri_skybox_entity.is_hidden() is True) - # 7. Test IsVisible. + # 8. Test IsVisible. hdri_skybox_entity.set_visibility_state(True) general.idle_wait_frames(1) Report.result(Tests.is_visible, hdri_skybox_entity.is_visible() is True) - # 8. Delete hdri_skybox entity. + # 9. Delete hdri_skybox entity. hdri_skybox_entity.delete() Report.result(Tests.entity_deleted, not hdri_skybox_entity.exists()) - # 9. UNDO deletion. + # 10. UNDO deletion. general.undo() Report.result(Tests.deletion_undo, hdri_skybox_entity.exists()) - # 10. REDO deletion. + # 11. REDO deletion. general.redo() Report.result(Tests.deletion_redo, not hdri_skybox_entity.exists()) - # 11. Look for errors or asserts. + # 12. Look for errors or asserts. TestHelper.wait_for_condition(lambda: error_tracer.has_errors or error_tracer.has_asserts, 1.0) for error_info in error_tracer.errors: Report.info(f"Error: {error_info.filename} {error_info.function} | {error_info.message}")