Merge branch 'development' of https://github.com/aws-lumberyard/o3de into Neil_P0_updates

This commit is contained in:
Neil Widmaier
2022-02-02 15:10:21 -08:00
1599 changed files with 42153 additions and 96220 deletions
@@ -87,12 +87,18 @@ class AtomComponentProperties:
def decal(property: str = 'name') -> str:
"""
Decal component properties.
- 'Attenuation Angle' controls how much the angle between geometry and decal impacts opacity. 0-1 Radians
- 'Opacity' where one is opaque and zero is transparent
- 'Sort Key' 0-255 stacking z-sort like key to define which decal is on top of another
- 'Material' the material Asset.id of the decal.
: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': 'Decal',
'Attenuation Angle': 'Controller|Configuration|Attenuation Angle',
'Opacity': 'Controller|Configuration|Opacity',
'Sort Key': 'Controller|Configuration|Sort Key',
'Material': 'Controller|Configuration|Material',
}
return properties[property]
@@ -8,49 +8,61 @@ SPDX-License-Identifier: Apache-2.0 OR MIT
class Tests:
camera_creation = (
"Camera Entity successfully created",
"Camera Entity failed to be created")
"P0: Camera Entity failed to be created")
camera_component_added = (
"Camera component was added to entity",
"Camera component failed to be added to entity")
"P0: Camera component failed to be added to entity")
camera_component_check = (
"Entity has a Camera component",
"Entity failed to find Camera component")
"P0: Entity failed to find Camera component")
creation_undo = (
"UNDO Entity creation success",
"UNDO Entity creation failed")
"P0: UNDO Entity creation failed")
creation_redo = (
"REDO Entity creation success",
"REDO Entity creation failed")
"P0: REDO Entity creation failed")
decal_creation = (
"Decal Entity successfully created",
"Decal Entity failed to be created")
"P0: Decal Entity failed to be created")
decal_component = (
"Entity has a Decal component",
"Entity failed to find Decal component")
"P0: Entity failed to find Decal component")
decal_component_removed = (
"Decal component removed",
"P0: Decal component failed to be removed")
material_property_set = (
"Material property set on Decal component",
"Couldn't set Material property on Decal component")
"P0: Couldn't set Material property on Decal component")
attenuation_property_set = (
"Attenuation Angle property set on Decal component",
"P1: Couldn't set Attenuation Angle property on Decal component")
opacity_property_set = (
"Opacity property set on Decal component",
"P1: Coudn't set Opacity property on Decal component")
sort_key_property_set = (
"Sort Key property set on Decal component",
"P1: Couldn't set Sort Key property on Decal component")
enter_game_mode = (
"Entered game mode",
"Failed to enter game mode")
"P0: Failed to enter game mode")
exit_game_mode = (
"Exited game mode",
"Couldn't exit game mode")
"P0: Couldn't exit game mode")
is_visible = (
"Entity is visible",
"Entity was not visible")
"P0: Entity was not visible")
is_hidden = (
"Entity is hidden",
"Entity was not hidden")
"P0: Entity was not hidden")
entity_deleted = (
"Entity deleted",
"Entity was not deleted")
"P0: Entity was not deleted")
deletion_undo = (
"UNDO deletion success",
"UNDO deletion failed")
"P0: UNDO deletion failed")
deletion_redo = (
"REDO deletion success",
"REDO deletion failed")
"P0: REDO deletion failed")
def AtomEditorComponents_Decal_AddedToEntity():
@@ -71,14 +83,18 @@ def AtomEditorComponents_Decal_AddedToEntity():
2) Add Decal component to Decal 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) Set Material property on Decal component.
9) Delete Decal entity.
10) UNDO deletion.
11) REDO deletion.
12) Look for errors and asserts.
5) Set Material property on Decal component.
6) Set Attenuation Angle property on Decal component.
7) Set Opacity property on Decal component
8) Set Sort Key property on Decal Component
9) Remove Decal component then UNDO the remove
10) Enter/Exit game mode.
11) Test IsHidden.
12) Test IsVisible.
13) Delete Decal entity.
14) UNDO deletion.
15) REDO deletion.
16) Look for errors and asserts.
:return: None
"""
@@ -130,42 +146,69 @@ def AtomEditorComponents_Decal_AddedToEntity():
general.idle_wait_frames(1)
Report.result(Tests.creation_redo, decal_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.
decal_entity.set_visibility_state(False)
Report.result(Tests.is_hidden, decal_entity.is_hidden() is True)
# 7. Test IsVisible.
decal_entity.set_visibility_state(True)
general.idle_wait_frames(1)
Report.result(Tests.is_visible, decal_entity.is_visible() is True)
# 8. Set Material property on Decal component.
decal_material_asset_path = os.path.join("materials", "basic_grey.azmaterial")
# 5. Set Material property on Decal component.
decal_material_asset_path = os.path.join("materials", "decal", "airship_symbol_decal.azmaterial")
decal_material_asset = Asset.find_asset_by_path(decal_material_asset_path, False)
decal_component.set_component_property_value(AtomComponentProperties.decal('Material'), decal_material_asset.id)
get_material_property = decal_component.get_component_property_value(AtomComponentProperties.decal('Material'))
Report.result(Tests.material_property_set, get_material_property == decal_material_asset.id)
# 9. Delete Decal entity.
# 6. Set Attenuation Angle property on Decal component
decal_component.set_component_property_value(AtomComponentProperties.decal('Attenuation Angle'), value=0.75)
get_attenuation_property = decal_component.get_component_property_value(
AtomComponentProperties.decal('Attenuation Angle'))
Report.result(Tests.attenuation_property_set, get_attenuation_property == 0.75)
# 7. Set Opacity property on Decal component
decal_component.set_component_property_value(AtomComponentProperties.decal('Opacity'), value=0.5)
get_opacity_property = decal_component.get_component_property_value(AtomComponentProperties.decal('Opacity'))
Report.result(Tests.opacity_property_set, get_opacity_property == 0.5)
# 8. Set Sort Key property on Decal component
decal_component.set_component_property_value(AtomComponentProperties.decal('Sort Key'), value=255.0)
get_sort_key_property = decal_component.get_component_property_value(AtomComponentProperties.decal('Sort Key'))
Report.result(Tests.sort_key_property_set, get_sort_key_property == 255.0)
decal_component.set_component_property_value(AtomComponentProperties.decal('Sort Key'), value=0)
get_sort_key_property = decal_component.get_component_property_value(AtomComponentProperties.decal('Sort Key'))
Report.result(Tests.sort_key_property_set, get_sort_key_property == 0)
# 9. Remove Decal component then UNDO the remove
decal_component.remove()
general.idle_wait_frames(1)
Report.result(Tests.decal_component_removed, not decal_entity.has_component(AtomComponentProperties.decal()))
general.undo()
general.idle_wait_frames(1)
Report.result(Tests.decal_component, decal_entity.has_component(AtomComponentProperties.decal()))
# 10. 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)
# 11. Test IsHidden.
decal_entity.set_visibility_state(False)
Report.result(Tests.is_hidden, decal_entity.is_hidden() is True)
# 12. Test IsVisible.
decal_entity.set_visibility_state(True)
general.idle_wait_frames(1)
Report.result(Tests.is_visible, decal_entity.is_visible() is True)
# 13. Delete Decal entity.
decal_entity.delete()
Report.result(Tests.entity_deleted, not decal_entity.exists())
# 10. UNDO deletion.
# 14. UNDO deletion.
general.undo()
general.idle_wait_frames(1)
Report.result(Tests.deletion_undo, decal_entity.exists())
# 11. REDO deletion.
# 15. REDO deletion.
general.redo()
general.idle_wait_frames(1)
Report.result(Tests.deletion_redo, not decal_entity.exists())
# 12. Look for errors and asserts.
# 16. 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}")
@@ -34,6 +34,7 @@ class EditorComponent:
EditorEntity.add_component() or Entity.add_components() or EditorEntity.get_components_of_type()
which also assigns self.id and self.type_id to the EditorComponent object.
self.type_id is the UUID for the component type as provided by an ebus call.
self.id is an azlmbr.entity.EntityComponentIdPair which contains both entity and component id's
"""
def __init__(self, type_id: uuid):
@@ -270,6 +271,13 @@ class EditorComponent:
warnings.warn("disable_component is deprecated, use set_enabled(False) instead.", DeprecationWarning)
editor.EditorComponentAPIBus(bus.Broadcast, "DisableComponents", [self.id])
def remove(self):
"""
Removes the component from its associated entity. Essentially a delete since only UNDO can return it.
:return: None
"""
editor.EditorComponentAPIBus(bus.Broadcast, "RemoveComponents", [self.id])
@staticmethod
def get_type_ids(component_names: list, entity_type: EditorEntityType = EditorEntityType.GAME) -> list:
"""
@@ -31,11 +31,15 @@ class TestAutomation(TestAutomationBase):
def test_Multiplayer_AutoComponent_NetworkInput(self, request, workspace, editor, launcher_platform):
from .tests import Multiplayer_AutoComponent_NetworkInput as test_module
self._run_prefab_test(request, workspace, editor, test_module)
def test_Multiplayer_AutoComponent_RPC(self, request, workspace, editor, launcher_platform):
from .tests import Multiplayer_AutoComponent_RPC as test_module
self._run_prefab_test(request, workspace, editor, test_module)
def test_Multiplayer_BasicConnectivity_Connects(self, request, workspace, editor, launcher_platform):
from .tests import Multiplayer_BasicConnectivity_Connects as test_module
self._run_prefab_test(request, workspace, editor, test_module)
def test_Multiplayer_SimpleNetworkLevelEntity(self, request, workspace, editor, launcher_platform):
from .tests import Multiplayer_SimpleNetworkLevelEntity as test_module
self._run_prefab_test(request, workspace, editor, test_module)
@@ -62,15 +62,16 @@ def Multiplayer_AutoComponent_RPC():
Report.critical_result(TestSuccessFailTuples.find_network_player, player_id.IsValid())
# 4) Check the editor logs for expected and unexpected log output
# Authority->Autonomous RPC
PLAYERID_RPC_WAIT_TIME_SECONDS = 1.0 # The player id is sent from the server as soon as the player script is spawned. 1 second should be more than enough time to send/receive that RPC.
helper.succeed_if_log_line_found('EditorServer', 'Script: AutoComponent_RPC: Sending client PlayerNumber 1', section_tracer.prints, PLAYERID_RPC_WAIT_TIME_SECONDS)
helper.succeed_if_log_line_found('Script', "AutoComponent_RPC: I'm Player #1", section_tracer.prints, PLAYERID_RPC_WAIT_TIME_SECONDS)
# Uncomment once editor game-play mode supports level entities with net-binding
#PLAYFX_RPC_WAIT_TIME_SECONDS = 1.1 # The server will send an RPC to play an fx on the client every second.
#helper.succeed_if_log_line_found('EditorServer', "Script: AutoComponent_RPC_NetLevelEntity Activated on entity: NetLevelEntity", section_tracer.prints, PLAYFX_RPC_WAIT_TIME_SECONDS)
#helper.succeed_if_log_line_found('EditorServer', "Script: AutoComponent_RPC_NetLevelEntity: Authority sending RPC to play some fx.", section_tracer.prints, PLAYFX_RPC_WAIT_TIME_SECONDS)
#helper.succeed_if_log_line_found('Script', "AutoComponent_RPC_NetLevelEntity: I'm a client playing some superficial fx.", section_tracer.prints, PLAYFX_RPC_WAIT_TIME_SECONDS)
# Authority->Client RPC
PLAYFX_RPC_WAIT_TIME_SECONDS = 1.1 # The server will send an RPC to play an fx on the client every second.
helper.succeed_if_log_line_found('EditorServer', "Script: AutoComponent_RPC_NetLevelEntity Activated on entity: NetLevelEntity", section_tracer.prints, PLAYFX_RPC_WAIT_TIME_SECONDS)
helper.succeed_if_log_line_found('EditorServer', "Script: AutoComponent_RPC_NetLevelEntity: Authority sending RPC to play some fx.", section_tracer.prints, PLAYFX_RPC_WAIT_TIME_SECONDS)
helper.succeed_if_log_line_found('Script', "AutoComponent_RPC_NetLevelEntity: I'm a client playing some fx.", section_tracer.prints, PLAYFX_RPC_WAIT_TIME_SECONDS)
# Exit game mode
@@ -0,0 +1,66 @@
"""
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
"""
# Test Case Title : Check that the basic client connect test works
# fmt: off
class TestConstants:
enter_game_mode = ("Entered game mode", "Failed to enter game mode")
exit_game_mode = ("Exited game mode", "Couldn't exit game mode")
find_network_player = ("Found network player", "Couldn't find network player")
# fmt: on
def Multiplayer_BasicConnectivity_Connects():
r"""
Summary:
Runs a test to make sure that a networked player can be spawned
Level Description:
- Dynamic
1. Although the level is empty, when the server and editor connect the server will spawn the player prefab.
- Static
1. This is an empty level.
Expected Outcome:
We should see the player connect and spawn with no errors.
:return:
"""
import azlmbr.legacy.general as general
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import Tracer
from editor_python_test_tools.utils import TestHelper as helper
level_name = "BasicConnectivity_Connects"
player_prefab_name = "Player"
player_prefab_path = f"levels/multiplayer/{level_name}/{player_prefab_name}.network.spawnable"
helper.init_idle()
# 1) Open Level
helper.open_level("Multiplayer", level_name)
with Tracer() as section_tracer:
# 2) Enter game mode
helper.multiplayer_enter_game_mode(TestConstants.enter_game_mode, player_prefab_path.lower())
# 3) Make sure the network player was spawned
player_id = general.find_game_entity(player_prefab_name)
Report.critical_result(TestConstants.find_network_player, player_id.IsValid())
# Exit game mode
helper.exit_game_mode(TestConstants.exit_game_mode)
if __name__ == "__main__":
from editor_python_test_tools.utils import Report
Report.start_test(Multiplayer_BasicConnectivity_Connects)
@@ -93,7 +93,7 @@ def Terrain_World_ConfigurationWorks():
# 5) Set the base Terrain World values
world_bounds_max = azmath.Vector3(1100.0, 1100.0, 1100.0)
world_bounds_min = azmath.Vector3(10.0, 10.0, 10.0)
height_query_resolution = azmath.Vector2(1.0, 1.0)
height_query_resolution = 1.0
hydra.set_component_property_value(terrain_world_component, "Configuration|World Bounds (Max)", world_bounds_max)
hydra.set_component_property_value(terrain_world_component, "Configuration|World Bounds (Min)", world_bounds_min)
hydra.set_component_property_value(terrain_world_component, "Configuration|Height Query Resolution (m)", height_query_resolution)
@@ -148,7 +148,7 @@ def Terrain_World_ConfigurationWorks():
# 13) Check height value is the expected one when query resolution is changed
testpoint = terrain.TerrainDataRequestBus(bus.Broadcast, 'GetHeightFromFloats', 10.5, 10.5, CLAMP)
height_query_resolution = azmath.Vector2(0.5, 0.5)
height_query_resolution = 0.5
hydra.set_component_property_value(terrain_world_component, "Configuration|Height Query Resolution (m)", height_query_resolution)
general.idle_wait_frames(1)
testpoint2 = terrain.TerrainDataRequestBus(bus.Broadcast, 'GetHeightFromFloats', 10.5, 10.5, CLAMP)
@@ -165,4 +165,3 @@ if __name__ == "__main__":
from editor_python_test_tools.utils import Report
Report.start_test(Terrain_World_ConfigurationWorks)
@@ -38,7 +38,7 @@ def Menus_FileMenuOptions_Work():
("Save As",),
("Save Level Statistics",),
("Edit Project Settings",),
#("Edit Platform Settings",), Temporarily disabled due to https://github.com/o3de/o3de/issues/6604
("Edit Platform Settings",),
("New Project",),
("Open Project",),
("Show Log File",),