From f1ad9ef0b8a3354f5b9d3dcf60d5d3ed507d88de Mon Sep 17 00:00:00 2001 From: Neil Widmaier Date: Fri, 28 Jan 2022 12:19:27 -0800 Subject: [PATCH 1/4] Updated Light, Grid, and Physical Sky P0 tests Signed-off-by: Neil Widmaier --- .../Atom/atom_utils/atom_constants.py | 4 ++ .../hydra_AtomEditorComponents_GridAdded.py | 25 +++++++---- .../hydra_AtomEditorComponents_LightAdded.py | 41 ++++++++++++------- ...a_AtomEditorComponents_PhysicalSkyAdded.py | 39 +++++++++++------- 4 files changed, 73 insertions(+), 36 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/Atom/atom_utils/atom_constants.py b/AutomatedTesting/Gem/PythonTests/Atom/atom_utils/atom_constants.py index 339108090f..00b76c3215 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/atom_utils/atom_constants.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/atom_utils/atom_constants.py @@ -242,12 +242,14 @@ class AtomComponentProperties: def grid(property: str = 'name') -> str: """ Grid component properties. + - 'Grid Size': The size of the grid, default value is 32 - 'Secondary Grid Spacing': The spacing value for the secondary grid, i.e. 1.0 :param property: From the last element of the property tree path. Default 'name' for component name string. :return: Full property path OR component name if no property specified. """ properties = { 'name': 'Grid', + 'Grid Size': 'Controller|Configuration|Grid Size', 'Secondary Grid Spacing': 'Controller|Configuration|Secondary Grid Spacing', } return properties[property] @@ -378,11 +380,13 @@ class AtomComponentProperties: def physical_sky(property: str = 'name') -> str: """ Physical Sky component properties. + - 'Sky Intensity' float that determines sky intensity value, default value is 4. :param property: From the last element of the property tree path. Default 'name' for component name string. :return: Full property path OR component name if no property specified. """ properties = { 'name': 'Physical Sky', + 'Sky Intensity': 'Controller|Configuration|Sky Intensity', } return properties[property] diff --git a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_GridAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_GridAdded.py index 3c6d261f22..c4da2fd71c 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_GridAdded.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_GridAdded.py @@ -18,6 +18,9 @@ class Tests: grid_component_added = ( "Entity has a Grid component", "Entity failed to find Grid component") + grid_size = ( + "Grid Size value set successfully", + "Grid Size value could not be set") enter_game_mode = ( "Entered game mode", "Failed to enter game mode") @@ -59,6 +62,7 @@ def AtomEditorComponents_Grid_AddedToEntity(): 2) Add a Grid component to Grid entity. 3) UNDO the entity creation and component addition. 4) REDO the entity creation and component addition. + 5) Grid Size changed. 5) Enter/Exit game mode. 6) Test IsHidden. 7) Test IsVisible. @@ -119,35 +123,42 @@ def AtomEditorComponents_Grid_AddedToEntity(): general.idle_wait_frames(1) Report.result(Tests.creation_redo, grid_entity.exists()) - # 5. Enter/Exit game mode. + # 5. Grid Size changed (default is 32, changed to 64) + grid_component.set_component_property_value( + AtomComponentProperties.grid('Grid Size'), 64) + current_grid_size = grid_component.get_component_property_value( + AtomComponentProperties.grid('Grid Size')) + Report.result(Tests.grid_size, current_grid_size == 64) + + # 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. grid_entity.set_visibility_state(False) Report.result(Tests.is_hidden, grid_entity.is_hidden() is True) - # 7. Test IsVisible. + # 8. Test IsVisible. grid_entity.set_visibility_state(True) general.idle_wait_frames(1) Report.result(Tests.is_visible, grid_entity.is_visible() is True) - # 8. Delete Grid entity. + # 9. Delete Grid entity. grid_entity.delete() Report.result(Tests.entity_deleted, not grid_entity.exists()) - # 9. UNDO deletion. + # 10. UNDO deletion. general.undo() general.idle_wait_frames(1) Report.result(Tests.deletion_undo, grid_entity.exists()) - # 10. REDO deletion. + # 11. REDO deletion. general.redo() general.idle_wait_frames(1) Report.result(Tests.deletion_redo, not grid_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}") diff --git a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_LightAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_LightAdded.py index 75a04612a3..f7c789c151 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_LightAdded.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_LightAdded.py @@ -27,6 +27,9 @@ class Tests: light_component = ( "Entity has a Light component", "Entity failed to find Light component") + light_type_value = ( + "Light type value set", + "Light type value could not be set") enter_game_mode = ( "Entered game mode", "Failed to enter game mode") @@ -68,13 +71,14 @@ def AtomEditorComponents_Light_AddedToEntity(): 2) Add Light component to the Light entity. 3) UNDO the entity creation and component addition. 4) REDO the entity creation and component addition. - 5) Enter/Exit game mode. - 6) Test IsHidden. - 7) Test IsVisible. - 8) Delete Light entity. - 9) UNDO deletion. - 10) REDO deletion. - 11) Look for errors. + 5) Set the light type to sphere. + 6) Enter/Exit game mode. + 7) Test IsHidden. + 8) Test IsVisible. + 9) Delete Light entity. + 10) UNDO deletion. + 11) REDO deletion. + 12) Look for errors. :return: None """ @@ -83,7 +87,7 @@ def AtomEditorComponents_Light_AddedToEntity(): 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 + from Atom.atom_utils.atom_constants import AtomComponentProperties, LIGHT_TYPES with Tracer() as error_tracer: # Test setup begins. @@ -124,35 +128,42 @@ def AtomEditorComponents_Light_AddedToEntity(): general.idle_wait_frames(1) Report.result(Tests.creation_redo, light_entity.exists()) - # 5. Enter/Exit game mode. + # 5. Set the light type to sphere + light_component.set_component_property_value( + AtomComponentProperties.light('Light type'), LIGHT_TYPES['sphere']) + current_light_type = light_component.get_component_property_value( + AtomComponentProperties.light('Light type')) + Report.result(Tests.light_type_value, current_light_type == LIGHT_TYPES['sphere']) + + # 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. light_entity.set_visibility_state(False) Report.result(Tests.is_hidden, light_entity.is_hidden() is True) - # 7. Test IsVisible. + # 8. Test IsVisible. light_entity.set_visibility_state(True) general.idle_wait_frames(1) Report.result(Tests.is_visible, light_entity.is_visible() is True) - # 8. Delete Light entity. + # 9. Delete Light entity. light_entity.delete() Report.result(Tests.entity_deleted, not light_entity.exists()) - # 9. UNDO deletion. + # 10. UNDO deletion. general.undo() general.idle_wait_frames(1) Report.result(Tests.deletion_undo, light_entity.exists()) - # 10. REDO deletion. + # 11. REDO deletion. general.redo() general.idle_wait_frames(1) Report.result(Tests.deletion_redo, not light_entity.exists()) - # 11. Look for errors asserts. + # 12. Look for errors 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}") diff --git a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_PhysicalSkyAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_PhysicalSkyAdded.py index e0c558811e..1f53a8c850 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_PhysicalSkyAdded.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_PhysicalSkyAdded.py @@ -27,6 +27,9 @@ class Tests: physical_sky_component = ( "Entity has a Physical Sky component", "Entity failed to find Physical Sky component") + sky_intensity = ( + "Sky Intensity value set to 2", + "Sky Intensity value could not be set") enter_game_mode = ( "Entered game mode", "Failed to enter game mode") @@ -68,13 +71,14 @@ def AtomEditorComponents_PhysicalSky_AddedToEntity(): 2) Add Physical Sky component to Physical Sky entity. 3) UNDO the entity creation and component addition. 4) REDO the entity creation and component addition. - 5) Enter/Exit game mode. - 6) Test IsHidden. - 7) Test IsVisible. - 8) Delete Physical Sky entity. - 9) UNDO deletion. - 10) REDO deletion. - 11) Look for errors and asserts. + 5) Set Sky Intensity to a value of 2. + 6) Enter/Exit game mode. + 7) Test IsHidden. + 8) Test IsVisible. + 9) Delete Physical Sky entity. + 10) UNDO deletion. + 11) REDO deletion. + 12) Look for errors and asserts. :return: None """ @@ -126,35 +130,42 @@ def AtomEditorComponents_PhysicalSky_AddedToEntity(): general.idle_wait_frames(1) Report.result(Tests.creation_redo, physical_sky_entity.exists()) - # 5. Enter/Exit game mode. + # 5. Set Sky Intensity to a value of 2 (default value is 4) + physical_sky_component.set_component_property_value( + AtomComponentProperties.physical_sky('Sky Intensity'), 2) + current_sky_intensity = physical_sky_component.get_component_property_value( + AtomComponentProperties.physical_sky('Sky Intensity')) + Report.result(Tests.sky_intensity, current_sky_intensity == 2) + + # 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. physical_sky_entity.set_visibility_state(False) Report.result(Tests.is_hidden, physical_sky_entity.is_hidden() is True) - # 7. Test IsVisible. + # 8. Test IsVisible. physical_sky_entity.set_visibility_state(True) general.idle_wait_frames(1) Report.result(Tests.is_visible, physical_sky_entity.is_visible() is True) - # 8. Delete Physical Sky entity. + # 9. Delete Physical Sky entity. physical_sky_entity.delete() Report.result(Tests.entity_deleted, not physical_sky_entity.exists()) - # 9. UNDO deletion. + # 10. UNDO deletion. general.undo() general.idle_wait_frames(1) Report.result(Tests.deletion_undo, physical_sky_entity.exists()) - # 10. REDO deletion. + # 11. REDO deletion. general.redo() general.idle_wait_frames(1) Report.result(Tests.deletion_redo, not physical_sky_entity.exists()) - # 11. Look for errors and asserts. + # 12. Look for errors and 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}") From 342b1ee47c8024260b89d68998aeee8ee2f88477 Mon Sep 17 00:00:00 2001 From: Neil Widmaier Date: Fri, 28 Jan 2022 12:44:04 -0800 Subject: [PATCH 2/4] minor update Signed-off-by: Neil Widmaier --- .../Atom/tests/hydra_AtomEditorComponents_GridAdded.py | 2 +- .../Atom/tests/hydra_AtomEditorComponents_PhysicalSkyAdded.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_GridAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_GridAdded.py index c4da2fd71c..31061f1044 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_GridAdded.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_GridAdded.py @@ -125,7 +125,7 @@ def AtomEditorComponents_Grid_AddedToEntity(): # 5. Grid Size changed (default is 32, changed to 64) grid_component.set_component_property_value( - AtomComponentProperties.grid('Grid Size'), 64) + AtomComponentProperties.grid('Grid Size'), value=64) current_grid_size = grid_component.get_component_property_value( AtomComponentProperties.grid('Grid Size')) Report.result(Tests.grid_size, current_grid_size == 64) diff --git a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_PhysicalSkyAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_PhysicalSkyAdded.py index 1f53a8c850..39dd0d15a5 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_PhysicalSkyAdded.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_PhysicalSkyAdded.py @@ -132,7 +132,7 @@ def AtomEditorComponents_PhysicalSky_AddedToEntity(): # 5. Set Sky Intensity to a value of 2 (default value is 4) physical_sky_component.set_component_property_value( - AtomComponentProperties.physical_sky('Sky Intensity'), 2) + AtomComponentProperties.physical_sky('Sky Intensity'), value=2) current_sky_intensity = physical_sky_component.get_component_property_value( AtomComponentProperties.physical_sky('Sky Intensity')) Report.result(Tests.sky_intensity, current_sky_intensity == 2) From 4aa5ba4eca245fcc177bdd799c4a92c448a4ec59 Mon Sep 17 00:00:00 2001 From: Neil Widmaier Date: Mon, 31 Jan 2022 15:08:03 -0800 Subject: [PATCH 3/4] Making minor fixes, and cycling through light types Signed-off-by: Neil Widmaier --- .../hydra_AtomEditorComponents_GridAdded.py | 16 +++++++------- .../hydra_AtomEditorComponents_LightAdded.py | 21 ++++++++++--------- ...a_AtomEditorComponents_PhysicalSkyAdded.py | 6 +++--- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_GridAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_GridAdded.py index 31061f1044..3a58ec80b1 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_GridAdded.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_GridAdded.py @@ -63,13 +63,13 @@ def AtomEditorComponents_Grid_AddedToEntity(): 3) UNDO the entity creation and component addition. 4) REDO the entity creation and component addition. 5) Grid Size changed. - 5) Enter/Exit game mode. - 6) Test IsHidden. - 7) Test IsVisible. - 8) Delete Grid entity. - 9) UNDO deletion. - 10) REDO deletion. - 11) Look for errors. + 6) Enter/Exit game mode. + 7) Test IsHidden. + 8) Test IsVisible. + 9) Delete Grid entity. + 10) UNDO deletion. + 11) REDO deletion. + 12) Look for errors. :return: None """ @@ -123,7 +123,7 @@ def AtomEditorComponents_Grid_AddedToEntity(): general.idle_wait_frames(1) Report.result(Tests.creation_redo, grid_entity.exists()) - # 5. Grid Size changed (default is 32, changed to 64) + # 5. Grid Size changed grid_component.set_component_property_value( AtomComponentProperties.grid('Grid Size'), value=64) current_grid_size = grid_component.get_component_property_value( diff --git a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_LightAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_LightAdded.py index f7c789c151..f0dfd32b81 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_LightAdded.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_LightAdded.py @@ -27,9 +27,6 @@ class Tests: light_component = ( "Entity has a Light component", "Entity failed to find Light component") - light_type_value = ( - "Light type value set", - "Light type value could not be set") enter_game_mode = ( "Entered game mode", "Failed to enter game mode") @@ -71,7 +68,7 @@ def AtomEditorComponents_Light_AddedToEntity(): 2) Add Light component to the Light entity. 3) UNDO the entity creation and component addition. 4) REDO the entity creation and component addition. - 5) Set the light type to sphere. + 5) Cycle through all light types. 6) Enter/Exit game mode. 7) Test IsHidden. 8) Test IsVisible. @@ -128,12 +125,16 @@ def AtomEditorComponents_Light_AddedToEntity(): general.idle_wait_frames(1) Report.result(Tests.creation_redo, light_entity.exists()) - # 5. Set the light type to sphere - light_component.set_component_property_value( - AtomComponentProperties.light('Light type'), LIGHT_TYPES['sphere']) - current_light_type = light_component.get_component_property_value( - AtomComponentProperties.light('Light type')) - Report.result(Tests.light_type_value, current_light_type == LIGHT_TYPES['sphere']) + # 5. Cycle through all light types. + for ltype, value in LIGHT_TYPES.items(): + light_component.set_component_property_value( + AtomComponentProperties.light('Light type'), LIGHT_TYPES[ltype]) + current_light_type = light_component.get_component_property_value( + AtomComponentProperties.light('Light type')) + test_shape = ( + f"Light component has {ltype} type set", + f"Light component failed to set {ltype} type") + Report.result(test_shape, current_light_type == LIGHT_TYPES[ltype]) # 6. Enter/Exit game mode. TestHelper.enter_game_mode(Tests.enter_game_mode) diff --git a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_PhysicalSkyAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_PhysicalSkyAdded.py index 39dd0d15a5..1970e38d83 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_PhysicalSkyAdded.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_PhysicalSkyAdded.py @@ -28,7 +28,7 @@ class Tests: "Entity has a Physical Sky component", "Entity failed to find Physical Sky component") sky_intensity = ( - "Sky Intensity value set to 2", + "Sky Intensity value updated successfully", "Sky Intensity value could not be set") enter_game_mode = ( "Entered game mode", @@ -71,7 +71,7 @@ def AtomEditorComponents_PhysicalSky_AddedToEntity(): 2) Add Physical Sky component to Physical Sky entity. 3) UNDO the entity creation and component addition. 4) REDO the entity creation and component addition. - 5) Set Sky Intensity to a value of 2. + 5) Update Sky Intensity value. 6) Enter/Exit game mode. 7) Test IsHidden. 8) Test IsVisible. @@ -130,7 +130,7 @@ def AtomEditorComponents_PhysicalSky_AddedToEntity(): general.idle_wait_frames(1) Report.result(Tests.creation_redo, physical_sky_entity.exists()) - # 5. Set Sky Intensity to a value of 2 (default value is 4) + # 5. Set Sky Intensity value physical_sky_component.set_component_property_value( AtomComponentProperties.physical_sky('Sky Intensity'), value=2) current_sky_intensity = physical_sky_component.get_component_property_value( From 57ab6d5e7c2ff73b7aa8e2e5db44998a2726e624 Mon Sep 17 00:00:00 2001 From: Neil Widmaier Date: Wed, 2 Feb 2022 15:08:54 -0800 Subject: [PATCH 4/4] making minor variable name changes Signed-off-by: Neil Widmaier --- .../tests/hydra_AtomEditorComponents_LightAdded.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_LightAdded.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_LightAdded.py index f0dfd32b81..d036147eb7 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_LightAdded.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomEditorComponents_LightAdded.py @@ -126,15 +126,15 @@ def AtomEditorComponents_Light_AddedToEntity(): Report.result(Tests.creation_redo, light_entity.exists()) # 5. Cycle through all light types. - for ltype, value in LIGHT_TYPES.items(): + for light_type in LIGHT_TYPES.keys(): light_component.set_component_property_value( - AtomComponentProperties.light('Light type'), LIGHT_TYPES[ltype]) + AtomComponentProperties.light('Light type'), LIGHT_TYPES[light_type]) current_light_type = light_component.get_component_property_value( AtomComponentProperties.light('Light type')) - test_shape = ( - f"Light component has {ltype} type set", - f"Light component failed to set {ltype} type") - Report.result(test_shape, current_light_type == LIGHT_TYPES[ltype]) + test_light_type = ( + f"Light component has {light_type} type set", + f"Light component failed to set {light_type} type") + Report.result(test_light_type, current_light_type == LIGHT_TYPES[light_type]) # 6. Enter/Exit game mode. TestHelper.enter_game_mode(Tests.enter_game_mode)