Gems/Multiplayer/Code/Tests/ClientHierarchyTests.cpp
TEST_F(HierarchyTests, On_Client_EntityReplicator_DontActivate_BeforeParent)
    {
        // Create a child entity that will be tested for activation inside a hierarchy
        AZStd::unique_ptr<AZ::Entity> childEntity = AZStd::make_unique<AZ::Entity>();
        CreateEntityWithChildHierarchy(childEntity);
        SetupEntity(childEntity, NetEntityId{ 2 }, NetEntityRole::Client);
        // child entity is not activated on purpose here, we are about to test conditional activation check

        // we need a parent-id value to be present in NetworkTransformComponent (which is in client mode and doesn't have a controller)
        SetParentIdOnNetworkTransform(childEntity, NetEntityId{ 1 });
        SetHierarchyRootFieldOnNetworkHierarchyChild<NetworkHierarchyChildComponent>(childEntity, NetEntityId{ 1 });

        // Create an entity replicator for the child entity
        const NetworkEntityHandle childHandle(childEntity.get(), m_networkEntityTracker.get());
        EntityReplicator entityReplicator(*m_entityReplicationManager, m_mockConnection.get(), NetEntityRole::Authority, childHandle);
        entityReplicator.Initialize(childHandle);

        // Entity replicator should not be ready to activate the entity because its parent does not exist
        EXPECT_EQ(entityReplicator.IsReadyToActivate(), false);
    }
/*
     * Hierarchy test - a child entity on a client delaying activation until its hierarchical parent has been activated
     */
Hierarchy test - a child entity on a client delaying activation until its hierarchical parent has been activated
Hierarchy test - a child entity on a client delaying activation until its hierarchical parent has been activated
TEST_F(HierarchyTests, On_Client_EntityReplicator_DontActivate_BeforeParent)
    {
        AZStd::unique_ptr<AZ::Entity> childEntity = AZStd::make_unique<AZ::Entity>();
        CreateEntityWithChildHierarchy(childEntity);
        SetupEntity(childEntity, NetEntityId{ 2 }, NetEntityRole::Client);
        SetParentIdOnNetworkTransform(childEntity, NetEntityId{ 1 });
        SetHierarchyRootFieldOnNetworkHierarchyChild<NetworkHierarchyChildComponent>(childEntity, NetEntityId{ 1 });
        const NetworkEntityHandle childHandle(childEntity.get(), m_networkEntityTracker.get());
        EntityReplicator entityReplicator(*m_entityReplicationManager, m_mockConnection.get(), NetEntityRole::Authority, childHandle);
        entityReplicator.Initialize(childHandle);
        EXPECT_EQ(entityReplicator.IsReadyToActivate(), false);
    }
TEST_F ( HierarchyTests , On_Client_EntityReplicator_DontActivate_BeforeParent ) { AZStd :: unique_ptr < AZ :: Entity > childEntity = AZStd :: make_unique < AZ :: Entity > ( ) ; CreateEntityWithChildHierarchy ( childEntity ) ; SetupEntity ( childEntity , NetEntityId { 2 } , NetEntityRole :: Client ) ; SetParentIdOnNetworkTransform ( childEntity , NetEntityId { 1 } ) ; SetHierarchyRootFieldOnNetworkHierarchyChild < NetworkHierarchyChildComponent > ( childEntity , NetEntityId { 1 } ) ; const NetworkEntityHandle childHandle ( childEntity . get ( ) , m_networkEntityTracker . get ( ) ) ; EntityReplicator entityReplicator ( * m_entityReplicationManager , m_mockConnection . get ( ) , NetEntityRole :: Authority , childHandle ) ; entityReplicator . Initialize ( childHandle ) ; EXPECT_EQ ( entityReplicator . IsReadyToActivate ( ) , false ) ; }
Hierarchy test - a child entity on a client delaying activation until its hierarchical parent has been activated
Hierarchy test - a child entity on a client delaying activation until its hierarchical parent has been activated
// Create a child entity that will be tested for activation inside a hierarchy // child entity is not activated on purpose here, we are about to test conditional activation check // we need a parent-id value to be present in NetworkTransformComponent (which is in client mode and doesn't have a controller) // Create an entity replicator for the child entity // Entity replicator should not be ready to activate the entity because its parent does not exist