From f1ad9ef0b8a3354f5b9d3dcf60d5d3ed507d88de Mon Sep 17 00:00:00 2001 From: Neil Widmaier Date: Fri, 28 Jan 2022 12:19:27 -0800 Subject: [PATCH] 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}")