@ -8,9 +8,9 @@
# include <Tests/FocusMode/EditorFocusModeFixture.h>
# include <Tests/FocusMode/EditorFocusModeFixture.h>
namespace AzToolsFramework
namespace UnitTest
{
{
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ Register)
TEST_F ( EditorFocusModeFixture , ContainerEntity Register)
{
{
// Registering an entity is successful.
// Registering an entity is successful.
auto outcome = m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ CarEntityName ] ) ;
auto outcome = m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ CarEntityName ] ) ;
@ -20,7 +20,7 @@ namespace AzToolsFramework
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ CarEntityName ] ) ;
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ CarEntityName ] ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ RegisterTwice)
TEST_F ( EditorFocusModeFixture , ContainerEntity RegisterTwice)
{
{
// Registering an entity twice fails.
// Registering an entity twice fails.
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ CarEntityName ] ) ;
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ CarEntityName ] ) ;
@ -31,7 +31,7 @@ namespace AzToolsFramework
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ CarEntityName ] ) ;
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ CarEntityName ] ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ Unregister)
TEST_F ( EditorFocusModeFixture , ContainerEntity Unregister)
{
{
// Unregistering a container entity is successful.
// Unregistering a container entity is successful.
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ CarEntityName ] ) ;
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ CarEntityName ] ) ;
@ -39,21 +39,21 @@ namespace AzToolsFramework
EXPECT_TRUE ( outcome . IsSuccess ( ) ) ;
EXPECT_TRUE ( outcome . IsSuccess ( ) ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ UnregisterRegularEntity)
TEST_F ( EditorFocusModeFixture , ContainerEntity UnregisterRegularEntity)
{
{
// Unregistering an entity that was not previously registered fails.
// Unregistering an entity that was not previously registered fails.
auto outcome = m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ CarEntityName ] ) ;
auto outcome = m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ CarEntityName ] ) ;
EXPECT_FALSE ( outcome . IsSuccess ( ) ) ;
EXPECT_FALSE ( outcome . IsSuccess ( ) ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ UnregisterTwice)
TEST_F ( EditorFocusModeFixture , ContainerEntity UnregisterTwice)
{
{
// Unregistering a container entity twice fails.
// Unregistering a container entity twice fails.
auto outcome = m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ CarEntityName ] ) ;
auto outcome = m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ CarEntityName ] ) ;
EXPECT_FALSE ( outcome . IsSuccess ( ) ) ;
EXPECT_FALSE ( outcome . IsSuccess ( ) ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ IsContainerOnRegularEntity)
TEST_F ( EditorFocusModeFixture , ContainerEntity IsContainerOnRegularEntity)
{
{
// If a regular entity is passed, IsContainer returns false.
// If a regular entity is passed, IsContainer returns false.
// Note that we use a different entity than the tests above to validate a completely new EntityId.
// Note that we use a different entity than the tests above to validate a completely new EntityId.
@ -61,7 +61,7 @@ namespace AzToolsFramework
EXPECT_FALSE ( isContainer ) ;
EXPECT_FALSE ( isContainer ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ IsContainerOnRegisteredContainer)
TEST_F ( EditorFocusModeFixture , ContainerEntity IsContainerOnRegisteredContainer)
{
{
// If a container entity is passed, IsContainer returns true.
// If a container entity is passed, IsContainer returns true.
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ SportsCarEntityName ] ) ;
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ SportsCarEntityName ] ) ;
@ -72,7 +72,7 @@ namespace AzToolsFramework
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ SportsCarEntityName ] ) ;
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ SportsCarEntityName ] ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ IsContainerOnUnRegisteredContainer)
TEST_F ( EditorFocusModeFixture , ContainerEntity IsContainerOnUnRegisteredContainer)
{
{
// If an entity that was previously a container but was then unregistered is passed, IsContainer returns false.
// If an entity that was previously a container but was then unregistered is passed, IsContainer returns false.
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ SportsCarEntityName ] ) ;
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ SportsCarEntityName ] ) ;
@ -82,14 +82,14 @@ namespace AzToolsFramework
EXPECT_FALSE ( isContainer ) ;
EXPECT_FALSE ( isContainer ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ SetContainerOpenOnRegularEntity)
TEST_F ( EditorFocusModeFixture , ContainerEntity SetContainerOpenOnRegularEntity)
{
{
// Setting a regular entity to open should return a failure.
// Setting a regular entity to open should return a failure.
auto outcome = m_containerEntityInterface - > SetContainerOpen ( m_entityMap [ StreetEntityName ] , true ) ;
auto outcome = m_containerEntityInterface - > SetContainerOpen ( m_entityMap [ StreetEntityName ] , true ) ;
EXPECT_FALSE ( outcome . IsSuccess ( ) ) ;
EXPECT_FALSE ( outcome . IsSuccess ( ) ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ SetContainerOpen)
TEST_F ( EditorFocusModeFixture , ContainerEntity SetContainerOpen)
{
{
// Set a container entity to open, and verify the operation was successful.
// Set a container entity to open, and verify the operation was successful.
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ StreetEntityName ] ) ;
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ StreetEntityName ] ) ;
@ -100,7 +100,7 @@ namespace AzToolsFramework
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ StreetEntityName ] ) ;
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ StreetEntityName ] ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ SetContainerOpenTwice)
TEST_F ( EditorFocusModeFixture , ContainerEntity SetContainerOpenTwice)
{
{
// Set a container entity to open twice, and verify that does not cause a failure (as intended).
// Set a container entity to open twice, and verify that does not cause a failure (as intended).
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ StreetEntityName ] ) ;
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ StreetEntityName ] ) ;
@ -112,7 +112,7 @@ namespace AzToolsFramework
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ StreetEntityName ] ) ;
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ StreetEntityName ] ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ SetContainerClosed)
TEST_F ( EditorFocusModeFixture , ContainerEntity SetContainerClosed)
{
{
// Set a container entity to closed, and verify the operation was successful.
// Set a container entity to closed, and verify the operation was successful.
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ StreetEntityName ] ) ;
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ StreetEntityName ] ) ;
@ -123,7 +123,7 @@ namespace AzToolsFramework
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ StreetEntityName ] ) ;
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ StreetEntityName ] ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ IsContainerOpenOnRegularEntity)
TEST_F ( EditorFocusModeFixture , ContainerEntity IsContainerOpenOnRegularEntity)
{
{
// Query open state on a regular entity, and verify it returns true.
// Query open state on a regular entity, and verify it returns true.
// Open containers behave exactly as regular entities, so this is the expected return value.
// Open containers behave exactly as regular entities, so this is the expected return value.
@ -131,7 +131,7 @@ namespace AzToolsFramework
EXPECT_TRUE ( isOpen ) ;
EXPECT_TRUE ( isOpen ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ IsContainerOpenOnDefaultContainerEntity)
TEST_F ( EditorFocusModeFixture , ContainerEntity IsContainerOpenOnDefaultContainerEntity)
{
{
// Query open state on a newly registered container entity, and verify it returns false.
// Query open state on a newly registered container entity, and verify it returns false.
// Containers are registered closed by default.
// Containers are registered closed by default.
@ -143,7 +143,7 @@ namespace AzToolsFramework
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ CityEntityName ] ) ;
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ CityEntityName ] ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ IsContainerOpenOnOpenContainerEntity)
TEST_F ( EditorFocusModeFixture , ContainerEntity IsContainerOpenOnOpenContainerEntity)
{
{
// Query open state on a container entity that was opened, and verify it returns true.
// Query open state on a container entity that was opened, and verify it returns true.
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ CityEntityName ] ) ;
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ CityEntityName ] ) ;
@ -155,7 +155,7 @@ namespace AzToolsFramework
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ CityEntityName ] ) ;
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ CityEntityName ] ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ IsContainerOpenOnClosedContainerEntity)
TEST_F ( EditorFocusModeFixture , ContainerEntity IsContainerOpenOnClosedContainerEntity)
{
{
// Query open state on a container entity that was opened and then closed, and verify it returns false.
// Query open state on a container entity that was opened and then closed, and verify it returns false.
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ CityEntityName ] ) ;
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ CityEntityName ] ) ;
@ -168,7 +168,7 @@ namespace AzToolsFramework
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ CityEntityName ] ) ;
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ CityEntityName ] ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ ContainerOpenStateIsPreserved)
TEST_F ( EditorFocusModeFixture , ContainerEntity ContainerOpenStateIsPreserved)
{
{
// Register an entity as container, open it, then unregister it.
// Register an entity as container, open it, then unregister it.
// When the entity is registered again, the open state should be preserved.
// When the entity is registered again, the open state should be preserved.
@ -185,14 +185,14 @@ namespace AzToolsFramework
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ CityEntityName ] ) ;
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ CityEntityName ] ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ ClearSucceeds)
TEST_F ( EditorFocusModeFixture , ContainerEntity ClearSucceeds)
{
{
// The Clear function works if no container is registered.
// The Clear function works if no container is registered.
auto outcome = m_containerEntityInterface - > Clear ( m_editorEntityContextId ) ;
auto outcome = m_containerEntityInterface - > Clear ( m_editorEntityContextId ) ;
EXPECT_TRUE ( outcome . IsSuccess ( ) ) ;
EXPECT_TRUE ( outcome . IsSuccess ( ) ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ ClearFailsIfContainersAreStillRegistered)
TEST_F ( EditorFocusModeFixture , ContainerEntity ClearFailsIfContainersAreStillRegistered)
{
{
// The Clear function fails if a container is registered.
// The Clear function fails if a container is registered.
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ Passenger1EntityName ] ) ;
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ Passenger1EntityName ] ) ;
@ -203,7 +203,7 @@ namespace AzToolsFramework
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ Passenger1EntityName ] ) ;
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ Passenger1EntityName ] ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ ClearSucceedsIfContainersAreUnregistered)
TEST_F ( EditorFocusModeFixture , ContainerEntity ClearSucceedsIfContainersAreUnregistered)
{
{
// The Clear function fails if a container is registered.
// The Clear function fails if a container is registered.
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ Passenger1EntityName ] ) ;
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ Passenger1EntityName ] ) ;
@ -212,7 +212,7 @@ namespace AzToolsFramework
EXPECT_TRUE ( outcome . IsSuccess ( ) ) ;
EXPECT_TRUE ( outcome . IsSuccess ( ) ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ ClearDeletesPreservedOpenStates)
TEST_F ( EditorFocusModeFixture , ContainerEntity ClearDeletesPreservedOpenStates)
{
{
// Register an entity as container, open it, unregister it, then call clear.
// Register an entity as container, open it, unregister it, then call clear.
// When the entity is registered again, the open state should not be preserved.
// When the entity is registered again, the open state should not be preserved.
@ -230,14 +230,14 @@ namespace AzToolsFramework
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ Passenger1EntityName ] ) ;
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ Passenger1EntityName ] ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ FindHighestSelectableEntityWithNoContainers)
TEST_F ( EditorFocusModeFixture , ContainerEntity FindHighestSelectableEntityWithNoContainers)
{
{
// When no containers are in the way, the function will just return the entityId that was passed to it.
// When no containers are in the way, the function will just return the entityId that was passed to it.
AZ : : EntityId selectedEntityId = m_containerEntityInterface - > FindHighestSelectableEntity ( m_entityMap [ Passenger2EntityName ] ) ;
AZ : : EntityId selectedEntityId = m_containerEntityInterface - > FindHighestSelectableEntity ( m_entityMap [ Passenger2EntityName ] ) ;
EXPECT_EQ ( selectedEntityId , m_entityMap [ Passenger2EntityName ] ) ;
EXPECT_EQ ( selectedEntityId , m_entityMap [ Passenger2EntityName ] ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ FindHighestSelectableEntityWithClosedContainer)
TEST_F ( EditorFocusModeFixture , ContainerEntity FindHighestSelectableEntityWithClosedContainer)
{
{
// If a closed container is an ancestor of the queried entity, the closed container is selected.
// If a closed container is an ancestor of the queried entity, the closed container is selected.
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ SportsCarEntityName ] ) ; // Containers are closed by default
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ SportsCarEntityName ] ) ; // Containers are closed by default
@ -248,7 +248,7 @@ namespace AzToolsFramework
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ SportsCarEntityName ] ) ;
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ SportsCarEntityName ] ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ FindHighestSelectableEntityWithOpenContainer)
TEST_F ( EditorFocusModeFixture , ContainerEntity FindHighestSelectableEntityWithOpenContainer)
{
{
// If an open container is an ancestor of the queried entity, it is ignored.
// If an open container is an ancestor of the queried entity, it is ignored.
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ SportsCarEntityName ] ) ;
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ SportsCarEntityName ] ) ;
@ -261,7 +261,7 @@ namespace AzToolsFramework
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ SportsCarEntityName ] ) ;
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ SportsCarEntityName ] ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ FindHighestSelectableEntityWithMultipleClosedContainers)
TEST_F ( EditorFocusModeFixture , ContainerEntity FindHighestSelectableEntityWithMultipleClosedContainers)
{
{
// If multiple closed containers are ancestors of the queried entity, the highest closed container is selected.
// If multiple closed containers are ancestors of the queried entity, the highest closed container is selected.
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ StreetEntityName ] ) ;
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ StreetEntityName ] ) ;
@ -275,7 +275,7 @@ namespace AzToolsFramework
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ SportsCarEntityName ] ) ;
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ SportsCarEntityName ] ) ;
}
}
TEST_F ( EditorFocusModeFixture , ContainerEntity Tests_ FindHighestSelectableEntityWithMultipleContainers)
TEST_F ( EditorFocusModeFixture , ContainerEntity FindHighestSelectableEntityWithMultipleContainers)
{
{
// If multiple containers are ancestors of the queried entity, the highest closed container is selected.
// If multiple containers are ancestors of the queried entity, the highest closed container is selected.
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ StreetEntityName ] ) ;
m_containerEntityInterface - > RegisterEntityAsContainer ( m_entityMap [ StreetEntityName ] ) ;
@ -289,5 +289,4 @@ namespace AzToolsFramework
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ StreetEntityName ] ) ;
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ StreetEntityName ] ) ;
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ SportsCarEntityName ] ) ;
m_containerEntityInterface - > UnregisterEntityAsContainer ( m_entityMap [ SportsCarEntityName ] ) ;
}
}
} // namespace UnitTest
}