Atom Level component test support in editor_entity_utils.py and tests for level components (#6082)
* Level component helper and test cases for Atom Level components which currently crash Signed-off-by: Scott Murray <scottmur@amazon.com> * moved a close paren to end of previous line to match existing style Signed-off-by: Scott Murray <scottmur@amazon.com> * adding a forgotten import Signed-off-by: Scott Murray <scottmur@amazon.com> * minor refactor and prep for adding back the Display Mapper Game component test Signed-off-by: Scott Murray <scottmur@amazon.com> * putting Game compoenent Display Mapper test back with addition of setting property Enabled to true Signed-off-by: Scott Murray <scottmur@amazon.com> * typo in line fixed Test. bocomes Tests. Signed-off-by: Scott Murray <scottmur@amazon.com>monroegm-disable-blank-issue-2
parent
aa5563803f
commit
e3306f948f
@ -0,0 +1,109 @@
|
|||||||
|
"""
|
||||||
|
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 Level component addition success",
|
||||||
|
"UNDO Level component addition failed")
|
||||||
|
creation_redo = (
|
||||||
|
"REDO Level component addition success",
|
||||||
|
"REDO Level component addition failed")
|
||||||
|
diffuse_global_illumination_component = (
|
||||||
|
"Level has a Diffuse Global Illumination component",
|
||||||
|
"Level failed to find Diffuse Global Illumination component")
|
||||||
|
diffuse_global_illumination_quality = (
|
||||||
|
"Quality Level set",
|
||||||
|
"Quality Level could not be set")
|
||||||
|
enter_game_mode = (
|
||||||
|
"Entered game mode",
|
||||||
|
"Failed to enter game mode")
|
||||||
|
exit_game_mode = (
|
||||||
|
"Exited game mode",
|
||||||
|
"Couldn't exit game mode")
|
||||||
|
|
||||||
|
|
||||||
|
def AtomEditorComponentsLevel_DiffuseGlobalIllumination_AddedToEntity():
|
||||||
|
"""
|
||||||
|
Summary:
|
||||||
|
Tests the Diffuse Global Illumination level component can be added to the level entity and is stable.
|
||||||
|
|
||||||
|
Test setup:
|
||||||
|
- Wait for Editor idle loop.
|
||||||
|
- Open the "Base" level.
|
||||||
|
|
||||||
|
Expected Behavior:
|
||||||
|
The component can be added, used in game mode, and has accurate required components.
|
||||||
|
Creation and deletion undo/redo should also work.
|
||||||
|
|
||||||
|
Test Steps:
|
||||||
|
1) Add Diffuse Global Illumination level component to the level entity.
|
||||||
|
2) UNDO the level component addition.
|
||||||
|
3) REDO the level component addition.
|
||||||
|
4) Set Quality Level property to Low
|
||||||
|
5) Enter/Exit game mode.
|
||||||
|
6) Look for errors and asserts.
|
||||||
|
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
|
|
||||||
|
import azlmbr.legacy.general as general
|
||||||
|
|
||||||
|
from editor_python_test_tools.editor_entity_utils import EditorLevelEntity
|
||||||
|
from editor_python_test_tools.utils import Report, Tracer, TestHelper
|
||||||
|
from Atom.atom_utils.atom_constants import AtomComponentProperties, GLOBAL_ILLUMINATION_QUALITY
|
||||||
|
|
||||||
|
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. Add Diffuse Global Illumination level component to the level entity.
|
||||||
|
diffuse_global_illumination_component = EditorLevelEntity.add_component(
|
||||||
|
AtomComponentProperties.diffuse_global_illumination())
|
||||||
|
Report.critical_result(
|
||||||
|
Tests.diffuse_global_illumination_component,
|
||||||
|
EditorLevelEntity.has_component(AtomComponentProperties.diffuse_global_illumination()))
|
||||||
|
|
||||||
|
# 2. UNDO the level component addition.
|
||||||
|
# -> UNDO component addition.
|
||||||
|
general.undo()
|
||||||
|
general.idle_wait_frames(1)
|
||||||
|
Report.result(Tests.creation_undo,
|
||||||
|
not EditorLevelEntity.has_component(AtomComponentProperties.diffuse_global_illumination()))
|
||||||
|
|
||||||
|
# 3. REDO the level component addition.
|
||||||
|
# -> REDO component addition.
|
||||||
|
general.redo()
|
||||||
|
general.idle_wait_frames(1)
|
||||||
|
Report.result(Tests.creation_redo,
|
||||||
|
EditorLevelEntity.has_component(AtomComponentProperties.diffuse_global_illumination()))
|
||||||
|
|
||||||
|
# 4. Set Quality Level property to Low
|
||||||
|
diffuse_global_illumination_component.set_component_property_value(
|
||||||
|
AtomComponentProperties.diffuse_global_illumination('Quality Level', GLOBAL_ILLUMINATION_QUALITY['Low']))
|
||||||
|
quality = diffuse_global_illumination_component.get_component_property_value(
|
||||||
|
AtomComponentProperties.diffuse_global_illumination('Quality Level'))
|
||||||
|
Report.result(diffuse_global_illumination_quality, quality == GLOBAL_ILLUMINATION_QUALITY['Low'])
|
||||||
|
|
||||||
|
# 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. 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}")
|
||||||
|
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(AtomEditorComponentsLevel_DiffuseGlobalIllumination_AddedToEntity)
|
||||||
@ -0,0 +1,124 @@
|
|||||||
|
"""
|
||||||
|
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 level component addition success",
|
||||||
|
"UNDO level component addition failed")
|
||||||
|
creation_redo = (
|
||||||
|
"REDO Level component addition success",
|
||||||
|
"REDO Level component addition failed")
|
||||||
|
display_mapper_component = (
|
||||||
|
"Level has a Display Mapper component",
|
||||||
|
"Level failed to find Display Mapper component")
|
||||||
|
ldr_color_grading_lut = (
|
||||||
|
"LDR color Grading LUT asset set",
|
||||||
|
"LDR color Grading LUT asset could not be set")
|
||||||
|
enable_ldr_color_grading_lut = (
|
||||||
|
"Enable LDR color grading LUT set",
|
||||||
|
"Enable LDR color grading LUT could not be set")
|
||||||
|
enter_game_mode = (
|
||||||
|
"Entered game mode",
|
||||||
|
"Failed to enter game mode")
|
||||||
|
exit_game_mode = (
|
||||||
|
"Exited game mode",
|
||||||
|
"Couldn't exit game mode")
|
||||||
|
|
||||||
|
|
||||||
|
def AtomEditorComponentsLevel_DisplayMapper_AddedToEntity():
|
||||||
|
"""
|
||||||
|
Summary:
|
||||||
|
Tests the Display Mapper level component can be added to the level 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, and has accurate required components.
|
||||||
|
Creation and deletion undo/redo should also work.
|
||||||
|
|
||||||
|
Test Steps:
|
||||||
|
1) Add Display Mapper level component to the level entity.
|
||||||
|
2) UNDO the level component addition.
|
||||||
|
3) REDO the level component addition.
|
||||||
|
4) Set LDR color Grading LUT asset.
|
||||||
|
5) Set Enable LDR color grading LUT property True
|
||||||
|
6) Enter/Exit game mode.
|
||||||
|
7) Look for errors and asserts.
|
||||||
|
|
||||||
|
: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 EditorLevelEntity
|
||||||
|
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. Add Display Mapper level component to the level entity.
|
||||||
|
display_mapper_component = EditorLevelEntity.add_component(AtomComponentProperties.display_mapper())
|
||||||
|
Report.critical_result(
|
||||||
|
Tests.display_mapper_component,
|
||||||
|
EditorLevelEntity.has_component(AtomComponentProperties.display_mapper()))
|
||||||
|
|
||||||
|
# 2. UNDO the level component addition.
|
||||||
|
# -> UNDO component addition.
|
||||||
|
general.undo()
|
||||||
|
general.idle_wait_frames(1)
|
||||||
|
Report.result(Tests.creation_undo, not EditorLevelEntity.has_component(AtomComponentProperties.display_mapper()))
|
||||||
|
|
||||||
|
# 3. REDO the level component addition.
|
||||||
|
# -> REDO component addition.
|
||||||
|
general.redo()
|
||||||
|
general.idle_wait_frames(1)
|
||||||
|
Report.result(Tests.creation_redo, EditorLevelEntity.has_component(AtomComponentProperties.display_mapper()))
|
||||||
|
|
||||||
|
# 4. Set LDR color Grading LUT asset.
|
||||||
|
display_mapper_asset_path = os.path.join("TestData", "test.lightingpreset.azasset")
|
||||||
|
display_mapper_asset = Asset.find_asset_by_path(display_mapper_asset_path, False)
|
||||||
|
display_mapper_component.set_component_property_value(
|
||||||
|
AtomComponentProperties.display_mapper('LDR color Grading LUT'), display_mapper_asset.id)
|
||||||
|
Report.result(
|
||||||
|
Tests.ldr_color_grading_lut,
|
||||||
|
display_mapper_component.get_component_property_value(
|
||||||
|
AtomComponentProperties.display_mapper('LDR color Grading LUT')) == display_mapper_asset.id)
|
||||||
|
|
||||||
|
# 5. Set Enable LDR color grading LUT property True
|
||||||
|
display_mapper_component.set_component_property_value(
|
||||||
|
AtomComponentProperties.display_mapper('Enable LDR color grading LUT'), True)
|
||||||
|
Report.result(
|
||||||
|
Test.enable_ldr_color_grading_lut,
|
||||||
|
display_mapper_component.get_component_property_value(
|
||||||
|
AtomComponentProperties.display_mapper('Enable LDR color grading LUT')) is True)
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
# 7. 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}")
|
||||||
|
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(AtomEditorComponentsLevel_DisplayMapper_AddedToEntity)
|
||||||
Loading…
Reference in New Issue