LYN-7279 + LYN-7192 | Focus Mode - Container unit tests + Clear container entity open state on new level load (#4558)

* Change SetContainerOpenState to SetContainerOpen.

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>

* Introduce Clear function to avoid retaining all lingering open states when switching contexts/loading a new level.

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>

* Minor FocusMode fixture refactors to support ContainerEntity tests

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>

* Introduce tests for the ContainerEntity API

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>

* Add include to fix issue with EntityContextId not being defined.

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>

* Minor comment fixes. Moved environment clear functions to TearDown function of test fixture.

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>

* Use default editor context id in ContainerEntitySystemComponent

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>

* Revert previous change as the EditorEntityContextId would not be initialized correctly on ContainerEntitySystemComponent Activate.

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>
This commit is contained in:
Danilo Aimini
2021-10-12 13:34:51 -07:00
committed by GitHub
parent c38c9739da
commit 6318247b3d
12 changed files with 575 additions and 130 deletions
@@ -14,6 +14,20 @@
namespace AzToolsFramework
{
void ClearSelectedEntities()
{
AzToolsFramework::ToolsApplicationRequestBus::Broadcast(
&AzToolsFramework::ToolsApplicationRequestBus::Events::SetSelectedEntities, AzToolsFramework::EntityIdList());
}
AzToolsFramework::EntityIdList EditorFocusModeFixture::GetSelectedEntities()
{
AzToolsFramework::EntityIdList selectedEntities;
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
selectedEntities, &AzToolsFramework::ToolsApplicationRequestBus::Events::GetSelectedEntities);
return selectedEntities;
}
void EditorFocusModeFixture::SetUpEditorFixtureImpl()
{
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
@@ -21,6 +35,9 @@ namespace AzToolsFramework
// in the unit tests.
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
m_containerEntityInterface = AZ::Interface<ContainerEntityInterface>::Get();
ASSERT_TRUE(m_containerEntityInterface != nullptr);
m_focusModeInterface = AZ::Interface<FocusModeInterface>::Get();
ASSERT_TRUE(m_focusModeInterface != nullptr);
@@ -31,6 +48,24 @@ namespace AzToolsFramework
m_editorEntityContextId, &AzToolsFramework::EditorEntityContextRequestBus::Events::GetEditorEntityContextId);
GenerateTestHierarchy();
// Clear the focus, disabling focus mode
m_focusModeInterface->ClearFocusRoot(m_editorEntityContextId);
// Clear selection
ClearSelectedEntities();
}
void EditorFocusModeFixture::TearDownEditorFixtureImpl()
{
// Clear Container Entity preserved open states
m_containerEntityInterface->Clear(m_editorEntityContextId);
// Clear the focus, disabling focus mode
m_focusModeInterface->ClearFocusRoot(m_editorEntityContextId);
// Clear selection
ClearSelectedEntities();
}
void EditorFocusModeFixture::GenerateTestHierarchy()
@@ -59,7 +94,7 @@ namespace AzToolsFramework
entity->Activate();
// Move the CarEntity so it's out of the way.
AZ::TransformBus::Event(m_entityMap[CarEntityName], &AZ::TransformBus::Events::SetWorldTranslation, CarEntityPosition);
AZ::TransformBus::Event(m_entityMap[CarEntityName], &AZ::TransformBus::Events::SetWorldTranslation, WorldCarEntityPosition);
// Setup the camera so the Car entity is in view.
AzFramework::SetCameraTransform(